チェンジセット 3503: as3/gunyarapaint

差分発生行の前後
無視リスト:
コミット日時:
2010/03/07 13:50:38 (3 年前)
コミッタ:
hkrn
ログメッセージ:

IDelegate to IApplication, removed canvas suffix from the methods in GPCanvasWindowControl.as

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/gunyarapaint/branches/gunyarapaint/compat/src/gunyarapaint.as

    r3499 r3503  
    3030private var m_recorder:Recorder; 
    3131private var m_module:IDrawable; 
     32private var m_commit:uint; 
    3233 
    3334private var basex:uint = 0; 
     
    9394} 
    9495 
    95 private function preinit():void 
     96// ふっかつのじゅもんからの復活 
     97 
     98public function deserialize(s:String):void 
     99
     100    // TODO: 実装 
     101    // var log:GPLogger = GPLogger.deserialize(s); 
     102
     103 
     104private function onPreinitialize(event:FlexEvent):void 
    96105{ 
    97106    var width:int = 0; 
     
    112121        parameters['canvasHeight'] = 317; 
    113122    } 
     123     
    114124    width = int(parameters['canvasWidth']); 
    115125    height = int(parameters['canvasHeight']); 
    116126    undoBufferSize = int(parameters['undoBufferSize']); 
     127     
    117128    m_recorder = new Recorder(new ByteArray()); 
    118129    m_recorder.prepare(width, height, undoBufferSize); 
    119130    m_module = DrawModuleFactory.create(DrawModuleFactory.FREE_HAND, m_recorder); 
    120      
    121     m_recorder.addEventListener(CommandEvent.COMMITTED, commitHandler); 
    122     m_recorder.addEventListener(UndoEvent.UNDO, changeUndoRedoHandler); 
    123     m_recorder.addEventListener(UndoEvent.REDO, changeUndoRedoHandler); 
    124     m_recorder.addEventListener(UndoEvent.PUSH, changeUndoRedoHandler); 
    125     //gpCanvasWindow.delegate = penDetailWindow.delegate = this
    126 } 
    127  
    128 private function commitHandler(event:CommandEvent):void 
     131    m_commit = 0; 
     132     
     133    m_recorder.addEventListener(CommandEvent.COMMITTED, onCommit); 
     134    m_recorder.addEventListener(UndoEvent.UNDO, onChangeUndo); 
     135    m_recorder.addEventListener(UndoEvent.REDO, onChangeUndo); 
     136    m_recorder.addEventListener(UndoEvent.PUSH, onChangeUndo)
     137} 
     138 
     139private function onCommit(event:CommandEvent):void 
    129140{ 
    130141    //trace(event.command); 
    131 
    132  
    133 public function init():void 
     142    m_commit++; 
     143
     144 
     145private function onCreationComplete(event:FlexEvent):void 
    134146{ 
    135147    var width:uint = 0; 
     
    198210} 
    199211 
    200 // ふっかつのじゅもんからの復活 
    201  
    202 public function deserialize(s:String):void 
    203 
    204     // TODO: 実装 
    205     // var log:GPLogger = GPLogger.deserialize(s); 
     212private function onApplicationComplete(event:FlexEvent):void 
     213
     214    stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);   
     215    stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);   
     216    stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 
     217    stage.addEventListener(MouseEvent.MOUSE_OUT, onMouseUp); // これを入れるとマズい。 
     218
     219 
     220private function onRemove(event:Event):void 
     221
     222    m_recorder.removeEventListener(CommandEvent.COMMITTED, onCommit); 
     223    m_recorder.removeEventListener(UndoEvent.UNDO, onChangeUndo); 
     224    m_recorder.removeEventListener(UndoEvent.REDO, onChangeUndo); 
     225    m_recorder.removeEventListener(UndoEvent.PUSH, onChangeUndo); 
     226    stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);   
     227    stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);   
     228    stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); 
     229    stage.removeEventListener(MouseEvent.MOUSE_OUT, onMouseUp); 
     230
     231 
     232// canvasでの外のmouseUpをcanvasに通知   
     233private function onMouseUp(evt:MouseEvent):void 
     234
     235    module.interrupt(evt.localX, evt.localY); 
     236
     237 
     238private function onChangeUndo(event:UndoEvent):void 
     239
     240    var undoCount:int = event.undoCount; 
     241    undoButton.label = 'アンドゥ '; 
     242    if (undoCount > 0) { 
     243        undoButton.label += '(' + undoCount + ')'; 
     244        undoButton.enabled = true; 
     245    } 
     246    else { 
     247        undoButton.enabled = false; 
     248    } 
     249    var redoCount:int = event.redoCount; 
     250    redoButton.label = 'リドゥ '; 
     251    if (redoCount > 0) { 
     252        redoButton.label += '(' + redoCount + ')'; 
     253        redoButton.enabled = true; 
     254    } 
     255    else { 
     256        redoButton.enabled = false; 
     257    } 
     258
     259 
     260private function get isShortCut():Boolean 
     261
     262    return stage.focus is mx.core.UITextField; 
     263
     264 
     265private function onKeyDown(evt:KeyboardEvent):void 
     266
     267    if (isShortCut) 
     268        return; 
     269    switch (evt.keyCode) { 
     270        case Keyboard.CONTROL: 
     271            penDetailWindow.pen = DrawModuleFactory.DROPPER; 
     272            break; 
     273        case Keyboard.SHIFT: 
     274            break; 
     275        case Keyboard.SPACE: 
     276            penDetailWindow.pen = ""; // handtool 
     277            break; 
     278        case 48: // 0 
     279        case 96: // ten-key 0 
     280            if (evt.shiftKey) { 
     281                setRotate(0); 
     282            } else { 
     283                setZoom(1); 
     284            } 
     285            break; 
     286        case 65: // a 
     287            // Aキーの状態 = 押下中 
     288            m_module.keyA = true; 
     289            break; 
     290        case 73: // i 
     291            windowsResetButtonHandler(null); 
     292            break; 
     293        case 77: // m 
     294            m_module.horizontalMirror(0xff); 
     295            break; 
     296        case 81: // q 
     297            // Qキーの状態 = 押下中 
     298            m_module.keyQ = true; 
     299            break; 
     300        case 82: // r 
     301            // Rキーの状態 = 押下中 
     302            m_module.shouldStartAfterDrawing = true; 
     303            break; 
     304        // 20090905-haku2 ins start 
     305        case 84: // t 
     306            // Tキーの状態 = 押下中 
     307            m_module.shouldStartBeforeDrawing = true; 
     308            break; 
     309        // 20090905-haku2 ins end 
     310        case 89: // y 
     311            m_module.redo(); 
     312            break; 
     313        case 90: // z 
     314            m_module.undo(); 
     315            break; 
     316        case 107: // ten key + 
     317            // + 
     318            setZoom(canvasZoom.value + 1); 
     319            break; 
     320        case 109: // ten key - 
     321            // - 
     322            setZoom(canvasZoom.value - 1); 
     323            break; 
     324        case 187: 
     325            if (evt.shiftKey) 
     326                // + 
     327                setZoom(canvasZoom.value + 1); 
     328            break; 
     329        case 189: 
     330            // - 
     331            setZoom(canvasZoom.value - 1); 
     332            break; 
     333        case 49: // 1 
     334        case 50: // 2 
     335        case 51: // 3 
     336        case 52: // 4 
     337        case 53: // 5 
     338        case 54: // 6 
     339        case 55: // 7 
     340        case 56: // 8 
     341        case 57: // 9 
     342            if (!evt.shiftKey)// 念のため SHIFTキー対応 (テンキーのほうは放置) 
     343                penDetailWindow.thickness = evt.keyCode - 48; 
     344            break; 
     345        case 97: // ten-key 1 
     346        case 98: // ten-key 2 
     347        case 99: // ten-key 3 
     348        case 100: // ten-key 4 
     349        case 101: // ten-key 5 
     350        case 102: // ten-key 6 
     351        case 103: // ten-key 7 
     352        case 104: // ten-key 8 
     353        case 105: // ten-key 9 
     354            penDetailWindow.thickness = evt.keyCode - 96; 
     355            break; 
     356        case 45: // INS 
     357            if (!evt.shiftKey) 
     358                setRotate(0); 
     359            break; 
     360        default: 
     361            // Alert('' + evt.keyCode); 
     362            break; 
     363    } 
     364
     365 
     366private function onKeyUp(evt:KeyboardEvent):void 
     367
     368    if (isShortCut) 
     369        return; 
     370    switch (evt.keyCode) { 
     371        case Keyboard.CONTROL: 
     372            penDetailWindow.reset(); 
     373            break; 
     374        case Keyboard.SPACE: 
     375            penDetailWindow.reset(); 
     376            break; 
     377        case 65: // a 
     378            // Aキーの状態 = 解放 
     379            m_module.keyA = false; 
     380            break; 
     381        case 81: // q 
     382            // Qキーの状態 = 解放 
     383            m_module.keyQ = false; 
     384            break; 
     385        case 82: // r 
     386            // Rキーの状態 = 解放 
     387            m_module.shouldStartAfterDrawing = false; 
     388            break; 
     389        // 20090905-haku2 ins start 
     390        case 84: // t 
     391            // Tキーの状態 = 解放 
     392            m_module.shouldStartBeforeDrawing = false; 
     393            break; 
     394        // 20090905-haku2 ins end 
     395        return; 
     396    } 
    206397} 
    207398 
    208399private function windowsResetButtonHandler(evt:FlexEvent):void 
    209400{ 
    210     gpCanvasWindow.rotateCanvas(0); 
     401    gpCanvasWindow.rotate(0); 
    211402     
    212403    gpCanvasWindow.transform.matrix = new Matrix(1, 0, 0, 1, initCanvasWindowPos.x, initCanvasWindowPos.y); 
     
    225416    PopUpManager.addPopUp(w, this, true); 
    226417    // w.password = gpCanvas.logger.password; 
    227 } 
    228  
    229 private function appComplete():void 
    230 { 
    231     stage.addEventListener(KeyboardEvent.KEY_DOWN, shortCutKeyDownHandler);   
    232     stage.addEventListener(KeyboardEvent.KEY_UP, shortCutKeyUpHandler);   
    233     stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); 
    234     stage.addEventListener(MouseEvent.MOUSE_OUT, mouseUpHandler); // これを入れるとマズい。 
    235 } 
    236  
    237 // canvasでの外のmouseUpをcanvasに通知   
    238 private function mouseUpHandler(evt:MouseEvent):void 
    239 { 
    240     module.interrupt(evt.localX, evt.localY); 
    241418} 
    242419 
     
    297474    if (evt.value >= 1) { 
    298475        canvasZoomValue.text = String(Math.round(evt.value * 10000)/100); 
    299     } else { 
     476    } 
     477    else { 
    300478        canvasZoomValue.text = String(Math.round((1.0 / (-evt.value + 2)) * 10000)/100); 
    301479    } 
    302480    // 20090905-haku2 ins end 
    303     gpCanvasWindow.zoomCanvas(evt.value); 
     481    gpCanvasWindow.zoom(evt.value); 
    304482} 
    305483// 20090909-haku2 upd start 
     
    311489    if (rm <= 0) { 
    312490        rm = 1; 
    313     } else if (rm >= 100) { 
     491    } 
     492    else if (rm >= 100) { 
    314493        rm /= 100; 
    315     } else { 
     494    } 
     495    else { 
    316496        rm = -(100 / rm) + 2; 
    317497    } 
    318498    canvasZoom.value = rm; 
    319     gpCanvasWindow.zoomCanvas(canvasZoom.value); 
     499    gpCanvasWindow.zoom(canvasZoom.value); 
    320500} 
    321501// 20090909-haku2 upd end 
     
    324504{ 
    325505    canvasRotateValue.text = String(-evt.value); // 20090905-haku2 ins キャンバス回転角度をテキストボックスに反映 
    326     gpCanvasWindow.rotateCanvas(evt.value); 
     506    gpCanvasWindow.rotate(evt.value); 
    327507} 
    328508 
     
    332512{ 
    333513    canvasRotate.value = Number(canvasRotateValue.text); 
    334     gpCanvasWindow.rotateCanvas(canvasRotate.value); 
     514    gpCanvasWindow.rotate(canvasRotate.value); 
    335515} 
    336516// 20090909-haku2 upd end 
     
    369549 
    370550// 20090906-haku2 ins end 
    371 private function changeUndoRedoHandler(event:UndoEvent):void 
    372 { 
    373     var undoCount:int = event.undoCount; 
    374     undoButton.label = 'アンドゥ '; 
    375     if (undoCount > 0) { 
    376         undoButton.label += '(' + undoCount + ')'; 
    377         undoButton.enabled = true; 
    378     } 
    379     else { 
    380         undoButton.enabled = false; 
    381     } 
    382     var redoCount:int = event.redoCount; 
    383     redoButton.label = 'リドゥ '; 
    384     if (redoCount > 0) { 
    385         redoButton.label += '(' + redoCount + ')'; 
    386         redoButton.enabled = true; 
    387     } 
    388     else { 
    389         redoButton.enabled = false; 
    390     } 
    391 } 
    392551 
    393552private function commCompleteHandler(com:Com):void 
     
    415574    if (titleTextInput.text == '') { 
    416575        Alert.show('絵のタイトルが空です。', ALERT_TITLE); 
    417         return; 
    418     } 
    419     if (messageTextArea.text == '') { 
     576    } 
     577    else if (messageTextArea.text == '') { 
    420578        Alert.show('書き込みが空です。', ALERT_TITLE); 
    421         return; 
    422     } 
    423     // TODO: 
    424     if (0 == 0) { 
     579    } 
     580    else if (m_commit == 0) { 
    425581        Alert.show('絵が描かれていません。お絵かきしてください。', ALERT_TITLE); 
    426         return; 
    427     } 
    428     try { 
    429         allEnabled = false; 
    430         alertOnUnload(false); 
    431         var com:Com = new Com(); 
    432         com.postOekaki(this, 
    433             parameters['postUrl'], 
    434             parameters['magic'], 
    435             parameters['cookie'], 
    436             fromTextInput.text, 
    437             titleTextInput.text, 
    438             messageTextArea.text, 
    439             watchlistCheckBox.selected, 
    440             oekakiId, 
    441             new ByteArray(), //_logger.dataForPost, 
    442             commCompleteHandler 
    443         ); 
    444     } catch (e:Error) { 
    445         allEnabled = true; 
    446         alertOnUnload(true); 
    447         Alert.show(e.message, ALERT_TITLE); 
     582    } 
     583    else { 
     584        try { 
     585            allEnabled = false; 
     586            alertOnUnload(false); 
     587            var com:Com = new Com(); 
     588            com.postOekaki(this, 
     589                parameters['postUrl'], 
     590                parameters['magic'], 
     591                parameters['cookie'], 
     592                fromTextInput.text, 
     593                titleTextInput.text, 
     594                messageTextArea.text, 
     595                watchlistCheckBox.selected, 
     596                oekakiId, 
     597                new ByteArray(), //_logger.dataForPost, 
     598                commCompleteHandler 
     599            ); 
     600        } catch (e:Error) { 
     601            allEnabled = true; 
     602            alertOnUnload(true); 
     603            Alert.show(e.message, ALERT_TITLE); 
     604        } 
    448605    } 
    449606} 
     
    465622    canvasRotate.value = v; 
    466623    canvasRotateValue.text = String(-canvasRotate.value); // 20090909-haku2 ins キャンバス回転角度をテキストボックスに反映 
    467     gpCanvasWindow.rotateCanvas(canvasRotate.value); 
     624    gpCanvasWindow.rotate(canvasRotate.value); 
    468625} 
    469626 
     
    471628{ 
    472629    canvasZoom.value = v; 
    473     gpCanvasWindow.zoomCanvas(canvasZoom.value);   
     630    gpCanvasWindow.zoom(canvasZoom.value);   
    474631    // 20090909-haku2 ins start 
    475632    // 拡大率をテキストボックスに反映 
     
    482639} 
    483640 
    484 private function get isShortCut():Boolean 
    485 { 
    486     return stage.focus is mx.core.UITextField; 
    487 } 
    488  
    489 private function shortCutKeyDownHandler(evt:KeyboardEvent):void 
    490 { 
    491     if (isShortCut) 
    492         return; 
    493     switch (evt.keyCode) { 
    494         case Keyboard.CONTROL: 
    495             penDetailWindow.pen = DrawModuleFactory.DROPPER; 
    496             break; 
    497         case Keyboard.SHIFT: 
    498             break; 
    499         case Keyboard.SPACE: 
    500             penDetailWindow.pen = ""; // handtool 
    501             break; 
    502         case 48: // 0 
    503         case 96: // ten-key 0 
    504             if (evt.shiftKey) { 
    505                 setRotate(0); 
    506             } else { 
    507                 setZoom(1); 
    508             } 
    509             break; 
    510         case 65: // a 
    511             // Aキーの状態 = 押下中 
    512             m_module.keyA = true; 
    513             break; 
    514         case 73: // i 
    515             windowsResetButtonHandler(null); 
    516             break; 
    517         case 77: // m 
    518             m_module.horizontalMirror(0xff); 
    519             break; 
    520         case 81: // q 
    521             // Qキーの状態 = 押下中 
    522             m_module.keyQ = true; 
    523             break; 
    524         case 82: // r 
    525             // Rキーの状態 = 押下中 
    526             m_module.shouldStartAfterDrawing = true; 
    527             break; 
    528         // 20090905-haku2 ins start 
    529         case 84: // t 
    530             // Tキーの状態 = 押下中 
    531             m_module.shouldStartBeforeDrawing = true; 
    532             break; 
    533         // 20090905-haku2 ins end 
    534         case 89: // y 
    535             m_module.redo(); 
    536             break; 
    537         case 90: // z 
    538             m_module.undo(); 
    539             break; 
    540         case 107: // ten key + 
    541             // + 
    542             setZoom(canvasZoom.value + 1); 
    543             break; 
    544         case 109: // ten key - 
    545             // - 
    546             setZoom(canvasZoom.value - 1); 
    547             break; 
    548         case 187: 
    549             if (evt.shiftKey) 
    550                 // + 
    551                 setZoom(canvasZoom.value + 1); 
    552             break; 
    553         case 189: 
    554             // - 
    555             setZoom(canvasZoom.value - 1); 
    556             break; 
    557         case 49: // 1 
    558         case 50: // 2 
    559         case 51: // 3 
    560         case 52: // 4 
    561         case 53: // 5 
    562         case 54: // 6 
    563         case 55: // 7 
    564         case 56: // 8 
    565         case 57: // 9 
    566             if (!evt.shiftKey)// 念のため SHIFTキー対応 (テンキーのほうは放置) 
    567                 penDetailWindow.thickness = evt.keyCode - 48; 
    568             break; 
    569         case 97: // ten-key 1 
    570         case 98: // ten-key 2 
    571         case 99: // ten-key 3 
    572         case 100: // ten-key 4 
    573         case 101: // ten-key 5 
    574         case 102: // ten-key 6 
    575         case 103: // ten-key 7 
    576         case 104: // ten-key 8 
    577         case 105: // ten-key 9 
    578             penDetailWindow.thickness = evt.keyCode - 96; 
    579             break; 
    580         case 45: // INS 
    581             if (!evt.shiftKey) 
    582                 setRotate(0); 
    583             break; 
    584         default: 
    585             // Alert('' + evt.keyCode); 
    586             break; 
    587     } 
    588 } 
    589  
    590 private function shortCutKeyUpHandler(evt:KeyboardEvent):void 
    591 { 
    592     if (isShortCut) 
    593         return; 
    594     switch (evt.keyCode) { 
    595         case Keyboard.CONTROL: 
    596             penDetailWindow.reset(); 
    597             break; 
    598         case Keyboard.SPACE: 
    599             penDetailWindow.reset(); 
    600             break; 
    601         case 65: // a 
    602             // Aキーの状態 = 解放 
    603             m_module.keyA = false; 
    604             break; 
    605         case 81: // q 
    606             // Qキーの状態 = 解放 
    607             m_module.keyQ = false; 
    608             break; 
    609         case 82: // r 
    610             // Rキーの状態 = 解放 
    611             m_module.shouldStartAfterDrawing = false; 
    612             break; 
    613         // 20090905-haku2 ins start 
    614         case 84: // t 
    615             // Tキーの状態 = 解放 
    616             m_module.shouldStartBeforeDrawing = false; 
    617             break; 
    618         // 20090905-haku2 ins end 
    619         return; 
    620     } 
    621 } 
    622  
    623641private function alertOnUnload(b:Boolean):void 
    624642{ 
  • as3/gunyarapaint/branches/gunyarapaint/compat/src/gunyarapaint.mxml

    r3499 r3503  
    44    xmlns:gpcontrol="org.libspark.gunyarapaint.controls.*" 
    55    layout="absolute" width="100%" height="100%" 
    6     preinitialize="preinit()" 
    7     creationComplete="init()" 
    8     applicationComplete="appComplete()" 
     6    preinitialize="onPreinitialize(event)" 
     7    creationComplete="onCreationComplete(event)" 
     8    applicationComplete="onApplicationComplete(event)" 
     9    removedFromStage="onRemove(event)" 
    910    borderStyle="solid" cornerRadius="0" borderColor="#333333" 
    1011    backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#cccccc, #cccccc]" 
    11     implements="org.libspark.gunyarapaint.controls.IDelegate
     12    implements="org.libspark.gunyarapaint.framework.ui.IApplication
    1213    alpha="1.0"> 
    1314    <mx:Script source="gunyarapaint.as"> 
  • as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPCanvas.as

    r3499 r3503  
    11package org.libspark.gunyarapaint.controls 
    22{ 
     3    import flash.display.Sprite; 
     4    import flash.events.Event; 
    35    import flash.events.MouseEvent; 
    46    import flash.geom.Rectangle; 
     
    1012    import org.libspark.gunyarapaint.framework.AuxPixelView; 
    1113    import org.libspark.gunyarapaint.framework.TransparentBitmap; 
     14    import org.libspark.gunyarapaint.framework.ui.IApplication; 
    1215     
    1316    internal class GPCanvas extends UIComponent 
    1417    { 
    15         private var m_auxLine:AuxLineView; 
    16         private var m_auxPixel:AuxPixelView; 
    17         private var m_delegate:IDelegate; 
    18          
    19         public function GPCanvas(delegate:IDelegate) 
     18        public function GPCanvas(application:IApplication) 
    2019        { 
    21             var rect:Rectangle = new Rectangle(0, 0, delegate.canvasWidth, delegate.canvasHeight); 
     20            var rect:Rectangle = new Rectangle(0, 0, application.canvasWidth, application.canvasHeight); 
    2221            var transparent:TransparentBitmap = new TransparentBitmap(rect); 
    2322            m_auxLine = new AuxLineView(rect); 
    2423            m_auxPixel = new AuxPixelView(rect); 
    25             m_delegate = delegate
     24            m_application = application
    2625            m_auxLine.visible = true; 
    2726            m_auxPixel.visible = false; 
    2827             
    2928            addChild(transparent); 
    30             addChild(delegate.canvasView); 
     29            addChild(application.canvasView); 
    3130            addChild(m_auxLine); 
    3231            addChild(m_auxPixel); 
    33              
    34             addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); 
    35             addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); 
    36             addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler); 
     32            addEventListener(Event.REMOVED, onRemove); 
     33            addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 
     34            addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 
    3735             
    3836            super(); 
     
    7674        } 
    7775         
    78         private function mouseDownHandler(evt:MouseEvent):void 
     76        private function onRemove(event:Event):void 
    7977        { 
     78            removeMouseEvents(m_application.canvasView); 
     79            removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 
     80            removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); 
     81            removeEventListener(Event.REMOVED, onRemove); 
     82        } 
     83         
     84        private function onMouseDown(event:MouseEvent):void 
     85        { 
     86            var cv:Sprite = m_application.canvasView; 
    8087            try { 
    81                 m_delegate.module.start(evt.localX, evt.localY); 
    82                 m_delegate.canvasView.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); 
     88                m_application.module.start(event.localX, event.localY); 
     89                cv.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 
     90                cv.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); 
    8391            } catch (e:Error) { 
     92                removeMouseEvents(cv); 
    8493                Alert.show(e.message, e.name); 
    8594            } 
    8695        } 
    8796         
    88         private function mouseMoveHandler(evt:MouseEvent):void 
     97        private function onMouseMove(event:MouseEvent):void 
    8998        { 
    90             m_delegate.module.move(evt.localX, evt.localY); 
     99            m_application.module.move(event.localX, event.localY); 
    91100        } 
    92101         
    93         private function mouseUpHandler(evt:MouseEvent):void 
     102        private function onMouseUp(event:MouseEvent):void 
    94103        { 
    95             m_delegate.canvasView.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler); 
    96             m_delegate.module.stop(evt.localX, evt.localY); 
     104            removeMouseEvents(m_application.canvasView); 
     105            m_application.module.stop(event.localX, event.localY); 
    97106        } 
    98107         
    99         private function mouseOutHandler(evt:MouseEvent):void 
     108        private function onMouseOut(event:MouseEvent):void 
    100109        { 
    101             m_delegate.module.interrupt(evt.localX, evt.localY); 
     110            removeMouseEvents(m_application.canvasView); 
     111            m_application.module.interrupt(event.localX, event.localY); 
    102112        } 
     113         
     114        private function removeMouseEvents(cv:Sprite):void 
     115        { 
     116            cv.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 
     117            cv.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut); 
     118        } 
     119         
     120        private var m_auxLine:AuxLineView; 
     121        private var m_auxPixel:AuxPixelView; 
     122        private var m_application:IApplication; 
    103123    } 
    104124} 
  • as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPCanvasWindowControl.as

    r3499 r3503  
    1818    import org.libspark.gunyarapaint.framework.AuxBitmap; 
    1919    import org.libspark.gunyarapaint.framework.Pen; 
     20    import org.libspark.gunyarapaint.framework.ui.IApplication; 
    2021     
    2122    public class GPCanvasWindowControl extends TitleWindow 
     
    5253        } 
    5354         
    54         public function zoomCanvas(m:Number):void 
    55         { 
    56             var rm:Number; 
    57             rm = m >= 1 ? m : 1.0 / (-m + 2); 
    58             m_canvasScale = rm; 
    59             //_logger.eventCanvasScale(rm); 
    60             resizeContainer(); 
    61             moveCanvas(); 
    62         } 
    63          
    64         public function rotateCanvas(deg:int):void 
    65         { 
    66             var br:Rectangle = transform.pixelBounds; 
    67             var p:Point = new Point(br.x + br.width / 2, br.y + br.height / 2); 
     55        public function zoom(value:Number):void 
     56        { 
     57            var mag:Number = value >= 1 ? value : (1.0 / (-value + 2)); 
     58            m_canvasScale = mag; 
     59            m_canvas.scaleX = m_canvas.scaleY = mag; 
     60            resize(); 
     61            update(); 
     62        } 
     63         
     64        public function rotate(value:int):void 
     65        { 
     66            var pb:Rectangle = transform.pixelBounds; 
     67            var p:Point = new Point(pb.x + pb.width / 2, pb.y + pb.height / 2); 
    6868            var m:Matrix = transform.matrix; 
    6969            m.translate(-p.x, -p.y); 
    70             m.rotate((deg - m_preDegree) * (Math.PI / 180)); 
     70            m.rotate((value - m_preDegree) * (Math.PI / 180)); 
    7171            m.translate(p.x, p.y); 
    7272            transform.matrix = m; 
    73             m_preDegree = deg
    74             if (deg == 0) 
     73            m_preDegree = value
     74            if (value == 0) 
    7575                transform.matrix = new Matrix(1, 0, 0, 1, m.tx, m.ty); 
    7676        } 
    7777         
    78         public function scrollCanvas(x:Number, y:Number):void 
     78        public function scroll(x:Number, y:Number):void 
    7979        { 
    8080            m_canvasX = x; 
    8181            m_canvasY = y; 
    82             moveCanvas(); 
     82            update(); 
    8383        } 
    8484         
     
    136136            m_canvasScale = 1; 
    137137             
    138             m_canvas = new GPCanvas(IDelegate(Application.application)); 
     138            m_canvas = new GPCanvas(IApplication(Application.application)); 
    139139            m_canvasContainer.addChild(m_canvas); 
    140140            m_contentContainer.addChild(m_canvasContainer); 
     
    143143            m_resizable = new ResizableComponent(this, new Point(100, 100)); 
    144144             
    145             resizeContainer(); 
    146             moveCanvas(); 
     145            resize(); 
     146            update(); 
    147147             
    148148            addEventListener(ResizeEvent.RESIZE, onResize); 
     
    153153        { 
    154154            m_canvasX = m_hScrollBar.scrollPosition; 
    155             moveCanvas(); 
     155            update(); 
    156156        } 
    157157         
     
    159159        { 
    160160            m_canvasY = m_vScrollBar.scrollPosition; 
    161             moveCanvas(); 
     161            update(); 
    162162        } 
    163163         
    164164        private function onResize(evt:ResizeEvent):void 
    165165        { 
    166             resizeContainer(); 
    167             moveCanvas(); 
     166            resize(); 
     167            update(); 
    168168        } 
    169169         
     
    171171        { 
    172172            if (e.eventPhase == flash.events.EventPhase.AT_TARGET) { 
    173                 var pen:Pen = IDelegate(Application.application).pen; 
     173                var pen:Pen = IApplication(Application.application).pen; 
    174174                setStyle("backgroundColor", pen.color); 
    175175                m_canvas.auxLineColor = pen.color; 
     
    179179        } 
    180180         
    181         private function moveCanvas():void 
    182         { 
    183             var delegate:IDelegate = IDelegate(Application.application); 
    184             var maxX:Number = delegate.canvasWidth * m_canvasScale - m_canvasContainer.width; 
    185             var maxY:Number = delegate.canvasHeight * m_canvasScale - m_canvasContainer.height; 
     181        private function update():void 
     182        { 
     183            var application:IApplication = IApplication(Application.application); 
     184            var maxX:Number = application.canvasWidth * m_canvasScale - m_canvasContainer.width; 
     185            var maxY:Number = application.canvasHeight * m_canvasScale - m_canvasContainer.height; 
    186186            m_canvasX = Math.floor(m_canvasX); 
    187187            m_canvasY = Math.floor(m_canvasY); 
     
    207207        } 
    208208         
    209         private function resizeContainer():void 
     209        private function resize():void 
    210210        { 
    211211            // 仮にサイズを狭める 
     
    221221            m_vScrollBar.height = clientHeight; 
    222222             
    223             var delegate:IDelegate = IDelegate(Application.application); 
    224             var canvasWidth:uint = delegate.canvasWidth; 
    225             var canvasHeight:uint = delegate.canvasHeight; 
     223            var application:IApplication = IApplication(Application.application); 
     224            var canvasWidth:uint = application.canvasWidth; 
     225            var canvasHeight:uint = application.canvasHeight; 
    226226            // TODO: minでいいやん 
    227227            if (canvasWidth * m_canvasScale < clientWidth) 
  • as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPLayerWindowControl.mxml

    r3499 r3503  
    1818            import org.libspark.gunyarapaint.framework.Painter; 
    1919            import org.libspark.gunyarapaint.utils.ComponentResizer; 
    20             import org.libspark.gunyarapaint.controls.IDelegate
     20            import org.libspark.gunyarapaint.framework.ui.IApplication
    2121             
    2222            public function update():void 
    2323            { 
    24                 var layers:LayerBitmapCollection = IDelegate(Application.application).layers; 
     24                var layers:LayerBitmapCollection = IApplication(Application.application).layers; 
    2525                var layer:LayerBitmap = layers.at(layers.currentIndex); 
    2626                var currentLayerBlendMode:String = layer.blendMode; 
     
    4040            private function onCreateComplete():void 
    4141            { 
    42                 var delegate:IDelegate = IDelegate(Application.application); 
    43                 blendModeComboBox.dataProvider = delegate.supportedBlendModes; 
     42                var application:IApplication = IApplication(Application.application); 
     43                blendModeComboBox.dataProvider = application.supportedBlendModes; 
    4444                enabled = true; 
    4545                update(); 
    4646                 
    47                 var layers:LayerBitmapCollection = delegate.layers; 
     47                var layers:LayerBitmapCollection = application.layers; 
    4848                var currentLayerIndex:uint = layers.currentIndex; 
    4949                var currentLayerBlendMode:String = layers.at(currentLayerIndex).blendMode; 
     
    6363            private function onClickLayer(evt:ListEvent):void 
    6464            { 
    65                 var delegate:IDelegate = IDelegate(Application.application); 
     65                var application:IApplication = IApplication(Application.application); 
    6666                var layer:LayerBitmap = LayerBitmap(evt.currentTarget.selectedItem); 
    67                 if (delegate.layers.currentIndex != layer.index) 
    68                     delegate.module.layerIndex = layer.index; 
     67                if (application.layers.currentIndex != layer.index) 
     68                    application.module.layerIndex = layer.index; 
    6969            } 
    7070             
    7171            private function onCreateLayer(evt:Event):void 
    7272            { 
    73                 IDelegate(Application.application).module.createLayer(); 
     73                IApplication(Application.application).module.createLayer(); 
    7474                update(); 
    7575            } 
     
    7777            private function onCopyLayer(evt:Event):void 
    7878            { 
    79                 IDelegate(Application.application).module.copyLayer(); 
     79                IApplication(Application.application).module.copyLayer(); 
    8080                update(); 
    8181            } 
     
    8484            { 
    8585                try { 
    86                     IDelegate(Application.application).module.removeLayer(); 
     86                    IApplication(Application.application).module.removeLayer(); 
    8787                    update(); 
    8888                } catch (e:Error) { 
     
    9494            { 
    9595                try { 
    96                     IDelegate(Application.application).module.mergeLayers(); 
     96                    IApplication(Application.application).module.mergeLayers(); 
    9797                    update(); 
    9898                } catch (e:Error) { 
     
    108108            private function onChangeAlphaSlider(evt:SliderEvent):void 
    109109            { 
    110                 IDelegate(Application.application).module.layerAlpha = evt.value; 
     110                IApplication(Application.application).module.layerAlpha = evt.value; 
    111111            } 
    112112             
    113113            private function onSelectBlendMode(evt:ListEvent):void 
    114114            { 
    115                 IDelegate(Application.application).module.layerBlendMode = String(evt.currentTarget.value); 
     115                IApplication(Application.application).module.layerBlendMode = String(evt.currentTarget.value); 
    116116            } 
    117117             
    118118            private function onDragComplete(evt:DragEvent):void 
    119119            { 
    120                 var delegate:IDelegate = IDelegate(Application.application); 
     120                var application:IApplication = IApplication(Application.application); 
    121121                var a:Array = (layerDataGrid.dataProvider as ArrayCollection).toArray().reverse(); 
    122122                var length:uint = a.length; 
    123                 var layers:LayerBitmapCollection = delegate.layers; 
     123                var layers:LayerBitmapCollection = application.layers; 
    124124                for (var i:uint = 0; i < length; i++) { 
    125125                    var from:uint = a[i].index; 
    126126                    var to:uint = layers.at(i).index; 
    127127                    if (a[i].index != to) { 
    128                         delegate.module.swapLayers(from, to); 
     128                        application.module.swapLayers(from, to); 
    129129                        break; 
    130130                    } 
  • as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/PenDetailWindowControl.mxml

    r3490 r3503  
    1111             
    1212            import org.libspark.gunyarapaint.framework.modules.DrawModuleFactory; 
     13            import org.libspark.gunyarapaint.framework.ui.IApplication; 
    1314             
    1415            private var m_gridItemPalette:GridItem; 
     
    2526                else if (eraserButton.selected) { 
    2627                    pen = DrawModuleFactory.ERASER; 
    27                     IDelegate(Application.application).module.blendMode = BlendMode.ERASE; 
     28                    IApplication(Application.application).module.blendMode = BlendMode.ERASE; 
    2829                } 
    2930                else if (dotButton.selected) { 
     
    3233                else { 
    3334                    pen = String(blendModeComboBox.value); 
    34                     IDelegate(Application.application).module.blendMode = String(blendModeComboBox.value); 
     35                    IApplication(Application.application).module.blendMode = String(blendModeComboBox.value); 
    3536                } 
    3637            } 
     
    4243                eraserButton.selected = false; 
    4344                dotButton.selected = false; 
    44                 var delegate:IDelegate = IDelegate(Application.application); 
    45                 delegate.setModule(String(blendModeComboBox.value)); 
     45                var application:IApplication = IApplication(Application.application); 
     46                application.setModule(String(blendModeComboBox.value)); 
    4647            } 
    4748             
     
    7071             
    7172            /* 
    72             public function set delegate(value:IDelegate):void 
     73            public function set application(value:IApplication):void 
    7374            { 
    7475            penDetail.logger = l; 
     
    108109                currentState = mode; 
    109110                if (mode != "handtool") 
    110                     IDelegate(Application.application).setModule(currentState); 
     111                    IApplication(Application.application).setModule(currentState); 
    111112            } 
    112113             
    113114            public function set thickness(t:uint):void 
    114115            { 
    115                 IDelegate(Application.application).module.thickness = thicknessSlider.value = t; 
     116                IApplication(Application.application).module.thickness = thicknessSlider.value = t; 
    116117            } 
    117118             
    118119            private function onInitialize():void 
    119120            { 
    120                 blendModeComboBox.dataProvider = IDelegate(Application.application).supportedBlendModes; 
     121                blendModeComboBox.dataProvider = IApplication(Application.application).supportedBlendModes; 
    121122                onClickPalette(1); 
    122123                // 初期値と設定値が一緒なのでイベントが飛んでこない、明示的に呼んであげる 
     
    134135                palette.setStyle("borderColor", 0x000000); 
    135136                m_gridItemPalette = palette; 
    136                 IDelegate(Application.application).module.color = m_gridItemPalette.getStyle("backgroundColor"); 
     137                IApplication(Application.application).module.color = m_gridItemPalette.getStyle("backgroundColor"); 
    137138                setColorRGBSlider(m_gridItemPalette.getStyle("backgroundColor")); // 20090905-haku2 ins 
    138139            } 
     
    170171                else if (evt.type == Event.CHANGE) { 
    171172                var color:uint = SColorPicker(evt.target).selectedColor; 
    172                 m_delegate.module.color = color; 
     173                m_application.module.color = color; 
    173174                m_gridItemPalette.setStyle("backgroundColor", color); 
    174175                setColRGBSlider(color); // 20090905-haku2 ins 
     
    201202                else { 
    202203                    pen = DrawModuleFactory.ERASER; 
    203                     IDelegate(Application.application).module.blendMode = BlendMode.ERASE; 
     204                    IApplication(Application.application).module.blendMode = BlendMode.ERASE; 
    204205                } 
    205206            } 
     
    216217            { 
    217218                cancel(); 
    218                 var delegate:IDelegate = IDelegate(Application.application); 
    219                 delegate.setModule(String(evt.currentTarget.value)); 
     219                var application:IApplication = IApplication(Application.application); 
     220                application.setModule(String(evt.currentTarget.value)); 
    220221            } 
    221222             
     
    223224            { 
    224225                cancel(); 
    225                 IDelegate(Application.application).module.blendMode = String(evt.currentTarget.value); 
     226                IApplication(Application.application).module.blendMode = String(evt.currentTarget.value); 
    226227            } 
    227228             
    228229            private function onChangeThicknessSlider(evt:SliderEvent):void 
    229230            { 
    230                 IDelegate(Application.application).module.thickness = evt.value; 
     231                IApplication(Application.application).module.thickness = evt.value; 
    231232            } 
    232233             
     
    261262                        break; 
    262263                } 
    263                 IDelegate(Application.application).module.color = color; 
     264                IApplication(Application.application).module.color = color; 
    264265                m_gridItemPalette.setStyle('backgroundColor', color); 
    265266            } 
     
    267268            private function onChangeAlphaSlider(evt:SliderEvent):void 
    268269            { 
    269                 IDelegate(Application.application).module.alpha = evt.value; 
     270                IApplication(Application.application).module.alpha = evt.value; 
    270271            } 
    271272        ]]>