Implemented toggle button type 13/22513/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 7 Mar 2014 08:33:43 +0000 (17:33 +0900)
committershoum.chen@samsung.com <shoum.chen@samsung.com>
Wed, 4 Jun 2014 22:01:25 +0000 (18:01 -0400)
Change-Id: I1884d6317cae1a6376502b5aa2043291ce88ed56

scl/include/sclconfig.h
scl/include/sclresourcecache.h
scl/sclcontroller.cpp
scl/sclresourcecache.cpp
scl/scluibuilder.cpp
xmlresource/autopopup_configure_parser.cpp
xmlresource/include/layout_parser_helper.h
xmlresource/label_properties_parser.cpp
xmlresource/layout_parser.cpp
xmlresource/layout_parser_helper.cpp

index 87d35ac..5268172 100644 (file)
@@ -62,6 +62,7 @@ typedef enum _SCLButtonType {
     BUTTON_TYPE_ROTATION,                      /**< Rotation key */
     BUTTON_TYPE_DIRECTION,                     /**< Direction decided by whole mouse movement from inital point */
     BUTTON_TYPE_RELATIVE_DIRECTION,    /**< Direction decided by recent mouse movement */
+    BUTTON_TYPE_TOGGLE,                                /** A button that has toggled state */
     BUTTON_TYPE_UIITEM,                                /** Not a button, just for displaying image */
     MAX_BUTTON_TYPE                                    /* maximum number of Key type */
 }SCLButtonType;
@@ -141,6 +142,8 @@ typedef enum _SCLKeyModifier {
     KEY_MODIFIER_DIRECTION_CURVE_RIGHT_UP,             /**< drag right up */
     KEY_MODIFIER_DIRECTION_CURVE_RIGHT_DOWN,   /**< drage right down */
 
+    KEY_MODIFIER_TOGGLED,                                              /**< toggled state */
+
     KEY_MODIFIER_MAX                   /* maximum number of Key type */
 }SCLKeyModifier;
 
@@ -219,6 +222,7 @@ typedef enum _SCLButtonState {
     BUTTON_STATE_NORMAL = 0,   /**< normal state */
     BUTTON_STATE_PRESSED,              /**< pressed state */
     BUTTON_STATE_DISABLED,             /**< disabled state */
+    BUTTON_STATE_TOGGLED,              /**< toggled state */
     //BUTTON_STATE_HIGHLIGHT,  /**< highlighed state */
     //BUTTON_STATE_LONGKEY,            /**< londkey state */
     SCL_BUTTON_STATE_MAX               /* maximum number of button state */
@@ -445,7 +449,7 @@ typedef enum _SCLParserType {
 #define SCL_HIGHLIGHT_UI_IMAGE "B09_icon_cue.png"
 
 #define SCL_ANIMATION_TIMER_INTERVAL (1000 / 30) // 30 frames per second
-#define SCL_ANIMATION_TIME 300 // Animation for 1 second
+#define SCL_ANIMATION_TIME 300 // Animation for 300 ms
 
 typedef enum _SCLDebugMode {
     DEBUGMODE_DISABLED,
index a6721d1..5a1ad6b 100644 (file)
@@ -30,7 +30,7 @@ namespace scl
 typedef struct _SclButtonContext {
     sclboolean used;
     sclbyte multikeyIdx;
-    //sclboolean pressed;
+    sclboolean toggled;
     SCLButtonState state;
 } SclButtonContext;
 /**
index e8e9c22..edf6053 100644 (file)
@@ -1818,6 +1818,23 @@ CSCLController::process_button_release_event(sclwindow window, sclint x, sclint
                     case BUTTON_TYPE_DRAG : {
                     }
                     break;
+                    case BUTTON_TYPE_TOGGLE : {
+                        SclButtonContext *pressed_context = cache->get_cur_button_context(pressed_window, pressed_key);
+                        if (pressed_context) {
+                            if (!(targetCoordinate->use_repeat_key) && pressed_context->state == BUTTON_STATE_PRESSED) {
+                                key_event_desc.key_value = targetCoordinate->key_value[shiftidx][0];
+                                key_event_desc.key_event = targetCoordinate->key_event[shiftidx][0];
+                                if (pressed_context->toggled) {
+                                    key_event_desc.key_modifier = KEY_MODIFIER_NONE;
+                                } else {
+                                    key_event_desc.key_modifier = KEY_MODIFIER_TOGGLED;
+                                }
+                                if (SCL_EVENT_PASS_ON == handler->on_event_key_clicked(key_event_desc)) {
+                                    pressed_context->toggled = !(pressed_context->toggled);
+                                }
+                            }
+                        }
+                    }
                     case BUTTON_TYPE_UIITEM: break;
                     case MAX_BUTTON_TYPE: break;
                     default: break;
@@ -3899,25 +3916,27 @@ CSCLController::check_event_transition_enabled(const SclLayoutKeyCoordinate *btn
     sclbyte typeTo = MAX_BUTTON_TYPE;
 
     const sclboolean TRANSITION_TABLE[MAX_BUTTON_TYPE][MAX_BUTTON_TYPE] = {
-        //     NORMAL  GRAB    SELFISH DRAG    MULTITAP        ROTATION        DIRECTION       R_DIRECTION     UIITEM
+        //     NORMAL  GRAB    SELFISH DRAG    MULTITAP        ROTATION        DIRECTION       R_DIRECTION     TOGGLE  UIITEM
         //     From : NORMAL
-        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      0},
+        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      TRUE,           0},
         //     From : GRAB
-        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0},
+        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0,                      0},
         //     From : SELFISH
-        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0},
+        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0,                      0},
         //     From : DRAG
-        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      0},
+        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      TRUE,           0},
         //     From : MULTITAP
-        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      0},
+        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      TRUE,           0},
         //     From : ROTATION
-        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      0},
+        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      TRUE,           0},
         //     From : DIRECTION
-        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0},
+        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0,                      0},
         //     From : R_DIRECTION
-        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0},
+        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0,                      0},
         //     From : UIITEM
-        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0},
+        {      0,              0,      0,              0,              0,                      0,                      0,                      0,                      0,                      0},
+        //     From : TOGGLE
+        {      TRUE,   0,      0,              TRUE,   TRUE,           TRUE,           0,                      0,                      TRUE,           0},
     };
 
     if (btnFrom) typeFrom = btnFrom->button_type;
index 0f47411..20f2397 100644 (file)
@@ -988,6 +988,7 @@ CSCLResourceCache::recompute_layout(sclwindow window)
                             if (!found) {
                                 (*pCurButtonContext)[loop].state = BUTTON_STATE_NORMAL;
                             }
+                            (*pCurButtonContext)[loop].toggled = FALSE;
 
                             /* Apply the custom scale rate value */
                             (*pCurLayoutKeyCoordinate)[loop].x *= utils->get_custom_scale_rate_x();
index baf11c7..c36fead 100644 (file)
@@ -332,7 +332,11 @@ CSCLUIBuilder::draw_button_all(const sclwindow window, const scldrawctx draw_ctx
                 if (coordinate->valid && subLayoutMatch) {
                     SclRectangle itemrect = {coordinate->x, coordinate->y, coordinate->width, coordinate->height};
                     if (drawall || utils->is_rect_overlap(itemrect, updatearea)) {
-                        if (!draw_button(window, draw_ctx, idx, btncontext->state)) {
+                        SCLButtonState state = btncontext->state;
+                        if (btncontext->toggled) {
+                            state = BUTTON_STATE_TOGGLED;
+                        }
+                        if (!draw_button(window, draw_ctx, idx, state)) {
                             break;
                         }
                     }
index 4305c32..87dd5bf 100644 (file)
@@ -275,9 +275,10 @@ class AutoPopupConfigureParserImpl {
                 button_state = BUTTON_STATE_PRESSED;
             } else if (equal_prop(cur_node, "button_state", "normal")) {
                 button_state = BUTTON_STATE_NORMAL;
-            }
-            else if (equal_prop(cur_node, "button_state", "disabled")) {
+            } else if (equal_prop(cur_node, "button_state", "disabled")) {
                 button_state = BUTTON_STATE_DISABLED;
+            } else if (equal_prop(cur_node, "button_state", "toggled")) {
+                button_state = BUTTON_STATE_TOGGLED;
             }
             return button_state;
 
index 77274ed..8d7e88b 100644 (file)
@@ -57,8 +57,9 @@ class ButtonTypeHelper{
         static const int ROTATION = 5;
         static const int DIRECTION = 6;
         static const int RELATIVE_DIRECTION = 7;
-        static const int UIITEM = 8;
-        static const int MAX = 9;
+        static const int TOGGLE = 8;
+        static const int UIITEM = 9;
+        static const int MAX = 10;
         static const int DEFAULT = 0;
 
         static const std::string pcNormal;
@@ -69,6 +70,7 @@ class ButtonTypeHelper{
         static const std::string pcRotation;
         static const std::string pcDirection;
         static const std::string pcRelative_Direction;
+        static const std::string pcToggle;
         static const std::string pcUiitem;
 
         static const std::string toString(const int val);
index 361766e..0c934d4 100644 (file)
@@ -369,9 +369,10 @@ class LabelPropertiesParserImpl {
             button_state = BUTTON_STATE_PRESSED;
         } else if (equal_prop(cur_node, "button", "normal")) {
             button_state = BUTTON_STATE_NORMAL;
-        }
-        else if (equal_prop(cur_node, "button", "disabled")) {
+        } else if (equal_prop(cur_node, "button", "disabled")) {
             button_state = BUTTON_STATE_DISABLED;
+        } else if (equal_prop(cur_node, "button", "toggled")) {
+            button_state = BUTTON_STATE_TOGGLED;
         }
         return button_state;
     }
index 3eda541..6152fe7 100644 (file)
@@ -81,6 +81,7 @@ using namespace std;
 #define LAYOUT_BACKGROUND_NORMAL_TAG "button_normal"
 #define LAYOUT_BACKGROUND_PRESSED_TAG "button_pressed"
 #define LAYOUT_BACKGROUND_DISABLED_TAG "button_disabled"
+#define LAYOUT_BACKGROUND_TOGGLED_TAG "button_toggled"
 
 #define LAYOUT_ROW_TAG "row"
 #define LAYOUT_ROW_SUBLAYOUT_ID_ATTRIBUTE "sub_layout"
@@ -426,20 +427,22 @@ LayoutParserImpl::parsing_background(
 
     xmlNodePtr child_node = cur_node->xmlChildrenNode;
     while ( child_node != NULL) {
-        if ( 0 == xmlStrcmp(child_node->name, (const xmlChar* )"button_normal") ) {
+        if ( 0 == xmlStrcmp(child_node->name, (const xmlChar* )LAYOUT_BACKGROUND_NORMAL_TAG) ) {
             xmlChar *key = xmlNodeGetContent(child_node);
             cur_layout->image_path[BUTTON_STATE_NORMAL] = (char *)key;
             add_layout_string(key);
-        }
-        else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar* )"button_pressed") ) {
+        } else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar* )LAYOUT_BACKGROUND_PRESSED_TAG) ) {
             xmlChar *key = xmlNodeGetContent(child_node);
             cur_layout->image_path[BUTTON_STATE_PRESSED] = (char *)key;
             add_layout_string(key);
-        }
-        else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar* )"button_disabled") ) {
+        } else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar* )LAYOUT_BACKGROUND_DISABLED_TAG ) ) {
             xmlChar *key = xmlNodeGetContent(child_node);
             cur_layout->image_path[BUTTON_STATE_DISABLED] = (char *)key;
             add_layout_string(key);
+        } else if ( 0 == xmlStrcmp(child_node->name, (const xmlChar* )LAYOUT_BACKGROUND_TOGGLED_TAG ) ) {
+            xmlChar *key = xmlNodeGetContent(child_node);
+            cur_layout->image_path[BUTTON_STATE_TOGGLED] = (char *)key;
+            add_layout_string(key);
         }
 
         child_node = child_node->next;
@@ -499,6 +502,7 @@ LayoutParserImpl::set_default_layout_value(const PSclLayout cur_layout) {
     cur_layout->image_path[BUTTON_STATE_NORMAL]      = NULL;
     cur_layout->image_path[BUTTON_STATE_PRESSED]     = NULL;
     cur_layout->image_path[BUTTON_STATE_DISABLED]    = NULL;
+    cur_layout->image_path[BUTTON_STATE_TOGGLED]     = NULL;
 
     cur_layout->use_sw_button = false;
     cur_layout->use_magnifier_window = false;
@@ -856,7 +860,6 @@ LayoutParserImpl::get_shift_state_prop(const xmlNodePtr cur_node) {
         shift_state = SCL_SHIFT_STATE_ON;
     } else if (equal_prop(cur_node, "shift", "off")) {
         shift_state = SCL_SHIFT_STATE_OFF;
-
     } else if (equal_prop(cur_node, "shift", "loc")) {
         shift_state = SCL_SHIFT_STATE_LOCK;
     }
@@ -871,9 +874,10 @@ LayoutParserImpl::get_button_state_prop(const xmlNodePtr cur_node) {
         button_state = BUTTON_STATE_PRESSED;
     } else if (equal_prop(cur_node, "button", "normal")) {
         button_state = BUTTON_STATE_NORMAL;
-    }
-    else if (equal_prop(cur_node, "button", "disabled")) {
+    } else if (equal_prop(cur_node, "button", "disabled")) {
         button_state = BUTTON_STATE_DISABLED;
+    } else if (equal_prop(cur_node, "button", "toggled")) {
+        button_state = BUTTON_STATE_TOGGLED;
     }
     return button_state;
 }
index 6b730d6..40ec50b 100644 (file)
@@ -82,6 +82,7 @@ const string ButtonTypeHelper::pcMultitap = "multitap";
 const string ButtonTypeHelper::pcRotation = "rotation";
 const string ButtonTypeHelper::pcDirection = "direction";
 const string ButtonTypeHelper::pcRelative_Direction = "relative_direction";
+const string ButtonTypeHelper::pcToggle = "toggle";
 const string ButtonTypeHelper::pcUiitem = "uiitem";
 
 const string ButtonTypeHelper::toString(const int val) {
@@ -126,6 +127,8 @@ const int ButtonTypeHelper::Int(const string str) {
         return DIRECTION;
     } else if (str ==  pcRelative_Direction) {
         return RELATIVE_DIRECTION;
+    } else if (str ==  pcToggle) {
+        return TOGGLE;
     } else if (str ==  pcUiitem) {
         return UIITEM;
     } else {