Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_panel.c
| Context not available. | |||||
| /* also it supposes a block has panel, and isn't a menu */ | /* also it supposes a block has panel, and isn't a menu */ | ||||
| static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift) | static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | |||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| Panel *pa; | Panel *pa; | ||||
| const bool click = ELEM(event, LEFTMOUSE, RETKEY, AKEY); | |||||
| #ifdef USE_PIN_HIDDEN | #ifdef USE_PIN_HIDDEN | ||||
| const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->flag & PNL_PIN); | const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->flag & PNL_PIN); | ||||
| #else | #else | ||||
| Context not available. | |||||
| rect_drag = block->rect; | rect_drag = block->rect; | ||||
| rect_drag.xmin = block->rect.xmax - (PNL_ICON * 1.5f); | rect_drag.xmin = block->rect.xmax - (PNL_ICON * 1.5f); | ||||
| rect_pin = rect_drag; | rect_pin = rect_drag; | ||||
| if (show_pin) { | if (show_pin && click) { | ||||
| BLI_rctf_translate(&rect_pin, -PNL_ICON, 0.0f); | BLI_rctf_translate(&rect_pin, -PNL_ICON, 0.0f); | ||||
| } | } | ||||
| rect_leftmost = rect_pin.xmin; | rect_leftmost = rect_pin.xmin; | ||||
| Context not available. | |||||
| /* XXX weak code, currently it assumes layout style for location of widgets */ | /* XXX weak code, currently it assumes layout style for location of widgets */ | ||||
| /* check open/collapsed button */ | /* check open/collapsed button */ | ||||
| if (event == RETKEY) | if (ELEM(event, RETKEY, LEFTMOUSE) && shift) { | ||||
| button = 1; | |||||
| else if (event == AKEY) | |||||
| button = 1; | |||||
| else if (ELEM(event, 0, RETKEY, LEFTMOUSE) && shift) { | |||||
| block->panel->flag ^= PNL_PIN; | block->panel->flag ^= PNL_PIN; | ||||
| button = 2; | button = 2; | ||||
| } | } | ||||
| Context not available. | |||||
| button = 1; | button = 1; | ||||
| } | } | ||||
| if (button) { | if (button && click) { | ||||
| if (button == 2) { /* close */ | if (button == 2) { /* close */ | ||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| } | } | ||||
| Context not available. | |||||
| else | else | ||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| } | } | ||||
| else if (BLI_rctf_isect_x(&rect_drag, mx)) { | if (BLI_rctf_isect_x(&rect_drag, mx)) { | ||||
| panel_activate_state(C, block->panel, PANEL_STATE_DRAG); | WM_cursor_modal_set(win, BC_HANDCURSOR); | ||||
| if (click) | |||||
| panel_activate_state(C, block->panel, PANEL_STATE_DRAG); | |||||
| } | |||||
| else if (!click) { | |||||
| WM_cursor_modal_restore(win); | |||||
| } | } | ||||
| else if (show_pin && BLI_rctf_isect_x(&rect_pin, mx)) { | else if (show_pin && BLI_rctf_isect_x(&rect_pin, mx) && !shift) { | ||||
| block->panel->flag ^= PNL_PIN; | block->panel->flag ^= PNL_PIN; | ||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| } | } | ||||
| Context not available. | |||||
| int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar) | int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar) | ||||
| { | { | ||||
| uiBlock *block; | wmWindow *win = CTX_wm_window(C); | ||||
| uiBlock *block, *block_act; | |||||
| Panel *pa; | Panel *pa; | ||||
| int retval, mx, my; | int retval, mx, my; | ||||
| bool has_category_tabs = UI_panel_category_is_visible(ar); | bool has_category_tabs = UI_panel_category_is_visible(ar); | ||||
| bool inside_header = false; | |||||
| retval = WM_UI_HANDLER_CONTINUE; | retval = WM_UI_HANDLER_CONTINUE; | ||||
| Context not available. | |||||
| } | } | ||||
| for (block = ar->uiblocks.last; block; block = block->prev) { | for (block = ar->uiblocks.last; block; block = block->prev) { | ||||
| bool inside = false, inside_header = false, inside_scale = false; | bool inside = false, inside_scale = false; | ||||
| mx = event->x; | mx = event->x; | ||||
| my = event->y; | my = event->y; | ||||
| Context not available. | |||||
| ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); | ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); | ||||
| retval = WM_UI_HANDLER_BREAK; | retval = WM_UI_HANDLER_BREAK; | ||||
| continue; | break; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| continue; | continue; | ||||
| if (inside || inside_header) { | if (inside || inside_header) { | ||||
| block_act = block; | |||||
| if (event->val == KM_PRESS) { | if (event->val == KM_PRESS) { | ||||
| /* open close on header */ | /* open close on header */ | ||||
| Context not available. | |||||
| retval = WM_UI_HANDLER_BREAK; | retval = WM_UI_HANDLER_BREAK; | ||||
| if (inside_header) { | if (inside_header) { | ||||
| ui_handle_panel_header(C, block, mx, my, 0, event->ctrl, event->shift); | ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); | ||||
| retval = WM_UI_HANDLER_BREAK; | retval = WM_UI_HANDLER_BREAK; | ||||
| break; | break; | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (event->type == MOUSEMOVE && !ui_button_is_active(ar)) { | |||||
| if (block_act && inside_header) | |||||
| ui_handle_panel_header(C, block_act, mx, my, 0, 0, 0); | |||||
| else | |||||
| WM_cursor_modal_restore(win); | |||||
| } | |||||
| return retval; | return retval; | ||||
| } | } | ||||
| Context not available. | |||||
| uiHandlePanelData *data = panel->activedata; | uiHandlePanelData *data = panel->activedata; | ||||
| /* verify if we can stop */ | /* verify if we can stop */ | ||||
| if (event->type == LEFTMOUSE && event->val != KM_PRESS) { | if (ELEM(event->type, LEFTMOUSE, RETKEY, PADENTER) && event->val != KM_PRESS) { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| int align = panel_aligned(sa, ar); | int align = panel_aligned(sa, ar); | ||||
| Context not available. | |||||
| panel_activate_state(C, panel, PANEL_STATE_ANIMATION); | panel_activate_state(C, panel, PANEL_STATE_ANIMATION); | ||||
| else | else | ||||
| panel_activate_state(C, panel, PANEL_STATE_EXIT); | panel_activate_state(C, panel, PANEL_STATE_EXIT); | ||||
| WM_cursor_modal_restore(CTX_wm_window(C)); | |||||
| } | } | ||||
| else if (event->type == MOUSEMOVE) { | else if (event->type == MOUSEMOVE) { | ||||
| if (data->state == PANEL_STATE_DRAG) | if (data->state == PANEL_STATE_DRAG) | ||||
| Context not available. | |||||