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;
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;
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 */
#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,
typedef struct _SclButtonContext {
sclboolean used;
sclbyte multikeyIdx;
- //sclboolean pressed;
+ sclboolean toggled;
SCLButtonState state;
} SclButtonContext;
/**
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;
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;
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();
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;
}
}
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;
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;
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);
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;
}
#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"
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;
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;
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;
}
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;
}
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) {
return DIRECTION;
} else if (str == pcRelative_Direction) {
return RELATIVE_DIRECTION;
+ } else if (str == pcToggle) {
+ return TOGGLE;
} else if (str == pcUiitem) {
return UIITEM;
} else {