[Title] draw hover and pressed button image in asyncexec
authorgiwoong.kim <giwoong.kim@samsung.com>
Wed, 4 Jul 2012 11:11:23 +0000 (20:11 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Wed, 4 Jul 2012 11:11:23 +0000 (20:11 +0900)
[Type] bugfix
[Module] Emulator / skin
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause] HW key tooltip
[Solution]
[TestCase]

tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSkin.java

index 673dd0faf9ca66611b1db417fc6020afead495f0..82bc763df9a7c988be8057fef7cd7625485abe65 100644 (file)
@@ -142,6 +142,7 @@ public class EmulatorSkin {
        private int currentLcdWidth;
        private int currentLcdHeight;
        private SkinRegion currentHoverRegion;
+       private SkinRegion currentPressedRegion;
 
        private int pressedMouseX;
        private int pressedMouseY;
@@ -521,7 +522,6 @@ public class EmulatorSkin {
                shell.addMouseTrackListener( shellMouseTrackListener );
 
                shellMouseMoveListener = new MouseMoveListener() {
-
                        @Override
                        public void mouseMove( MouseEvent e ) {
                                if ( EmulatorSkin.this.isMousePressed ) {
@@ -539,7 +539,6 @@ public class EmulatorSkin {
 
                                        }
                                } else {
-
                                        SkinRegion region = SkinUtil.getHardKeyArea( e.x, e.y, currentRotationId, currentScale );
 
                                        if ( null == region ) {
@@ -561,23 +560,30 @@ public class EmulatorSkin {
                                                }
 
                                                isHoverState = true;
-                                               GC gc = new GC( shell );
-                                               gc.setLineWidth( 1 );
-                                               gc.setForeground( hoverColor );
-                                               gc.drawRectangle( region.x, region.y, region.width, region.height );
                                                currentHoverRegion = region;
-                                               gc.dispose();
-                                       }
 
+                                               /* draw hover */
+                                               shell.getDisplay().asyncExec(new Runnable() {
+                                                       public void run() {
+                                                               if (currentHoverRegion.width != 0 && currentHoverRegion.height != 0) {
+                                                                       GC gc = new GC(shell);
+                                                                       gc.setLineWidth(1);
+                                                                       gc.setForeground(hoverColor);
+                                                                       gc.drawRectangle(currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width, currentHoverRegion.height);
+
+                                                                       gc.dispose();
+                                                               }
+                                                       }
+                                               });
+                                       }
                                }
 
-                       }
+                       } //end of mouseMove
                };
 
                shell.addMouseMoveListener( shellMouseMoveListener );
 
                shellMouseListener = new MouseListener() {
-
                        @Override
                        public void mouseUp( MouseEvent e ) {
                                if ( 1 == e.button ) { // left button
@@ -589,9 +595,8 @@ public class EmulatorSkin {
                                        int keyCode = SkinUtil.getHardKeyCode( e.x, e.y, currentRotationId, currentScale );
 
                                        if ( SkinUtil.UNKNOWN_KEYCODE != keyCode ) {
-                                               
                                                // null check : prevent from mouse up without a hover (ex. doing always on top in hardkey area)
-                                               if( null != currentHoverRegion ) {
+                                               if ( null != currentHoverRegion ) {
                                                        if ( currentHoverRegion.width == 0 && currentHoverRegion.height == 0 ) {
                                                                shell.redraw();
                                                        } else {
@@ -599,7 +604,7 @@ public class EmulatorSkin {
                                                                                currentHoverRegion.height + 1, false );
                                                        }
                                                }
-                                               
+
                                                SkinUtil.trimShell( shell, currentImage );
 
                                                KeyEventData keyEventData = new KeyEventData( KeyEventType.RELEASED.value(), keyCode, 0 );
@@ -621,17 +626,39 @@ public class EmulatorSkin {
                                        int keyCode = SkinUtil.getHardKeyCode( e.x, e.y, currentRotationId, currentScale );
 
                                        if ( SkinUtil.UNKNOWN_KEYCODE != keyCode ) {
-                                               // draw the button region as the cropped keyPressed image area
-                                               SkinRegion region = SkinUtil.getHardKeyArea( e.x, e.y, currentRotationId, currentScale );
-
-                                               if ( null != currentKeyPressedImage ) {
-                                                       GC gc = new GC( shell );
-                                                       gc.drawImage( currentKeyPressedImage, region.x + 1, region.y + 1, region.width - 1,
-                                                                       region.height - 1, // src
-                                                                       region.x + 1, region.y + 1, region.width - 1, region.height - 1 ); // dst
-                                                       gc.dispose();
-
-                                                       SkinUtil.trimShell( shell, currentKeyPressedImage, region.x, region.y, region.width, region.height );
+                                               shell.setToolTipText(null);
+
+                                               /* draw the button region as the cropped keyPressed image area */
+                                               currentPressedRegion = SkinUtil.getHardKeyArea( e.x, e.y, currentRotationId, currentScale );
+                                               if (currentPressedRegion != null && currentPressedRegion.width != 0 && currentPressedRegion.height != 0) {
+                                                       shell.getDisplay().asyncExec(new Runnable() {
+                                                               public void run() {
+                                                                       if ( null != currentKeyPressedImage ) {
+                                                                               GC gc = new GC( shell );
+
+                                                                               /* button */
+                                                                               gc.drawImage(currentKeyPressedImage,
+                                                                                               currentPressedRegion.x + 1, currentPressedRegion.y + 1,
+                                                                                               currentPressedRegion.width - 1, currentPressedRegion.height - 1, //src
+                                                                                               currentPressedRegion.x + 1, currentPressedRegion.y + 1,
+                                                                                               currentPressedRegion.width - 1, currentPressedRegion.height - 1); //dst
+
+                                                                               /* hover */
+                                                                               if (currentHoverRegion.width != 0 && currentHoverRegion.height != 0) {
+                                                                                       gc.setLineWidth(1);
+                                                                                       gc.setForeground(hoverColor);
+                                                                                       gc.drawRectangle(currentHoverRegion.x, currentHoverRegion.y, currentHoverRegion.width, currentHoverRegion.height);
+                                                                               }
+
+                                                                               gc.dispose();
+
+                                                                               SkinUtil.trimShell(shell, currentKeyPressedImage,
+                                                                                               currentPressedRegion.x, currentPressedRegion.y, currentPressedRegion.width, currentPressedRegion.height);
+
+                                                                               currentPressedRegion = null;
+                                                                       }
+                                                               }
+                                                       });
                                                }
 
                                                KeyEventData keyEventData = new KeyEventData( KeyEventType.PRESSED.value(), keyCode, 0 );
@@ -1472,9 +1499,9 @@ public class EmulatorSkin {
                                //internal/Library.java::arch()
                                String osArch = System.getProperty("os.arch"); //$NON-NLS-1$
                                logger.info(osArch);
-                               if (osArch.equals ("amd64") || osArch.equals ("IA64N") || osArch.equals("IA64W")) { //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
+                               if (osArch.equals("amd64") || osArch.equals("IA64N") || osArch.equals("IA64W")) { //$NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
                                        logger.info("64bit architecture");
-                                       setTopMost64(isOnTop);
+                                       setTopMost64(isOnTop); //64bit
                                } else {
                                        logger.info("32bit architecture");
                                        setTopMost32(isOnTop);