2
0
Эх сурвалжийг харах

Merge pull request #1475 from sgrenier/next

UI Focus Changes
Steve Grenier 11 жил өмнө
parent
commit
93eb8c3e20

+ 22 - 14
gameplay/src/Container.h

@@ -37,6 +37,19 @@ public:
         SCROLL_BOTH = SCROLL_HORIZONTAL | SCROLL_VERTICAL
         SCROLL_BOTH = SCROLL_HORIZONTAL | SCROLL_VERTICAL
     };
     };
 
 
+    /**
+     * Defines supported focus chagne directions.
+     */
+    enum Direction
+    {
+        UP = 0x01,
+        DOWN = 0x02,
+        LEFT = 0x04,
+        RIGHT = 0x08,
+        NEXT = 0x10,
+        PREVIOUS = 0x20
+    };
+
     /**
     /**
      * Creates a new container.
      * Creates a new container.
      *
      *
@@ -245,6 +258,15 @@ public:
      */
      */
     bool setFocus();
     bool setFocus();
 
 
+    /**
+     * Attempts to switch focus to a child of this container in the specified direction.
+     *
+     * @param direction The direction for focus change.
+     *
+     * @return True on success, false if there are no controls to focus on.
+     */
+    bool moveFocus(Direction direction);
+
     /**
     /**
      * Returns the currently active control for this container.
      * Returns the currently active control for this container.
      *
      *
@@ -546,22 +568,8 @@ private:
      */
      */
     Container(const Container& copy);
     Container(const Container& copy);
 
 
-    enum Direction
-    {
-        UP = 0x01,
-        DOWN = 0x02,
-        LEFT = 0x04,
-        RIGHT = 0x08,
-        NEXT = 0x10,
-        PREVIOUS = 0x20
-    };
-
     static const int MAX_CONTACT_INDICES = 10;
     static const int MAX_CONTACT_INDICES = 10;
 
 
-    // Returns true on success; false if there are no controls to focus on,
-    // in which case scrolling can be initiated.
-    bool moveFocus(Direction direction);
-
 	bool moveFocusNextPrevious(Direction direction);
 	bool moveFocusNextPrevious(Direction direction);
 	bool moveFocusDirectional(Direction direction);
 	bool moveFocusDirectional(Direction direction);
 
 

+ 3 - 3
gameplay/src/Control.cpp

@@ -909,10 +909,10 @@ Theme* Control::getTheme() const
 
 
 Control::State Control::getState() const
 Control::State Control::getState() const
 {
 {
-    if (_state == HOVER)
+    if (Form::getFocusControl() == this)
     {
     {
-        // Focus state takes priority over hover
-        return (Form::getFocusControl() == this ? FOCUS : HOVER);
+        // Active is the only state that overrides focus state
+        return _state == ACTIVE ? ACTIVE : FOCUS;
     }
     }
 
 
     return _state;
     return _state;