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 112 Lines • ▼ Show 20 Lines | |||||
| * This is needed for values such as location & dimensions which don't have a meaningful min/max, | * This is needed for values such as location & dimensions which don't have a meaningful min/max, | ||||
| * Instead of mapping cursor motion to the min/max, map the motion to the click-step. | * Instead of mapping cursor motion to the min/max, map the motion to the click-step. | ||||
| * | * | ||||
| * This value is multiplied by the click step to calculate a range to clamp the soft-range by. | * This value is multiplied by the click step to calculate a range to clamp the soft-range by. | ||||
| * See: T68130 | * See: T68130 | ||||
| */ | */ | ||||
| #define UI_DRAG_MAP_SOFT_RANGE_PIXEL_MAX 1000 | #define UI_DRAG_MAP_SOFT_RANGE_PIXEL_MAX 1000 | ||||
| static CLG_LogRef LOG = {"interface.handlers"}; | |||||
| /* proto */ | /* proto */ | ||||
| static int ui_do_but_EXIT(bContext *C, | static int ui_do_but_EXIT(bContext *C, | ||||
| uiBut *but, | uiBut *but, | ||||
| struct uiHandleButtonData *data, | struct uiHandleButtonData *data, | ||||
| const wmEvent *event); | const wmEvent *event); | ||||
| static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b); | static bool ui_but_find_select_in_enum__cmp(const uiBut *but_a, const uiBut *but_b); | ||||
| static void ui_textedit_string_set(uiBut *but, struct uiHandleButtonData *data, const char *str); | static void ui_textedit_string_set(uiBut *but, struct uiHandleButtonData *data, const char *str); | ||||
| static void button_tooltip_timer_reset(bContext *C, uiBut *but); | static void button_tooltip_timer_reset(bContext *C, uiBut *but); | ||||
| ▲ Show 20 Lines • Show All 1,234 Lines • ▼ Show 20 Lines | # endif | ||||
| /* clamp based on soft limits, see: T40154 */ | /* clamp based on soft limits, see: T40154 */ | ||||
| CLAMP(but->active->value, (double)but->softmin, (double)but->softmax); | CLAMP(but->active->value, (double)but->softmin, (double)but->softmax); | ||||
| } | } | ||||
| ui_but_execute_end(C, region, but, active_back); | ui_but_execute_end(C, region, but, active_back); | ||||
| } | } | ||||
| else { | else { | ||||
| /* highly unlikely */ | /* highly unlikely */ | ||||
| printf("%s: cant find button\n", __func__); | CLOG_ERROR(&LOG, | ||||
| "can not find button (%p), type: %u, str: %s, tip: %s", | |||||
| but, | |||||
| but->type, | |||||
| but->str, | |||||
| but->tip); | |||||
| } | } | ||||
| /* end */ | /* end */ | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif /* USE_DRAG_MULTINUM */ | #endif /* USE_DRAG_MULTINUM */ | ||||
| ▲ Show 20 Lines • Show All 1,674 Lines • ▼ Show 20 Lines | static bool ui_textedit_insert_buf(uiBut *but, | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| static bool ui_textedit_insert_ascii(uiBut *but, uiHandleButtonData *data, char ascii) | static bool ui_textedit_insert_ascii(uiBut *but, uiHandleButtonData *data, char ascii) | ||||
| { | { | ||||
| const char buf[2] = {ascii, '\0'}; | const char buf[2] = {ascii, '\0'}; | ||||
| if (UI_but_is_utf8(but) && (BLI_str_utf8_size(buf) == -1)) { | if (UI_but_is_utf8(but) && (BLI_str_utf8_size(buf) == -1)) { | ||||
| printf( | CLOG_ERROR(&LOG, "entering invalid ascii char into an ascii key (%d)", (int)(uchar)ascii); | ||||
| "%s: entering invalid ascii char into an ascii key (%d)\n", __func__, (int)(uchar)ascii); | |||||
| return false; | return false; | ||||
| } | } | ||||
| /* in some cases we want to allow invalid utf8 chars */ | /* in some cases we want to allow invalid utf8 chars */ | ||||
| return ui_textedit_insert_buf(but, data, buf, 1); | return ui_textedit_insert_buf(but, data, buf, 1); | ||||
| } | } | ||||
| static void ui_textedit_move(uiBut *but, | static void ui_textedit_move(uiBut *but, | ||||
| ▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) | ||||
| wmWindow *win = data->window; | wmWindow *win = data->window; | ||||
| if (but) { | if (but) { | ||||
| if (UI_but_is_utf8(but)) { | if (UI_but_is_utf8(but)) { | ||||
| int strip = BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr)); | int strip = BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr)); | ||||
| /* not a file?, strip non utf-8 chars */ | /* not a file?, strip non utf-8 chars */ | ||||
| if (strip) { | if (strip) { | ||||
| /* wont happen often so isn't that annoying to keep it here for a while */ | /* wont happen often so isn't that annoying to keep it here for a while */ | ||||
| printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip); | CLOG_ERROR(&LOG, "invalid utf8 - stripped chars %d", strip); | ||||
| } | } | ||||
| } | } | ||||
| if (data->searchbox) { | if (data->searchbox) { | ||||
| if (data->cancel == false) { | if (data->cancel == false) { | ||||
| if ((ui_searchbox_apply(but, data->searchbox) == false) && | if ((ui_searchbox_apply(but, data->searchbox) == false) && | ||||
| (ui_searchbox_find_index(data->searchbox, but->editstr) == -1)) { | (ui_searchbox_find_index(data->searchbox, but->editstr) == -1)) { | ||||
| data->cancel = true; | data->cancel = true; | ||||
| ▲ Show 20 Lines • Show All 5,248 Lines • ▼ Show 20 Lines | else if (ELEM(but->type, UI_BTYPE_BLOCK, UI_BTYPE_PULLDOWN)) { | ||||
| /* open sub-menus (like right arrow key) */ | /* open sub-menus (like right arrow key) */ | ||||
| ui_handle_button_activate(C, region, but, BUTTON_ACTIVATE_OPEN); | ui_handle_button_activate(C, region, but, BUTTON_ACTIVATE_OPEN); | ||||
| } | } | ||||
| else if (but->type == UI_BTYPE_MENU) { | else if (but->type == UI_BTYPE_MENU) { | ||||
| /* activate menu items */ | /* activate menu items */ | ||||
| ui_handle_button_activate(C, region, but, BUTTON_ACTIVATE); | ui_handle_button_activate(C, region, but, BUTTON_ACTIVATE); | ||||
| } | } | ||||
| else { | else { | ||||
| #ifdef DEBUG | CLOG_ERROR(&LOG, "unhandled type: %u", but->type); | ||||
| printf("%s: error, unhandled type: %u\n", __func__, but->type); | |||||
| #endif | |||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 2,464 Lines • Show Last 20 Lines | |||||