Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_handlers.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 378 Lines • ▼ Show 20 Lines | typedef struct uiHandleButtonData { | ||||
| bool interactive; | bool interactive; | ||||
| /* overall state */ | /* overall state */ | ||||
| uiHandleButtonState state; | uiHandleButtonState state; | ||||
| int retval; | int retval; | ||||
| /* booleans (could be made into flags) */ | /* booleans (could be made into flags) */ | ||||
| bool cancel, escapecancel; | bool cancel, escapecancel; | ||||
| bool applied, applied_interactive; | bool applied, applied_interactive; | ||||
| /* Button is being applied through an extra icon. */ | |||||
| bool apply_through_extra_icon; | |||||
| bool changed_cursor; | bool changed_cursor; | ||||
| wmTimer *flashtimer; | wmTimer *flashtimer; | ||||
| /* edited value */ | /* edited value */ | ||||
| /* use 'ui_textedit_string_set' to assign new strings */ | /* use 'ui_textedit_string_set' to assign new strings */ | ||||
| char *str; | char *str; | ||||
| char *origstr; | char *origstr; | ||||
| double value, origvalue, startvalue; | double value, origvalue, startvalue; | ||||
| ▲ Show 20 Lines • Show All 764 Lines • ▼ Show 20 Lines | if (bt != but && bt->poin == but->poin && ELEM(bt->type, UI_BTYPE_ROW, UI_BTYPE_LISTROW)) { | ||||
| ui_but_update_edited(bt); | ui_but_update_edited(bt); | ||||
| } | } | ||||
| } | } | ||||
| data->retval = but->retval; | data->retval = but->retval; | ||||
| data->applied = true; | data->applied = true; | ||||
| } | } | ||||
| static void ui_apply_but_TREEROW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data) | |||||
| { | |||||
| if (data->apply_through_extra_icon) { | |||||
| /* Don't apply this, it would cause unintended tree-row toggling when clicking on extra icons. | |||||
| */ | |||||
| return; | |||||
| } | |||||
| ui_apply_but_ROW(C, block, but, data); | |||||
| } | |||||
| /** | /** | ||||
| * \note Ownership of \a properties is moved here. The #uiAfterFunc owns it now. | * \note Ownership of \a properties is moved here. The #uiAfterFunc owns it now. | ||||
| * | * | ||||
| * \param context_but: The button to use context from when calling or polling the operator. | * \param context_but: The button to use context from when calling or polling the operator. | ||||
| * | * | ||||
| * \returns true if the operator was executed, otherwise false. | * \returns true if the operator was executed, otherwise false. | ||||
| */ | */ | ||||
| static bool ui_list_invoke_item_operator(bContext *C, | static bool ui_list_invoke_item_operator(bContext *C, | ||||
| ▲ Show 20 Lines • Show All 1,127 Lines • ▼ Show 20 Lines | switch (but_type) { | ||||
| case UI_BTYPE_ICON_TOGGLE_N: | case UI_BTYPE_ICON_TOGGLE_N: | ||||
| case UI_BTYPE_CHECKBOX: | case UI_BTYPE_CHECKBOX: | ||||
| case UI_BTYPE_CHECKBOX_N: | case UI_BTYPE_CHECKBOX_N: | ||||
| ui_apply_but_TOG(C, but, data); | ui_apply_but_TOG(C, but, data); | ||||
| break; | break; | ||||
| case UI_BTYPE_ROW: | case UI_BTYPE_ROW: | ||||
| ui_apply_but_ROW(C, block, but, data); | ui_apply_but_ROW(C, block, but, data); | ||||
| break; | break; | ||||
| case UI_BTYPE_TREEROW: | |||||
| ui_apply_but_TREEROW(C, block, but, data); | |||||
| break; | |||||
| case UI_BTYPE_LISTROW: | case UI_BTYPE_LISTROW: | ||||
| ui_apply_but_LISTROW(C, block, but, data); | ui_apply_but_LISTROW(C, block, but, data); | ||||
| break; | break; | ||||
| case UI_BTYPE_DATASETROW: | case UI_BTYPE_DATASETROW: | ||||
| ui_apply_but_ROW(C, block, but, data); | ui_apply_but_ROW(C, block, but, data); | ||||
| break; | break; | ||||
| case UI_BTYPE_TAB: | case UI_BTYPE_TAB: | ||||
| ui_apply_but_TAB(C, but, data); | ui_apply_but_TAB(C, but, data); | ||||
| ▲ Show 20 Lines • Show All 1,871 Lines • ▼ Show 20 Lines | else { | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| } | } | ||||
| ED_region_tag_redraw(data->region); | ED_region_tag_redraw(data->region); | ||||
| } | } | ||||
| static void ui_but_extra_operator_icon_apply(bContext *C, uiBut *but, uiButExtraOpIcon *op_icon) | static void ui_but_extra_operator_icon_apply(bContext *C, uiBut *but, uiButExtraOpIcon *op_icon) | ||||
| { | { | ||||
| but->active->apply_through_extra_icon = true; | |||||
| if (but->active->interactive) { | if (but->active->interactive) { | ||||
| ui_apply_but(C, but->block, but, but->active, true); | ui_apply_but(C, but->block, but, but->active, true); | ||||
| } | } | ||||
| button_activate_state(C, but, BUTTON_STATE_EXIT); | button_activate_state(C, but, BUTTON_STATE_EXIT); | ||||
| WM_operator_name_call_ptr_with_depends_on_cursor(C, | WM_operator_name_call_ptr_with_depends_on_cursor(C, | ||||
| op_icon->optype_params->optype, | op_icon->optype_params->optype, | ||||
| op_icon->optype_params->opcontext, | op_icon->optype_params->opcontext, | ||||
| op_icon->optype_params->opptr, | op_icon->optype_params->opptr, | ||||
| ▲ Show 20 Lines • Show All 527 Lines • ▼ Show 20 Lines | if (ELEM(event->type, EVT_PADENTER, EVT_RETKEY)) { | ||||
| do_activate = true; | do_activate = true; | ||||
| } | } | ||||
| } | } | ||||
| else if (event->type == LEFTMOUSE) { | else if (event->type == LEFTMOUSE) { | ||||
| if (ui_block_is_menu(but->block)) { | if (ui_block_is_menu(but->block)) { | ||||
| /* Behave like other menu items. */ | /* Behave like other menu items. */ | ||||
| do_activate = (event->val == KM_RELEASE); | do_activate = (event->val == KM_RELEASE); | ||||
| } | } | ||||
| else { | else if (!ui_do_but_extra_operator_icon(C, but, data, event)) { | ||||
| /* Also use double-clicks to prevent fast clicks to leak to other handlers (T76481). */ | /* Also use double-clicks to prevent fast clicks to leak to other handlers (T76481). */ | ||||
| do_activate = ELEM(event->val, KM_PRESS, KM_DBL_CLICK); | do_activate = ELEM(event->val, KM_PRESS, KM_DBL_CLICK); | ||||
| } | } | ||||
| } | } | ||||
| if (do_activate) { | if (do_activate) { | ||||
| #if 0 /* UNUSED */ | #if 0 /* UNUSED */ | ||||
| data->togdual = event->ctrl; | data->togdual = event->ctrl; | ||||
| ▲ Show 20 Lines • Show All 3,212 Lines • ▼ Show 20 Lines | switch (but->type) { | ||||
| case UI_BTYPE_BUT_TOGGLE: | case UI_BTYPE_BUT_TOGGLE: | ||||
| case UI_BTYPE_TOGGLE: | case UI_BTYPE_TOGGLE: | ||||
| case UI_BTYPE_ICON_TOGGLE: | case UI_BTYPE_ICON_TOGGLE: | ||||
| case UI_BTYPE_ICON_TOGGLE_N: | case UI_BTYPE_ICON_TOGGLE_N: | ||||
| case UI_BTYPE_TOGGLE_N: | case UI_BTYPE_TOGGLE_N: | ||||
| case UI_BTYPE_CHECKBOX: | case UI_BTYPE_CHECKBOX: | ||||
| case UI_BTYPE_CHECKBOX_N: | case UI_BTYPE_CHECKBOX_N: | ||||
| case UI_BTYPE_ROW: | case UI_BTYPE_ROW: | ||||
| case UI_BTYPE_TREEROW: | |||||
| case UI_BTYPE_DATASETROW: | case UI_BTYPE_DATASETROW: | ||||
| retval = ui_do_but_TOG(C, but, data, event); | retval = ui_do_but_TOG(C, but, data, event); | ||||
| break; | break; | ||||
| case UI_BTYPE_SCROLL: | case UI_BTYPE_SCROLL: | ||||
| retval = ui_do_but_SCROLL(C, block, but, data, event); | retval = ui_do_but_SCROLL(C, block, but, data, event); | ||||
| break; | break; | ||||
| case UI_BTYPE_GRIP: | case UI_BTYPE_GRIP: | ||||
| retval = ui_do_but_GRIP(C, block, but, data, event); | retval = ui_do_but_GRIP(C, block, but, data, event); | ||||
| ▲ Show 20 Lines • Show All 3,754 Lines • Show Last 20 Lines | |||||