Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | else { | ||||
| *r_rect = region->winrct; | *r_rect = region->winrct; | ||||
| } | } | ||||
| } | } | ||||
| /* ******************* block calc ************************* */ | /* ******************* block calc ************************* */ | ||||
| void UI_block_translate(uiBlock *block, int x, int y) | void UI_block_translate(uiBlock *block, int x, int y) | ||||
| { | { | ||||
| uiBut *but; | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| for (but = block->buttons.first; but; but = but->next) { | |||||
| BLI_rctf_translate(&but->rect, x, y); | BLI_rctf_translate(&but->rect, x, y); | ||||
| } | } | ||||
| BLI_rctf_translate(&block->rect, x, y); | BLI_rctf_translate(&block->rect, x, y); | ||||
| } | } | ||||
| static void ui_block_bounds_calc_text(uiBlock *block, float offset) | static void ui_block_bounds_calc_text(uiBlock *block, float offset) | ||||
| { | { | ||||
| const uiStyle *style = UI_style_get(); | const uiStyle *style = UI_style_get(); | ||||
| uiBut *bt, *init_col_bt, *col_bt; | uiBut *col_bt; | ||||
| int i = 0, j, x1addval = offset; | int i = 0, j, x1addval = offset; | ||||
| UI_fontstyle_set(&style->widget); | UI_fontstyle_set(&style->widget); | ||||
| for (init_col_bt = bt = block->buttons.first; bt; bt = bt->next) { | uiBut *init_col_bt = block->buttons.first; | ||||
| LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { | |||||
| if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) { | if (!ELEM(bt->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE, UI_BTYPE_SEPR_SPACER)) { | ||||
| j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr)); | j = BLF_width(style->widget.uifont_id, bt->drawstr, sizeof(bt->drawstr)); | ||||
| if (j > i) { | if (j > i) { | ||||
| i = j; | i = j; | ||||
| } | } | ||||
| } | } | ||||
| Show All 19 Lines | for (col_bt = init_col_bt; col_bt; col_bt = col_bt->next) { | ||||
| col_bt->rect.xmax = max_ff(x1addval + i + block->bounds, offset + block->minbounds); | col_bt->rect.xmax = max_ff(x1addval + i + block->bounds, offset + block->minbounds); | ||||
| ui_but_update(col_bt); /* clips text again */ | ui_but_update(col_bt); /* clips text again */ | ||||
| } | } | ||||
| } | } | ||||
| void ui_block_bounds_calc(uiBlock *block) | void ui_block_bounds_calc(uiBlock *block) | ||||
| { | { | ||||
| uiBut *bt; | |||||
| int xof; | int xof; | ||||
| if (BLI_listbase_is_empty(&block->buttons)) { | if (BLI_listbase_is_empty(&block->buttons)) { | ||||
| if (block->panel) { | if (block->panel) { | ||||
| block->rect.xmin = 0.0; | block->rect.xmin = 0.0; | ||||
| block->rect.xmax = block->panel->sizex; | block->rect.xmax = block->panel->sizex; | ||||
| block->rect.ymin = 0.0; | block->rect.ymin = 0.0; | ||||
| block->rect.ymax = block->panel->sizey; | block->rect.ymax = block->panel->sizey; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_rctf_init_minmax(&block->rect); | BLI_rctf_init_minmax(&block->rect); | ||||
| for (bt = block->buttons.first; bt; bt = bt->next) { | LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { | ||||
| BLI_rctf_union(&block->rect, &bt->rect); | BLI_rctf_union(&block->rect, &bt->rect); | ||||
| } | } | ||||
| block->rect.xmin -= block->bounds; | block->rect.xmin -= block->bounds; | ||||
| block->rect.ymin -= block->bounds; | block->rect.ymin -= block->bounds; | ||||
| block->rect.xmax += block->bounds; | block->rect.xmax += block->bounds; | ||||
| block->rect.ymax += block->bounds; | block->rect.ymax += block->bounds; | ||||
| } | } | ||||
| block->rect.xmax = block->rect.xmin + max_ff(BLI_rctf_size_x(&block->rect), block->minbounds); | block->rect.xmax = block->rect.xmin + max_ff(BLI_rctf_size_x(&block->rect), block->minbounds); | ||||
| /* hardcoded exception... but that one is annoying with larger safety */ | /* hardcoded exception... but that one is annoying with larger safety */ | ||||
| bt = block->buttons.first; | uiBut *bt = block->buttons.first; | ||||
| if (bt && STREQLEN(bt->str, "ERROR", 5)) { | if (bt && STREQLEN(bt->str, "ERROR", 5)) { | ||||
| xof = 10; | xof = 10; | ||||
| } | } | ||||
| else { | else { | ||||
| xof = 40; | xof = 40; | ||||
| } | } | ||||
| block->safety.xmin = block->rect.xmin - xof; | block->safety.xmin = block->rect.xmin - xof; | ||||
| ▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | if (but->optype != oldbut->optype) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| uiBut *ui_but_find_old(uiBlock *block_old, const uiBut *but_new) | uiBut *ui_but_find_old(uiBlock *block_old, const uiBut *but_new) | ||||
| { | { | ||||
| uiBut *but_old; | uiBut *but_old = NULL; | ||||
| for (but_old = block_old->buttons.first; but_old; but_old = but_old->next) { | LISTBASE_FOREACH (uiBut *, but, &block_old->buttons) { | ||||
| if (ui_but_equals_old(but_new, but_old)) { | if (ui_but_equals_old(but_new, but)) { | ||||
| but_old = but; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return but_old; | return but_old; | ||||
| } | } | ||||
| uiBut *ui_but_find_new(uiBlock *block_new, const uiBut *but_old) | uiBut *ui_but_find_new(uiBlock *block_new, const uiBut *but_old) | ||||
| { | { | ||||
| uiBut *but_new; | uiBut *but_new = NULL; | ||||
| for (but_new = block_new->buttons.first; but_new; but_new = but_new->next) { | LISTBASE_FOREACH (uiBut *, but, &block_new->buttons) { | ||||
| if (ui_but_equals_old(but_new, but_old)) { | if (ui_but_equals_old(but, but_old)) { | ||||
| but_new = but; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return but_new; | return but_new; | ||||
| } | } | ||||
| /** | /** | ||||
| * \return true when \a but_p is set (only done for active buttons). | * \return true when \a but_p is set (only done for active buttons). | ||||
| ▲ Show 20 Lines • Show All 735 Lines • ▼ Show 20 Lines | |||||
| static void ui_but_pie_direction_string(uiBut *but, char *buf, int size) | static void ui_but_pie_direction_string(uiBut *but, char *buf, int size) | ||||
| { | { | ||||
| BLI_assert(but->pie_dir < ARRAY_SIZE(ui_radial_dir_to_numpad)); | BLI_assert(but->pie_dir < ARRAY_SIZE(ui_radial_dir_to_numpad)); | ||||
| BLI_snprintf(buf, size, "%d", ui_radial_dir_to_numpad[but->pie_dir]); | BLI_snprintf(buf, size, "%d", ui_radial_dir_to_numpad[but->pie_dir]); | ||||
| } | } | ||||
| static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) | static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) | ||||
| { | { | ||||
| uiBut *but; | |||||
| char buf[128]; | char buf[128]; | ||||
| BLI_assert(block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)); | BLI_assert(block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)); | ||||
| /* only do it before bounding */ | /* only do it before bounding */ | ||||
| if (block->rect.xmin != block->rect.xmax) { | if (block->rect.xmin != block->rect.xmax) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (STREQ(block->name, "splash")) { | if (STREQ(block->name, "splash")) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (block->flag & UI_BLOCK_RADIAL) { | if (block->flag & UI_BLOCK_RADIAL) { | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| if (but->pie_dir != UI_RADIAL_NONE) { | if (but->pie_dir != UI_RADIAL_NONE) { | ||||
| ui_but_pie_direction_string(but, buf, sizeof(buf)); | ui_but_pie_direction_string(but, buf, sizeof(buf)); | ||||
| ui_but_add_shortcut(but, buf, false); | ui_but_add_shortcut(but, buf, false); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| if (block->flag & UI_BLOCK_SHOW_SHORTCUT_ALWAYS) { | if (block->flag & UI_BLOCK_SHOW_SHORTCUT_ALWAYS) { | ||||
| /* Skip icon-only buttons (as used in the toolbar). */ | /* Skip icon-only buttons (as used in the toolbar). */ | ||||
| if (but->drawstr[0] == '\0') { | if (but->drawstr[0] == '\0') { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (((block->flag & UI_BLOCK_POPOVER) == 0) && UI_but_is_tool(but)) { | if (((block->flag & UI_BLOCK_POPOVER) == 0) && UI_but_is_tool(but)) { | ||||
| /* For non-popovers, shown in shortcut only | /* For non-popovers, shown in shortcut only | ||||
| * (has special shortcut handling code). */ | * (has special shortcut handling code). */ | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | static void ui_but_extra_operator_icon_free(uiButExtraOpIcon *extra_icon) | ||||
| WM_operator_properties_free(extra_icon->optype_params->opptr); | WM_operator_properties_free(extra_icon->optype_params->opptr); | ||||
| MEM_freeN(extra_icon->optype_params->opptr); | MEM_freeN(extra_icon->optype_params->opptr); | ||||
| MEM_freeN(extra_icon->optype_params); | MEM_freeN(extra_icon->optype_params); | ||||
| MEM_freeN(extra_icon); | MEM_freeN(extra_icon); | ||||
| } | } | ||||
| void ui_but_extra_operator_icons_free(uiBut *but) | void ui_but_extra_operator_icons_free(uiBut *but) | ||||
| { | { | ||||
| LISTBASE_FOREACH_MUTABLE (uiButExtraOpIcon *, op_icon, &but->extra_op_icons) { | |||||
| for (uiButExtraOpIcon *op_icon = but->extra_op_icons.first, *op_icon_next; op_icon; | |||||
| op_icon = op_icon_next) { | |||||
| op_icon_next = op_icon->next; | |||||
| ui_but_extra_operator_icon_free(op_icon); | ui_but_extra_operator_icon_free(op_icon); | ||||
| } | } | ||||
| BLI_listbase_clear(&but->extra_op_icons); | BLI_listbase_clear(&but->extra_op_icons); | ||||
| } | } | ||||
| PointerRNA *UI_but_extra_operator_icon_add(uiBut *but, | PointerRNA *UI_but_extra_operator_icon_add(uiBut *but, | ||||
| const char *opname, | const char *opname, | ||||
| short opcontext, | short opcontext, | ||||
| ▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | static void ui_but_predefined_extra_operator_icons_add(uiBut *but) | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| void UI_block_update_from_old(const bContext *C, uiBlock *block) | void UI_block_update_from_old(const bContext *C, uiBlock *block) | ||||
| { | { | ||||
| uiBut *but_old; | uiBut *but_old; | ||||
| uiBut *but; | |||||
| if (!block->oldblock) { | if (!block->oldblock) { | ||||
| return; | return; | ||||
| } | } | ||||
| but_old = block->oldblock->buttons.first; | but_old = block->oldblock->buttons.first; | ||||
| if (BLI_listbase_is_empty(&block->oldblock->butstore) == false) { | if (BLI_listbase_is_empty(&block->oldblock->butstore) == false) { | ||||
| UI_butstore_update(block); | UI_butstore_update(block); | ||||
| } | } | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| if (ui_but_update_from_old_block(C, block, &but, &but_old)) { | if (ui_but_update_from_old_block(C, block, &but, &but_old)) { | ||||
| ui_but_update(but); | ui_but_update(but); | ||||
| /* redraw dynamic tooltip if we have one open */ | /* redraw dynamic tooltip if we have one open */ | ||||
| if (but->tip_func) { | if (but->tip_func) { | ||||
| UI_but_tooltip_refresh((bContext *)C, but); | UI_but_tooltip_refresh((bContext *)C, but); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| block->auto_open = block->oldblock->auto_open; | block->auto_open = block->oldblock->auto_open; | ||||
| block->auto_open_last = block->oldblock->auto_open_last; | block->auto_open_last = block->oldblock->auto_open_last; | ||||
| block->tooltipdisabled = block->oldblock->tooltipdisabled; | block->tooltipdisabled = block->oldblock->tooltipdisabled; | ||||
| BLI_movelisttolist(&block->color_pickers.list, &block->oldblock->color_pickers.list); | BLI_movelisttolist(&block->color_pickers.list, &block->oldblock->color_pickers.list); | ||||
| block->oldblock = NULL; | block->oldblock = NULL; | ||||
| } | } | ||||
| void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_xy[2]) | void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_xy[2]) | ||||
| { | { | ||||
| wmWindow *window = CTX_wm_window(C); | wmWindow *window = CTX_wm_window(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| uiBut *but; | |||||
| BLI_assert(block->active); | BLI_assert(block->active); | ||||
| UI_block_update_from_old(C, block); | UI_block_update_from_old(C, block); | ||||
| /* inherit flags from 'old' buttons that was drawn here previous, based | /* inherit flags from 'old' buttons that was drawn here previous, based | ||||
| * on matching buttons, we need this to make button event handling non | * on matching buttons, we need this to make button event handling non | ||||
| * blocking, while still allowing buttons to be remade each redraw as it | * blocking, while still allowing buttons to be remade each redraw as it | ||||
| * is expected by blender code */ | * is expected by blender code */ | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| /* temp? Proper check for graying out */ | /* temp? Proper check for graying out */ | ||||
| if (but->optype) { | if (but->optype) { | ||||
| wmOperatorType *ot = but->optype; | wmOperatorType *ot = but->optype; | ||||
| if (but->context) { | if (but->context) { | ||||
| CTX_store_set((bContext *)C, but->context); | CTX_store_set((bContext *)C, but->context); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | static void ui_but_to_pixelrect(rcti *rect, const ARegion *region, uiBlock *block, uiBut *but) | ||||
| BLI_rcti_translate(rect, -region->winrct.xmin, -region->winrct.ymin); | BLI_rcti_translate(rect, -region->winrct.xmin, -region->winrct.ymin); | ||||
| } | } | ||||
| /* uses local copy of style, to scale things down, and allow widgets to change stuff */ | /* uses local copy of style, to scale things down, and allow widgets to change stuff */ | ||||
| void UI_block_draw(const bContext *C, uiBlock *block) | void UI_block_draw(const bContext *C, uiBlock *block) | ||||
| { | { | ||||
| uiStyle style = *UI_style_get_dpi(); /* XXX pass on as arg */ | uiStyle style = *UI_style_get_dpi(); /* XXX pass on as arg */ | ||||
| ARegion *region; | ARegion *region; | ||||
| uiBut *but; | |||||
| rcti rect; | rcti rect; | ||||
| /* get menu region or area region */ | /* get menu region or area region */ | ||||
| region = CTX_wm_menu(C); | region = CTX_wm_menu(C); | ||||
| if (!region) { | if (!region) { | ||||
| region = CTX_wm_region(C); | region = CTX_wm_region(C); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | ui_draw_aligned_panel( | ||||
| &style, block, &rect, UI_panel_category_is_visible(region), show_background); | &style, block, &rect, UI_panel_category_is_visible(region), show_background); | ||||
| } | } | ||||
| BLF_batch_draw_begin(); | BLF_batch_draw_begin(); | ||||
| UI_icon_draw_cache_begin(); | UI_icon_draw_cache_begin(); | ||||
| UI_widgetbase_draw_cache_begin(); | UI_widgetbase_draw_cache_begin(); | ||||
| /* widgets */ | /* widgets */ | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| if (!(but->flag & (UI_HIDDEN | UI_SCROLLED))) { | if (!(but->flag & (UI_HIDDEN | UI_SCROLLED))) { | ||||
| ui_but_to_pixelrect(&rect, region, block, but); | ui_but_to_pixelrect(&rect, region, block, but); | ||||
| /* XXX: figure out why invalid coordinates happen when closing render window */ | /* XXX: figure out why invalid coordinates happen when closing render window */ | ||||
| /* and material preview is redrawn in main window (temp fix for bug #23848) */ | /* and material preview is redrawn in main window (temp fix for bug #23848) */ | ||||
| if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) { | if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) { | ||||
| ui_draw_but(C, region, &style, but, &rect); | ui_draw_but(C, region, &style, but, &rect); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 549 Lines • ▼ Show 20 Lines | int ui_but_string_get_max_length(uiBut *but) | ||||
| if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { | if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { | ||||
| return but->hardmax; | return but->hardmax; | ||||
| } | } | ||||
| return UI_MAX_DRAW_STR; | return UI_MAX_DRAW_STR; | ||||
| } | } | ||||
| uiBut *ui_but_drag_multi_edit_get(uiBut *but) | uiBut *ui_but_drag_multi_edit_get(uiBut *but) | ||||
| { | { | ||||
| uiBut *but_iter; | uiBut *return_but = NULL; | ||||
| BLI_assert(but->flag & UI_BUT_DRAG_MULTI); | BLI_assert(but->flag & UI_BUT_DRAG_MULTI); | ||||
| for (but_iter = but->block->buttons.first; but_iter; but_iter = but_iter->next) { | LISTBASE_FOREACH (uiBut *, but_iter, &but->block->buttons) { | ||||
| if (but_iter->editstr) { | if (but_iter->editstr) { | ||||
| return_but = but_iter; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return but_iter; | return return_but; | ||||
| } | } | ||||
| static double ui_get_but_scale_unit(uiBut *but, double value) | static double ui_get_but_scale_unit(uiBut *but, double value) | ||||
| { | { | ||||
| UnitSettings *unit = but->block->unit; | UnitSettings *unit = but->block->unit; | ||||
| int unit_type = UI_but_unit_type_get(but); | int unit_type = UI_but_unit_type_get(but); | ||||
| /* Time unit is a bit special, not handled by BKE_scene_unit_scale() for now. */ | /* Time unit is a bit special, not handled by BKE_scene_unit_scale() for now. */ | ||||
| ▲ Show 20 Lines • Show All 843 Lines • ▼ Show 20 Lines | void UI_blocklist_free(const bContext *C, ListBase *lb) | ||||
| while ((block = BLI_pophead(lb))) { | while ((block = BLI_pophead(lb))) { | ||||
| UI_block_free(C, block); | UI_block_free(C, block); | ||||
| } | } | ||||
| } | } | ||||
| void UI_blocklist_free_inactive(const bContext *C, ListBase *lb) | void UI_blocklist_free_inactive(const bContext *C, ListBase *lb) | ||||
| { | { | ||||
| uiBlock *block, *nextblock; | LISTBASE_FOREACH_MUTABLE (uiBlock *, block, lb) { | ||||
| for (block = lb->first; block; block = nextblock) { | |||||
| nextblock = block->next; | |||||
| if (!block->handle) { | if (!block->handle) { | ||||
| if (!block->active) { | if (!block->active) { | ||||
| BLI_remlink(lb, block); | BLI_remlink(lb, block); | ||||
| UI_block_free(C, block); | UI_block_free(C, block); | ||||
| } | } | ||||
| else { | else { | ||||
| block->active = 0; | block->active = 0; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,557 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* END Button containing both string label and icon */ | /* END Button containing both string label and icon */ | ||||
| /* cruft to make uiBlock and uiBut private */ | /* cruft to make uiBlock and uiBut private */ | ||||
| int UI_blocklist_min_y_get(ListBase *lb) | int UI_blocklist_min_y_get(ListBase *lb) | ||||
| { | { | ||||
| uiBlock *block; | |||||
| int min = 0; | int min = 0; | ||||
| for (block = lb->first; block; block = block->next) { | LISTBASE_FOREACH (uiBlock *, block, lb) { | ||||
| if (block == lb->first || block->rect.ymin < min) { | if (block == lb->first || block->rect.ymin < min) { | ||||
| min = block->rect.ymin; | min = block->rect.ymin; | ||||
| } | } | ||||
| } | } | ||||
| return min; | return min; | ||||
| } | } | ||||
| void UI_block_direction_set(uiBlock *block, char direction) | void UI_block_direction_set(uiBlock *block, char direction) | ||||
| { | { | ||||
| block->direction = direction; | block->direction = direction; | ||||
| } | } | ||||
| /* this call escapes if there's alignment flags */ | /* this call escapes if there's alignment flags */ | ||||
| void UI_block_order_flip(uiBlock *block) | void UI_block_order_flip(uiBlock *block) | ||||
| { | { | ||||
| uiBut *but; | |||||
| float centy, miny = 10000, maxy = -10000; | float centy, miny = 10000, maxy = -10000; | ||||
| if (U.uiflag & USER_MENUFIXEDORDER) { | if (U.uiflag & USER_MENUFIXEDORDER) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (block->flag & UI_BLOCK_NO_FLIP) { | if (block->flag & UI_BLOCK_NO_FLIP) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| if (but->drawflag & UI_BUT_ALIGN) { | if (but->drawflag & UI_BUT_ALIGN) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (but->rect.ymin < miny) { | if (but->rect.ymin < miny) { | ||||
| miny = but->rect.ymin; | miny = but->rect.ymin; | ||||
| } | } | ||||
| if (but->rect.ymax > maxy) { | if (but->rect.ymax > maxy) { | ||||
| maxy = but->rect.ymax; | maxy = but->rect.ymax; | ||||
| } | } | ||||
| } | } | ||||
| /* mirror trick */ | /* mirror trick */ | ||||
| centy = (miny + maxy) / 2.0f; | centy = (miny + maxy) / 2.0f; | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| but->rect.ymin = centy - (but->rect.ymin - centy); | but->rect.ymin = centy - (but->rect.ymin - centy); | ||||
| but->rect.ymax = centy - (but->rect.ymax - centy); | but->rect.ymax = centy - (but->rect.ymax - centy); | ||||
| SWAP(float, but->rect.ymin, but->rect.ymax); | SWAP(float, but->rect.ymin, but->rect.ymax); | ||||
| } | } | ||||
| block->flag ^= UI_BLOCK_IS_FLIP; | block->flag ^= UI_BLOCK_IS_FLIP; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 983 Lines • Show Last 20 Lines | |||||