チェンジセット 3503: as3/gunyarapaint
- コミット日時:
- 2010/03/07 13:50:38 (3 年前)
- ファイル:
-
- as3/gunyarapaint/branches/gunyarapaint/compat/src/gunyarapaint.as (更新) (14 diffs)
- as3/gunyarapaint/branches/gunyarapaint/compat/src/gunyarapaint.mxml (更新) (1 diff)
- as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPCanvas.as (更新) (3 diffs)
- as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPCanvasWindowControl.as (更新) (10 diffs)
- as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPLayerWindowControl.mxml (更新) (7 diffs)
- as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/IDelegate.as (削除)
- as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/PenDetailWindowControl.mxml (更新) (13 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/gunyarapaint/branches/gunyarapaint/compat/src/gunyarapaint.as
r3499 r3503 30 30 private var m_recorder:Recorder; 31 31 private var m_module:IDrawable; 32 private var m_commit:uint; 32 33 33 34 private var basex:uint = 0; … … 93 94 } 94 95 95 private function preinit():void 96 // ふっかつのじゅもんからの復活 97 98 public function deserialize(s:String):void 99 { 100 // TODO: 実装 101 // var log:GPLogger = GPLogger.deserialize(s); 102 } 103 104 private function onPreinitialize(event:FlexEvent):void 96 105 { 97 106 var width:int = 0; … … 112 121 parameters['canvasHeight'] = 317; 113 122 } 123 114 124 width = int(parameters['canvasWidth']); 115 125 height = int(parameters['canvasHeight']); 116 126 undoBufferSize = int(parameters['undoBufferSize']); 127 117 128 m_recorder = new Recorder(new ByteArray()); 118 129 m_recorder.prepare(width, height, undoBufferSize); 119 130 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):void131 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 139 private function onCommit(event:CommandEvent):void 129 140 { 130 141 //trace(event.command); 131 } 132 133 public function init():void 142 m_commit++; 143 } 144 145 private function onCreationComplete(event:FlexEvent):void 134 146 { 135 147 var width:uint = 0; … … 198 210 } 199 211 200 // ふっかつのじゅもんからの復活 201 202 public function deserialize(s:String):void 203 { 204 // TODO: 実装 205 // var log:GPLogger = GPLogger.deserialize(s); 212 private 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 220 private 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に通知 233 private function onMouseUp(evt:MouseEvent):void 234 { 235 module.interrupt(evt.localX, evt.localY); 236 } 237 238 private 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 260 private function get isShortCut():Boolean 261 { 262 return stage.focus is mx.core.UITextField; 263 } 264 265 private 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 366 private 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 } 206 397 } 207 398 208 399 private function windowsResetButtonHandler(evt:FlexEvent):void 209 400 { 210 gpCanvasWindow.rotate Canvas(0);401 gpCanvasWindow.rotate(0); 211 402 212 403 gpCanvasWindow.transform.matrix = new Matrix(1, 0, 0, 1, initCanvasWindowPos.x, initCanvasWindowPos.y); … … 225 416 PopUpManager.addPopUp(w, this, true); 226 417 // w.password = gpCanvas.logger.password; 227 }228 229 private function appComplete():void230 {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):void239 {240 module.interrupt(evt.localX, evt.localY);241 418 } 242 419 … … 297 474 if (evt.value >= 1) { 298 475 canvasZoomValue.text = String(Math.round(evt.value * 10000)/100); 299 } else { 476 } 477 else { 300 478 canvasZoomValue.text = String(Math.round((1.0 / (-evt.value + 2)) * 10000)/100); 301 479 } 302 480 // 20090905-haku2 ins end 303 gpCanvasWindow.zoom Canvas(evt.value);481 gpCanvasWindow.zoom(evt.value); 304 482 } 305 483 // 20090909-haku2 upd start … … 311 489 if (rm <= 0) { 312 490 rm = 1; 313 } else if (rm >= 100) { 491 } 492 else if (rm >= 100) { 314 493 rm /= 100; 315 } else { 494 } 495 else { 316 496 rm = -(100 / rm) + 2; 317 497 } 318 498 canvasZoom.value = rm; 319 gpCanvasWindow.zoom Canvas(canvasZoom.value);499 gpCanvasWindow.zoom(canvasZoom.value); 320 500 } 321 501 // 20090909-haku2 upd end … … 324 504 { 325 505 canvasRotateValue.text = String(-evt.value); // 20090905-haku2 ins キャンバス回転角度をテキストボックスに反映 326 gpCanvasWindow.rotate Canvas(evt.value);506 gpCanvasWindow.rotate(evt.value); 327 507 } 328 508 … … 332 512 { 333 513 canvasRotate.value = Number(canvasRotateValue.text); 334 gpCanvasWindow.rotate Canvas(canvasRotate.value);514 gpCanvasWindow.rotate(canvasRotate.value); 335 515 } 336 516 // 20090909-haku2 upd end … … 369 549 370 550 // 20090906-haku2 ins end 371 private function changeUndoRedoHandler(event:UndoEvent):void372 {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 }392 551 393 552 private function commCompleteHandler(com:Com):void … … 415 574 if (titleTextInput.text == '') { 416 575 Alert.show('絵のタイトルが空です。', ALERT_TITLE); 417 return; 418 } 419 if (messageTextArea.text == '') { 576 } 577 else if (messageTextArea.text == '') { 420 578 Alert.show('書き込みが空です。', ALERT_TITLE); 421 return; 422 } 423 // TODO: 424 if (0 == 0) { 579 } 580 else if (m_commit == 0) { 425 581 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 } 448 605 } 449 606 } … … 465 622 canvasRotate.value = v; 466 623 canvasRotateValue.text = String(-canvasRotate.value); // 20090909-haku2 ins キャンバス回転角度をテキストボックスに反映 467 gpCanvasWindow.rotate Canvas(canvasRotate.value);624 gpCanvasWindow.rotate(canvasRotate.value); 468 625 } 469 626 … … 471 628 { 472 629 canvasZoom.value = v; 473 gpCanvasWindow.zoom Canvas(canvasZoom.value);630 gpCanvasWindow.zoom(canvasZoom.value); 474 631 // 20090909-haku2 ins start 475 632 // 拡大率をテキストボックスに反映 … … 482 639 } 483 640 484 private function get isShortCut():Boolean485 {486 return stage.focus is mx.core.UITextField;487 }488 489 private function shortCutKeyDownHandler(evt:KeyboardEvent):void490 {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 = ""; // handtool501 break;502 case 48: // 0503 case 96: // ten-key 0504 if (evt.shiftKey) {505 setRotate(0);506 } else {507 setZoom(1);508 }509 break;510 case 65: // a511 // Aキーの状態 = 押下中512 m_module.keyA = true;513 break;514 case 73: // i515 windowsResetButtonHandler(null);516 break;517 case 77: // m518 m_module.horizontalMirror(0xff);519 break;520 case 81: // q521 // Qキーの状態 = 押下中522 m_module.keyQ = true;523 break;524 case 82: // r525 // Rキーの状態 = 押下中526 m_module.shouldStartAfterDrawing = true;527 break;528 // 20090905-haku2 ins start529 case 84: // t530 // Tキーの状態 = 押下中531 m_module.shouldStartBeforeDrawing = true;532 break;533 // 20090905-haku2 ins end534 case 89: // y535 m_module.redo();536 break;537 case 90: // z538 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: // 1558 case 50: // 2559 case 51: // 3560 case 52: // 4561 case 53: // 5562 case 54: // 6563 case 55: // 7564 case 56: // 8565 case 57: // 9566 if (!evt.shiftKey)// 念のため SHIFTキー対応 (テンキーのほうは放置)567 penDetailWindow.thickness = evt.keyCode - 48;568 break;569 case 97: // ten-key 1570 case 98: // ten-key 2571 case 99: // ten-key 3572 case 100: // ten-key 4573 case 101: // ten-key 5574 case 102: // ten-key 6575 case 103: // ten-key 7576 case 104: // ten-key 8577 case 105: // ten-key 9578 penDetailWindow.thickness = evt.keyCode - 96;579 break;580 case 45: // INS581 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):void591 {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: // a602 // Aキーの状態 = 解放603 m_module.keyA = false;604 break;605 case 81: // q606 // Qキーの状態 = 解放607 m_module.keyQ = false;608 break;609 case 82: // r610 // Rキーの状態 = 解放611 m_module.shouldStartAfterDrawing = false;612 break;613 // 20090905-haku2 ins start614 case 84: // t615 // Tキーの状態 = 解放616 m_module.shouldStartBeforeDrawing = false;617 break;618 // 20090905-haku2 ins end619 return;620 }621 }622 623 641 private function alertOnUnload(b:Boolean):void 624 642 { as3/gunyarapaint/branches/gunyarapaint/compat/src/gunyarapaint.mxml
r3499 r3503 4 4 xmlns:gpcontrol="org.libspark.gunyarapaint.controls.*" 5 5 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)" 9 10 borderStyle="solid" cornerRadius="0" borderColor="#333333" 10 11 backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#cccccc, #cccccc]" 11 implements="org.libspark.gunyarapaint. controls.IDelegate"12 implements="org.libspark.gunyarapaint.framework.ui.IApplication" 12 13 alpha="1.0"> 13 14 <mx:Script source="gunyarapaint.as"> as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPCanvas.as
r3499 r3503 1 1 package org.libspark.gunyarapaint.controls 2 2 { 3 import flash.display.Sprite; 4 import flash.events.Event; 3 5 import flash.events.MouseEvent; 4 6 import flash.geom.Rectangle; … … 10 12 import org.libspark.gunyarapaint.framework.AuxPixelView; 11 13 import org.libspark.gunyarapaint.framework.TransparentBitmap; 14 import org.libspark.gunyarapaint.framework.ui.IApplication; 12 15 13 16 internal class GPCanvas extends UIComponent 14 17 { 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) 20 19 { 21 var rect:Rectangle = new Rectangle(0, 0, delegate.canvasWidth, delegate.canvasHeight);20 var rect:Rectangle = new Rectangle(0, 0, application.canvasWidth, application.canvasHeight); 22 21 var transparent:TransparentBitmap = new TransparentBitmap(rect); 23 22 m_auxLine = new AuxLineView(rect); 24 23 m_auxPixel = new AuxPixelView(rect); 25 m_ delegate = delegate;24 m_application = application; 26 25 m_auxLine.visible = true; 27 26 m_auxPixel.visible = false; 28 27 29 28 addChild(transparent); 30 addChild( delegate.canvasView);29 addChild(application.canvasView); 31 30 addChild(m_auxLine); 32 31 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); 37 35 38 36 super(); … … 76 74 } 77 75 78 private function mouseDownHandler(evt:MouseEvent):void76 private function onRemove(event:Event):void 79 77 { 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; 80 87 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); 83 91 } catch (e:Error) { 92 removeMouseEvents(cv); 84 93 Alert.show(e.message, e.name); 85 94 } 86 95 } 87 96 88 private function mouseMoveHandler(evt:MouseEvent):void97 private function onMouseMove(event:MouseEvent):void 89 98 { 90 m_ delegate.module.move(evt.localX, evt.localY);99 m_application.module.move(event.localX, event.localY); 91 100 } 92 101 93 private function mouseUpHandler(evt:MouseEvent):void102 private function onMouseUp(event:MouseEvent):void 94 103 { 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); 97 106 } 98 107 99 private function mouseOutHandler(evt:MouseEvent):void108 private function onMouseOut(event:MouseEvent):void 100 109 { 101 m_delegate.module.interrupt(evt.localX, evt.localY); 110 removeMouseEvents(m_application.canvasView); 111 m_application.module.interrupt(event.localX, event.localY); 102 112 } 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; 103 123 } 104 124 } as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPCanvasWindowControl.as
r3499 r3503 18 18 import org.libspark.gunyarapaint.framework.AuxBitmap; 19 19 import org.libspark.gunyarapaint.framework.Pen; 20 import org.libspark.gunyarapaint.framework.ui.IApplication; 20 21 21 22 public class GPCanvasWindowControl extends TitleWindow … … 52 53 } 53 54 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); 68 68 var m:Matrix = transform.matrix; 69 69 m.translate(-p.x, -p.y); 70 m.rotate(( deg- m_preDegree) * (Math.PI / 180));70 m.rotate((value - m_preDegree) * (Math.PI / 180)); 71 71 m.translate(p.x, p.y); 72 72 transform.matrix = m; 73 m_preDegree = deg;74 if ( deg== 0)73 m_preDegree = value; 74 if (value == 0) 75 75 transform.matrix = new Matrix(1, 0, 0, 1, m.tx, m.ty); 76 76 } 77 77 78 public function scroll Canvas(x:Number, y:Number):void78 public function scroll(x:Number, y:Number):void 79 79 { 80 80 m_canvasX = x; 81 81 m_canvasY = y; 82 moveCanvas();82 update(); 83 83 } 84 84 … … 136 136 m_canvasScale = 1; 137 137 138 m_canvas = new GPCanvas(I Delegate(Application.application));138 m_canvas = new GPCanvas(IApplication(Application.application)); 139 139 m_canvasContainer.addChild(m_canvas); 140 140 m_contentContainer.addChild(m_canvasContainer); … … 143 143 m_resizable = new ResizableComponent(this, new Point(100, 100)); 144 144 145 resize Container();146 moveCanvas();145 resize(); 146 update(); 147 147 148 148 addEventListener(ResizeEvent.RESIZE, onResize); … … 153 153 { 154 154 m_canvasX = m_hScrollBar.scrollPosition; 155 moveCanvas();155 update(); 156 156 } 157 157 … … 159 159 { 160 160 m_canvasY = m_vScrollBar.scrollPosition; 161 moveCanvas();161 update(); 162 162 } 163 163 164 164 private function onResize(evt:ResizeEvent):void 165 165 { 166 resize Container();167 moveCanvas();166 resize(); 167 update(); 168 168 } 169 169 … … 171 171 { 172 172 if (e.eventPhase == flash.events.EventPhase.AT_TARGET) { 173 var pen:Pen = I Delegate(Application.application).pen;173 var pen:Pen = IApplication(Application.application).pen; 174 174 setStyle("backgroundColor", pen.color); 175 175 m_canvas.auxLineColor = pen.color; … … 179 179 } 180 180 181 private function moveCanvas():void182 { 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; 186 186 m_canvasX = Math.floor(m_canvasX); 187 187 m_canvasY = Math.floor(m_canvasY); … … 207 207 } 208 208 209 private function resize Container():void209 private function resize():void 210 210 { 211 211 // 仮にサイズを狭める … … 221 221 m_vScrollBar.height = clientHeight; 222 222 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; 226 226 // TODO: minでいいやん 227 227 if (canvasWidth * m_canvasScale < clientWidth) as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/GPLayerWindowControl.mxml
r3499 r3503 18 18 import org.libspark.gunyarapaint.framework.Painter; 19 19 import org.libspark.gunyarapaint.utils.ComponentResizer; 20 import org.libspark.gunyarapaint. controls.IDelegate;20 import org.libspark.gunyarapaint.framework.ui.IApplication; 21 21 22 22 public function update():void 23 23 { 24 var layers:LayerBitmapCollection = I Delegate(Application.application).layers;24 var layers:LayerBitmapCollection = IApplication(Application.application).layers; 25 25 var layer:LayerBitmap = layers.at(layers.currentIndex); 26 26 var currentLayerBlendMode:String = layer.blendMode; … … 40 40 private function onCreateComplete():void 41 41 { 42 var delegate:IDelegate = IDelegate(Application.application);43 blendModeComboBox.dataProvider = delegate.supportedBlendModes;42 var application:IApplication = IApplication(Application.application); 43 blendModeComboBox.dataProvider = application.supportedBlendModes; 44 44 enabled = true; 45 45 update(); 46 46 47 var layers:LayerBitmapCollection = delegate.layers;47 var layers:LayerBitmapCollection = application.layers; 48 48 var currentLayerIndex:uint = layers.currentIndex; 49 49 var currentLayerBlendMode:String = layers.at(currentLayerIndex).blendMode; … … 63 63 private function onClickLayer(evt:ListEvent):void 64 64 { 65 var delegate:IDelegate = IDelegate(Application.application);65 var application:IApplication = IApplication(Application.application); 66 66 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; 69 69 } 70 70 71 71 private function onCreateLayer(evt:Event):void 72 72 { 73 I Delegate(Application.application).module.createLayer();73 IApplication(Application.application).module.createLayer(); 74 74 update(); 75 75 } … … 77 77 private function onCopyLayer(evt:Event):void 78 78 { 79 I Delegate(Application.application).module.copyLayer();79 IApplication(Application.application).module.copyLayer(); 80 80 update(); 81 81 } … … 84 84 { 85 85 try { 86 I Delegate(Application.application).module.removeLayer();86 IApplication(Application.application).module.removeLayer(); 87 87 update(); 88 88 } catch (e:Error) { … … 94 94 { 95 95 try { 96 I Delegate(Application.application).module.mergeLayers();96 IApplication(Application.application).module.mergeLayers(); 97 97 update(); 98 98 } catch (e:Error) { … … 108 108 private function onChangeAlphaSlider(evt:SliderEvent):void 109 109 { 110 I Delegate(Application.application).module.layerAlpha = evt.value;110 IApplication(Application.application).module.layerAlpha = evt.value; 111 111 } 112 112 113 113 private function onSelectBlendMode(evt:ListEvent):void 114 114 { 115 I Delegate(Application.application).module.layerBlendMode = String(evt.currentTarget.value);115 IApplication(Application.application).module.layerBlendMode = String(evt.currentTarget.value); 116 116 } 117 117 118 118 private function onDragComplete(evt:DragEvent):void 119 119 { 120 var delegate:IDelegate = IDelegate(Application.application);120 var application:IApplication = IApplication(Application.application); 121 121 var a:Array = (layerDataGrid.dataProvider as ArrayCollection).toArray().reverse(); 122 122 var length:uint = a.length; 123 var layers:LayerBitmapCollection = delegate.layers;123 var layers:LayerBitmapCollection = application.layers; 124 124 for (var i:uint = 0; i < length; i++) { 125 125 var from:uint = a[i].index; 126 126 var to:uint = layers.at(i).index; 127 127 if (a[i].index != to) { 128 delegate.module.swapLayers(from, to);128 application.module.swapLayers(from, to); 129 129 break; 130 130 } as3/gunyarapaint/branches/gunyarapaint/compat/src/org/libspark/gunyarapaint/controls/PenDetailWindowControl.mxml
r3490 r3503 11 11 12 12 import org.libspark.gunyarapaint.framework.modules.DrawModuleFactory; 13 import org.libspark.gunyarapaint.framework.ui.IApplication; 13 14 14 15 private var m_gridItemPalette:GridItem; … … 25 26 else if (eraserButton.selected) { 26 27 pen = DrawModuleFactory.ERASER; 27 I Delegate(Application.application).module.blendMode = BlendMode.ERASE;28 IApplication(Application.application).module.blendMode = BlendMode.ERASE; 28 29 } 29 30 else if (dotButton.selected) { … … 32 33 else { 33 34 pen = String(blendModeComboBox.value); 34 I Delegate(Application.application).module.blendMode = String(blendModeComboBox.value);35 IApplication(Application.application).module.blendMode = String(blendModeComboBox.value); 35 36 } 36 37 } … … 42 43 eraserButton.selected = false; 43 44 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)); 46 47 } 47 48 … … 70 71 71 72 /* 72 public function set delegate(value:IDelegate):void73 public function set application(value:IApplication):void 73 74 { 74 75 penDetail.logger = l; … … 108 109 currentState = mode; 109 110 if (mode != "handtool") 110 I Delegate(Application.application).setModule(currentState);111 IApplication(Application.application).setModule(currentState); 111 112 } 112 113 113 114 public function set thickness(t:uint):void 114 115 { 115 I Delegate(Application.application).module.thickness = thicknessSlider.value = t;116 IApplication(Application.application).module.thickness = thicknessSlider.value = t; 116 117 } 117 118 118 119 private function onInitialize():void 119 120 { 120 blendModeComboBox.dataProvider = I Delegate(Application.application).supportedBlendModes;121 blendModeComboBox.dataProvider = IApplication(Application.application).supportedBlendModes; 121 122 onClickPalette(1); 122 123 // 初期値と設定値が一緒なのでイベントが飛んでこない、明示的に呼んであげる … … 134 135 palette.setStyle("borderColor", 0x000000); 135 136 m_gridItemPalette = palette; 136 I Delegate(Application.application).module.color = m_gridItemPalette.getStyle("backgroundColor");137 IApplication(Application.application).module.color = m_gridItemPalette.getStyle("backgroundColor"); 137 138 setColorRGBSlider(m_gridItemPalette.getStyle("backgroundColor")); // 20090905-haku2 ins 138 139 } … … 170 171 else if (evt.type == Event.CHANGE) { 171 172 var color:uint = SColorPicker(evt.target).selectedColor; 172 m_ delegate.module.color = color;173 m_application.module.color = color; 173 174 m_gridItemPalette.setStyle("backgroundColor", color); 174 175 setColRGBSlider(color); // 20090905-haku2 ins … … 201 202 else { 202 203 pen = DrawModuleFactory.ERASER; 203 I Delegate(Application.application).module.blendMode = BlendMode.ERASE;204 IApplication(Application.application).module.blendMode = BlendMode.ERASE; 204 205 } 205 206 } … … 216 217 { 217 218 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)); 220 221 } 221 222 … … 223 224 { 224 225 cancel(); 225 I Delegate(Application.application).module.blendMode = String(evt.currentTarget.value);226 IApplication(Application.application).module.blendMode = String(evt.currentTarget.value); 226 227 } 227 228 228 229 private function onChangeThicknessSlider(evt:SliderEvent):void 229 230 { 230 I Delegate(Application.application).module.thickness = evt.value;231 IApplication(Application.application).module.thickness = evt.value; 231 232 } 232 233 … … 261 262 break; 262 263 } 263 I Delegate(Application.application).module.color = color;264 IApplication(Application.application).module.color = color; 264 265 m_gridItemPalette.setStyle('backgroundColor', color); 265 266 } … … 267 268 private function onChangeAlphaSlider(evt:SliderEvent):void 268 269 { 269 I Delegate(Application.application).module.alpha = evt.value;270 IApplication(Application.application).module.alpha = evt.value; 270 271 } 271 272 ]]>

