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 1,234 Lines • ▼ Show 20 Lines | static bool ui_drag_toggle_but_is_supported(const uiBut *but) | ||||
| } | } | ||||
| else { | else { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| /* Button pushed state to compare if other buttons match. Can be more | /* Button pushed state to compare if other buttons match. Can be more | ||||
| * then just true or false for toggle buttons with more than 2 states. */ | * then just true or false for toggle buttons with more than 2 states. */ | ||||
| static int ui_drag_toggle_but_pushed_state(uiBut *but) | static int ui_drag_toggle_but_pushed_state(bContext *C, uiBut *but) | ||||
| { | { | ||||
| if (but->rnapoin.data == NULL && but->poin == NULL && but->icon) { | if (but->rnapoin.data == NULL && but->poin == NULL && but->icon) { | ||||
| if (but->pushed_state_func) { | |||||
| return but->pushed_state_func(C, but->pushed_state_arg); | |||||
| } | |||||
| else { | |||||
| /* Assume icon identifies a unique state, for buttons that | /* Assume icon identifies a unique state, for buttons that | ||||
| * work though functions callbacks and don't have an boolean | * work though functions callbacks and don't have an boolean | ||||
| * value that indicates the state. */ | * value that indicates the state. */ | ||||
| return but->icon + but->iconadd; | return but->icon + but->iconadd; | ||||
| } | } | ||||
| } | |||||
| else if (ui_but_is_bool(but)) { | else if (ui_but_is_bool(but)) { | ||||
| return ui_but_is_pushed(but); | return ui_but_is_pushed(but); | ||||
| } | } | ||||
| else { | else { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| Show All 31 Lines | for (but = block->buttons.first; but; but = but->next) { | ||||
| /* Note: ctrl is always true here because (at least for now) we always want to consider text control | /* Note: ctrl is always true here because (at least for now) we always want to consider text control | ||||
| * in this case, even when not embossed. */ | * in this case, even when not embossed. */ | ||||
| if (ui_but_is_interactive(but, true)) { | if (ui_but_is_interactive(but, true)) { | ||||
| if (BLI_rctf_isect_segment(&but->rect, xy_a_block, xy_b_block)) { | if (BLI_rctf_isect_segment(&but->rect, xy_a_block, xy_b_block)) { | ||||
| /* execute the button */ | /* execute the button */ | ||||
| if (ui_drag_toggle_but_is_supported(but)) { | if (ui_drag_toggle_but_is_supported(but)) { | ||||
| /* is it pressed? */ | /* is it pressed? */ | ||||
| int pushed_state_but = ui_drag_toggle_but_pushed_state(but); | int pushed_state_but = ui_drag_toggle_but_pushed_state(C, but); | ||||
| if (pushed_state_but != pushed_state) { | if (pushed_state_but != pushed_state) { | ||||
| UI_but_execute(C, but); | UI_but_execute(C, but); | ||||
| if (do_check) { | if (do_check) { | ||||
| ui_but_update_edited(but); | ui_but_update_edited(but); | ||||
| } | } | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 442 Lines • ▼ Show 20 Lines | #ifdef USE_DRAG_TOGGLE | ||||
| if (ui_drag_toggle_but_is_supported(but)) { | if (ui_drag_toggle_but_is_supported(but)) { | ||||
| uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__); | uiDragToggleHandle *drag_info = MEM_callocN(sizeof(*drag_info), __func__); | ||||
| ARegion *ar_prev; | ARegion *ar_prev; | ||||
| /* call here because regular mouse-up event wont run, | /* call here because regular mouse-up event wont run, | ||||
| * typically 'button_activate_exit()' handles this */ | * typically 'button_activate_exit()' handles this */ | ||||
| ui_apply_but_autokey(C, but); | ui_apply_but_autokey(C, but); | ||||
| drag_info->pushed_state = ui_drag_toggle_but_pushed_state(but); | drag_info->pushed_state = ui_drag_toggle_but_pushed_state(C, but); | ||||
| drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect); | drag_info->but_cent_start[0] = BLI_rctf_cent_x(&but->rect); | ||||
| drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect); | drag_info->but_cent_start[1] = BLI_rctf_cent_y(&but->rect); | ||||
| copy_v2_v2_int(drag_info->xy_init, &event->x); | copy_v2_v2_int(drag_info->xy_init, &event->x); | ||||
| copy_v2_v2_int(drag_info->xy_last, &event->x); | copy_v2_v2_int(drag_info->xy_last, &event->x); | ||||
| /* needed for toggle drag on popups */ | /* needed for toggle drag on popups */ | ||||
| ar_prev = CTX_wm_region(C); | ar_prev = CTX_wm_region(C); | ||||
| CTX_wm_region_set(C, data->region); | CTX_wm_region_set(C, data->region); | ||||
| ▲ Show 20 Lines • Show All 8,354 Lines • Show Last 20 Lines | |||||