diff options
Diffstat (limited to 'source/blender/editors/interface')
18 files changed, 117 insertions, 95 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 82ae4de07af..3188829bf31 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2369,7 +2369,7 @@ static bool ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), but->block->unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type)); - return BPY_execute_string_as_number(C, str_unit_convert, true, r_value); + return BPY_execute_string_as_number(C, NULL, str_unit_convert, true, r_value); } #endif /* WITH_PYTHON */ @@ -2384,7 +2384,7 @@ bool ui_but_string_set_eval_num(bContext *C, uiBut *but, const char *str, double if (str[0] != '\0') { bool is_unit_but = (ui_but_is_float(but) && ui_but_is_unit(but)); /* only enable verbose if we won't run again with units */ - if (BPY_execute_string_as_number(C, str, is_unit_but == false, r_value)) { + if (BPY_execute_string_as_number(C, NULL, str, is_unit_but == false, r_value)) { /* if the value parsed ok without unit conversion this button may still need a unit multiplier */ if (is_unit_but) { char str_new[128]; @@ -2879,6 +2879,11 @@ void UI_block_emboss_set(uiBlock *block, char dt) block->dt = dt; } +void UI_block_theme_style_set(uiBlock *block, char theme_style) +{ + block->theme_style = theme_style; +} + /** * \param but: Button to update. * \param validate: When set, this function may change the button value. @@ -4159,7 +4164,7 @@ void UI_but_drag_set_value(uiBut *but) void UI_but_drag_set_image(uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale, const bool use_free) { but->dragtype = WM_DRAG_PATH; - ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesnt draw in button */ + ui_def_but_icon(but, icon, 0); /* no flag UI_HAS_ICON, so icon doesn't draw in button */ if ((but->dragflag & UI_BUT_DRAGPOIN_FREE)) { MEM_SAFE_FREE(but->dragpoin); but->dragflag &= ~UI_BUT_DRAGPOIN_FREE; @@ -4479,7 +4484,7 @@ static void operator_enum_search_cb(const struct bContext *C, void *but, const c for (item = item_array; item->identifier; item++) { /* note: need to give the index rather than the identifier because the enum can be freed */ if (BLI_strcasestr(item->name, str)) { - if (false == UI_search_item_add(items, item->name, SET_INT_IN_POINTER(item->value), 0)) + if (false == UI_search_item_add(items, item->name, POINTER_FROM_INT(item->value), 0)) break; } } @@ -4497,7 +4502,7 @@ static void operator_enum_call_cb(struct bContext *UNUSED(C), void *but, void *a if (ot) { if (ot->prop) { - RNA_property_enum_set(opptr, ot->prop, GET_INT_FROM_POINTER(arg2)); + RNA_property_enum_set(opptr, ot->prop, POINTER_AS_INT(arg2)); /* We do not call op from here, will be called by button code. * ui_apply_but_funcs_after() (in interface_handlers.c) called this func before checking operators, * because one of its parameters is the button itself! diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 5eb4359607a..34f33f1d970 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -103,7 +103,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op) display_device = scene->display_settings.display_device; eye->display = IMB_colormanagement_display_get_named(display_device); - /* store inital color */ + /* store initial color */ RNA_property_float_get_array(&eye->ptr, eye->prop, col); if (eye->display) { IMB_colormanagement_display_to_scene_linear_v3(col, eye->display); diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c index 2bb575558fc..43ccd65ddf2 100644 --- a/source/blender/editors/interface/interface_eyedropper_datablock.c +++ b/source/blender/editors/interface/interface_eyedropper_datablock.c @@ -190,7 +190,10 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int } } - if (id) { + PointerRNA idptr; + RNA_id_pointer_create(id, &idptr); + + if (id && RNA_property_pointer_poll(&ddr->ptr, ddr->prop, &idptr)) { BLI_snprintf(ddr->name, sizeof(ddr->name), "%s: %s", ddr->idcode_name, id->name + 2); *r_id = id; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 06b6099cec7..64c3ae32eaa 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -160,7 +160,7 @@ typedef enum uiHandleButtonState { #ifdef USE_ALLSELECT -/* Unfortunately theres no good way handle more generally: +/* Unfortunately there's no good way handle more generally: * (propagate single clicks on layer buttons to other objects) */ #define USE_ALLSELECT_LAYER_HACK @@ -2529,7 +2529,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, * It converts every UTF-8 character to an asterisk, and also remaps * the cursor position and selection start/end. * - * \note: remaping is used, because password could contain UTF-8 characters. + * \note: remapping is used, because password could contain UTF-8 characters. * */ @@ -2793,7 +2793,7 @@ static bool ui_textedit_insert_buf( if ((len + step >= data->maxlen) && (data->maxlen - (len + 1) > 0)) { if (ui_but_is_utf8(but)) { - /* shorten 'step' to a utf8 algined size that fits */ + /* shorten 'step' to a utf8 aligned size that fits */ BLI_strnlen_utf8_ex(buf, data->maxlen - (len + 1), &step); } else { @@ -3859,7 +3859,7 @@ static int ui_do_but_HOTKEYEVT( if (event->type == LEFTMOUSE && event->val == KM_PRESS) { /* only cancel if click outside the button */ if (ui_but_contains_point_px(but->active->region, but, event->x, event->y) == 0) { - /* data->cancel doesnt work, this button opens immediate */ + /* data->cancel doesn't work, this button opens immediate */ if (but->flag & UI_BUT_IMMEDIATE) ui_but_value_set(but, 0); else @@ -4444,7 +4444,7 @@ static int ui_do_but_NUM( else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { if (data->dragchange) { #ifdef USE_DRAG_MULTINUM - /* if we started multibutton but didnt drag, then edit */ + /* if we started multibutton but didn't drag, then edit */ if (data->multi_data.init == BUTTON_MULTI_INIT_SETUP) { click = 1; } @@ -4755,7 +4755,7 @@ static int ui_do_but_SLI( else if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { if (data->dragchange) { #ifdef USE_DRAG_MULTINUM - /* if we started multibutton but didnt drag, then edit */ + /* if we started multibutton but didn't drag, then edit */ if (data->multi_data.init == BUTTON_MULTI_INIT_SETUP) { click = 1; } @@ -8327,7 +8327,7 @@ static void ui_handle_button_return_submenu(bContext *C, const wmEvent *event, u /* ************************* menu handling *******************************/ /** - * Function used to prevent loosing the open menu when using nested pulldowns, + * Function used to prevent losing the open menu when using nested pulldowns, * when moving mouse towards the pulldown menu over other buttons that could * steal the highlight from the current button, only checks: * @@ -8547,7 +8547,7 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my, uiBut *to_bt) * let the parent menu get the event. * * This allows a menu to be open, - * but send key events to the parent if theres no active buttons. + * but send key events to the parent if there's no active buttons. * * Without this keyboard navigation from menu's wont work. */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 75f2efdf3aa..11691fd8365 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -404,9 +404,10 @@ struct uiBlock { short alignnr; char direction; + char theme_style; /* UI_BLOCK_THEME_STYLE_* */ char dt; /* drawtype: UI_EMBOSS, UI_EMBOSS_NONE ... etc, copied to buttons */ bool auto_open; - char _pad[7]; + char _pad[6]; double auto_open_last; const char *lockstr; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index edd568e4fea..6550115e50b 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -370,7 +370,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) uiBut *but = arg_but, *cbut; PointerRNA *ptr = &but->rnapoin; PropertyRNA *prop = but->rnaprop; - int i, index = GET_INT_FROM_POINTER(arg_index); + int i, index = POINTER_AS_INT(arg_index); int shift = win->eventstate->shift; int len = RNA_property_array_length(ptr, prop); @@ -463,7 +463,7 @@ static void ui_item_array( but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); if (subtype == PROP_LAYER_MEMBER) - UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); + UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); } for (a = 0; a < colbuts; a++) { const int layer_num = a + len / 2 + b * colbuts; @@ -481,7 +481,7 @@ static void ui_item_array( but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); if (subtype == PROP_LAYER_MEMBER) - UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); + UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num)); } UI_block_align_end(block); @@ -567,7 +567,7 @@ static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2) if (!win->eventstate->shift) { uiBut *but = (uiBut *)arg1; - int enum_value = GET_INT_FROM_POINTER(arg2); + int enum_value = POINTER_AS_INT(arg2); int current_value = RNA_property_enum_get(&but->rnapoin, but->rnaprop); if (!(current_value & enum_value)) { @@ -645,7 +645,7 @@ static void ui_item_enum_expand( but = uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { - UI_but_func_set(but, ui_item_enum_expand_handle, but, SET_INT_IN_POINTER(value)); + UI_but_func_set(but, ui_item_enum_expand_handle, but, POINTER_FROM_INT(value)); } if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) @@ -1099,7 +1099,7 @@ void uiItemsFullEnumO_items( uiItemS(target); } else { - /* XXX bug here, colums draw bottom item badly */ + /* XXX bug here, columns draw bottom item badly */ uiItemS(target); } } @@ -1741,7 +1741,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s /* add search items from temporary list */ for (cis = items_list->first; cis; cis = cis->next) { - if (false == UI_search_item_add(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) { + if (false == UI_search_item_add(items, cis->name, POINTER_FROM_INT(cis->index), cis->iconid)) { break; } } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 1e67ecdfc90..d941f429339 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1151,7 +1151,7 @@ void ED_operatortypes_ui(void) */ void ED_keymap_ui(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "User Interface", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "User Interface", 0, 0); wmKeyMapItem *kmi; /* eyedroppers - notice they all have the same shortcut, but pass the event diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 744f6b3c4d0..1e8a80bb308 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1247,7 +1247,7 @@ static void ui_panel_drag_collapse(bContext *C, uiPanelDragCollapseHandle *dragc /** * Panel drag-collapse (modal handler) * Clicking and dragging over panels toggles their collapse state based on the panel that was first - * dragged over. If it was open all affected panels incl the initial one are closed and vise versa. + * dragged over. If it was open all affected panels incl the initial one are closed and vice versa. */ static int ui_panel_drag_collapse_handler(bContext *C, const wmEvent *event, void *userdata) { @@ -1619,7 +1619,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) const int px = max_ii(1, round_fl_to_int(U.pixelsize)); const int category_tabs_width = round_fl_to_int(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom); const float dpi_fac = UI_DPI_FAC; - const int tab_v_pad_text = round_fl_to_int((2 + ((px * 3) * dpi_fac)) * zoom); /* pading of tabs around text */ + const int tab_v_pad_text = round_fl_to_int((2 + ((px * 3) * dpi_fac)) * zoom); /* padding of tabs around text */ const int tab_v_pad = round_fl_to_int((4 + (2 * px * dpi_fac)) * zoom); /* padding between tabs */ const float tab_curve_radius = ((px * 3) * dpi_fac) * zoom; const int roundboxtype = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT; diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c index 00462b456ea..afa3486cf6c 100644 --- a/source/blender/editors/interface/interface_region_color_picker.c +++ b/source/blender/editors/interface/interface_region_color_picker.c @@ -629,6 +629,7 @@ uiBlock *ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_ ui_block_colorpicker(block, handle->retvec, &but->rnapoin, but->rnaprop, show_picker); block->flag = UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_OUT_1 | UI_BLOCK_MOVEMOUSE_QUIT; + UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); UI_block_bounds_set_normal(block, 0.5 * UI_UNIT_X); block->block_event_func = ui_colorpicker_small_wheel_cb; diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c index 41001d65d82..ef2d273bab6 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.c +++ b/source/blender/editors/interface/interface_region_menu_pie.c @@ -87,6 +87,7 @@ static uiBlock *ui_block_func_PIE(bContext *UNUSED(C), uiPopupBlockHandle *handl UI_block_layout_resolve(block, &width, &height); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NUMSELECT); + UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); block->minbounds = minwidth; block->bounds = 1; diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index fa7113f195e..fac96fc2154 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -235,6 +235,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi uiBut *but_activate = NULL; UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NUMSELECT); + UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); UI_block_direction_set(block, direction); /* offset the mouse position, possibly based on earlier selection */ diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 656c59055af..93fd62b5c66 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -502,6 +502,7 @@ uiBlock *ui_popup_block_refresh( } block->flag |= UI_BLOCK_LOOP; + UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); /* defer this until blocks are translated (below) */ block->oldblock = NULL; diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 1eec3737215..7bb0a02bbf6 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -573,12 +573,12 @@ static ARegion *ui_tooltip_create_with_data( const float pad_px = UI_TIP_PADDING; wmWindow *win = CTX_wm_window(C); const int winx = WM_window_pixels_x(win); + const int winy = WM_window_pixels_y(win); uiStyle *style = UI_style_get(); static ARegionType type; ARegion *ar; int fonth, fontw; int h, i; - rctf rect_fl; rcti rect_i; int font_flag = 0; @@ -658,35 +658,32 @@ static ARegion *ui_tooltip_create_with_data( data->toth = fonth; data->lineh = h; - /* compute position */ - - rect_fl.xmin = init_position[0] - TIP_BORDER_X; - rect_fl.xmax = rect_fl.xmin + fontw + pad_px; - rect_fl.ymax = init_position[1] - TIP_BORDER_Y; - rect_fl.ymin = rect_fl.ymax - fonth - TIP_BORDER_Y; - - BLI_rcti_rctf_copy(&rect_i, &rect_fl); + /* Compute position. */ + { + rctf rect_fl; + rect_fl.xmin = init_position[0] - TIP_BORDER_X; + rect_fl.xmax = rect_fl.xmin + fontw + pad_px; + rect_fl.ymax = init_position[1] - TIP_BORDER_Y; + rect_fl.ymin = rect_fl.ymax - fonth - TIP_BORDER_Y; + BLI_rcti_rctf_copy(&rect_i, &rect_fl); + } #undef TIP_BORDER_X #undef TIP_BORDER_Y - /* clip with window boundaries */ - if (rect_i.xmax > winx) { - /* super size */ - if (rect_i.xmax > winx + rect_i.xmin) { - rect_i.xmax = winx; - rect_i.xmin = 0; - } - else { - rect_i.xmin -= rect_i.xmax - winx; - rect_i.xmax = winx; - } - } - /* ensure at least 5 px above screen bounds - * 25 is just a guess to be above the menu item */ - if (rect_i.ymin < 5) { - rect_i.ymax += (-rect_i.ymin) + 30; - rect_i.ymin = 30; + /* Clamp to window bounds. */ + { + /* Ensure at least 5 px above screen bounds + * UI_UNIT_Y is just a guess to be above the menu item */ + const int pad = max_ff(1.0f, U.pixelsize) * 5; + const rcti rect_clamp = { + .xmin = pad, + .xmax = winx - pad, + .ymin = pad + (UI_UNIT_Y * 2), + .ymax = winy - pad, + }; + int offset_dummy[2]; + BLI_rcti_clamp(&rect_i, &rect_clamp, offset_dummy); } /* add padding */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 9d05819dd6a..86f9ba40f16 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -267,6 +267,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU); + UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); /* preview thumbnails */ if (template_ui.prv_rows > 0 && template_ui.prv_cols > 0) { @@ -348,7 +349,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) TemplateID *template_ui = (TemplateID *)arg_litem; PointerRNA idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); ID *id = idptr.data; - int event = GET_INT_FROM_POINTER(arg_event); + int event = POINTER_AS_INT(arg_event); switch (event) { case UI_ID_BROWSE: @@ -534,7 +535,7 @@ static void template_ID( but = uiDefButR( block, UI_BTYPE_TEXT, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type)); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_RENAME)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_RENAME)); if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT); if (id->lib) { @@ -552,7 +553,7 @@ static void template_ID( UI_but_flag_enable(but, UI_BUT_DISABLED); } - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_LOCAL)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_LOCAL)); } if (id->us > 1) { @@ -567,7 +568,7 @@ static void template_ID( TIP_("Display number of users of this data (click to make a single-user copy)")); but->flag |= UI_BUT_UNDO; - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ALONE)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ALONE)); if (/* test only */ (id_copy(CTX_data_main(C), id, NULL, true) == false) || (idfrom && idfrom->lib) || @@ -625,13 +626,13 @@ static void template_ID( but = uiDefIconTextButO( block, UI_BTYPE_BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); } else { but = uiDefIconTextBut( block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_ADD_NEW)); } if ((idfrom && idfrom->lib) || !editable) @@ -657,13 +658,13 @@ static void template_ID( but = uiDefIconTextButO( block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OPEN)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); } else { but = uiDefIconTextBut( block, UI_BTYPE_BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_OPEN)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_OPEN)); } if ((idfrom && idfrom->lib) || !editable) @@ -687,7 +688,7 @@ static void template_ID( block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Unlink data-block " "(Shift + Click to set users to zero, data will then not be saved)")); - UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), SET_INT_IN_POINTER(UI_ID_DELETE)); + UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template_ui), POINTER_FROM_INT(UI_ID_DELETE)); if (RNA_property_flag(template_ui->prop) & PROP_NEVER_NULL) { UI_but_flag_enable(but, UI_BUT_DISABLED); @@ -1143,7 +1144,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) /* find modifier and draw it */ cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0); - /* XXX virtual modifiers are not accesible for python */ + /* XXX virtual modifiers are not accessible for python */ vmd = modifiers_getVirtualModifierList(ob, &virtualModifierData); for (i = 0; vmd; i++, vmd = vmd->next) { @@ -1283,11 +1284,11 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) short prev_proxylock, show_upbut, show_downbut; /* Up/Down buttons: - * Proxy-constraints are not allowed to occur after local (non-proxy) constraints - * as that poses problems when restoring them, so disable the "up" button where - * it may cause this situation. + * Proxy-constraints are not allowed to occur after local (non-proxy) constraints + * as that poses problems when restoring them, so disable the "up" button where + * it may cause this situation. * - * Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose. + * Up/Down buttons should only be shown (or not grayed - todo) if they serve some purpose. */ if (BKE_constraints_proxylocked_owner(ob, pchan)) { if (con->prev) { @@ -1774,6 +1775,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem) block = UI_block_begin(C, ar, "_popup", UI_EMBOSS_PULLDOWN); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NO_FLIP); + UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); RNA_property_enum_items(C, &args.ptr, args.prop, &item, NULL, &free); @@ -2037,7 +2039,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) block = UI_block_begin(C, ar, __func__, UI_EMBOSS); - /* use this for a fake extra empy space around the buttons */ + /* use this for a fake extra empty space around the buttons */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); bt = uiDefButBitI( @@ -2596,7 +2598,7 @@ void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propn static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) { uiBut *but = arg1; - int cur = GET_INT_FROM_POINTER(arg2); + int cur = POINTER_AS_INT(arg2); wmWindow *win = CTX_wm_window(C); int i, tot, shift = win->eventstate->shift; @@ -2680,7 +2682,7 @@ void uiTemplateLayers( icon = ICON_LAYER_USED; but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2); - UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer)); + UI_but_func_set(but, handle_layer_buttons, but, POINTER_FROM_INT(layer)); but->type = UI_BTYPE_TOGGLE; } } @@ -2751,7 +2753,7 @@ void uiTemplateGameStates( but = uiDefIconButR_prop( block, UI_BTYPE_ICON_TOGGLE, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, state, 0, 0, -1, -1, sca_state_name_get(ob, state)); - UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state)); + UI_but_func_set(but, handle_layer_buttons, but, POINTER_FROM_INT(state)); but->type = UI_BTYPE_TOGGLE; } } @@ -3874,9 +3876,11 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) UI_but_func_tooltip_set(but_progress, progress_tooltip_func, tip_arg); } - uiDefIconTextBut(block, UI_BTYPE_BUT, handle_event, ICON_PANEL_CLOSE, - "", 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); + if (!wm->is_interface_locked) { + uiDefIconTextBut(block, UI_BTYPE_BUT, handle_event, ICON_PANEL_CLOSE, + "", 0, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); + } } if (screen->animtimer) diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 2059fc1c849..2b9c6265eeb 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -120,7 +120,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind but = uiDefButR_prop(block, UI_BTYPE_TEXT, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); if (RNA_property_flag(prop) & PROP_TEXTEDIT_UPDATE) { - /* TEXTEDIT_UPDATE is usally used for search buttons. For these we also want + /* TEXTEDIT_UPDATE is usually used for search buttons. For these we also want * the 'x' icon to clear search string, so setting VALUE_CLEAR flag, too. */ UI_but_flag_enable(but, UI_BUT_TEXTEDIT_UPDATE | UI_BUT_VALUE_CLEAR); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index a7de70629d1..a655dea9215 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -680,7 +680,9 @@ static void widgetbase_outline(uiWidgetBase *wtb) glDisableClientState(GL_VERTEX_ARRAY); } -static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) +static void widgetbase_draw_ex( + uiWidgetBase *wtb, uiWidgetColors *wcol, + const bool show_alpha_checkers) { int j, a; @@ -690,7 +692,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) if (wtb->draw_inner) { BLI_assert(wtb->totvert != 0); if (wcol->shaded == 0) { - if (wcol->alpha_check) { + if (show_alpha_checkers) { float inner_v_half[WIDGET_SIZE_MAX][2]; float x_mid = 0.0f; /* used for dumb clamping of values */ @@ -841,6 +843,11 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glDisable(GL_BLEND); } +static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) +{ + widgetbase_draw_ex(wtb, wcol, false); +} + /* *********************** text/icon ************************************** */ #define UI_TEXT_CLIP_MARGIN (0.25f * U.widget_unit / but->block->aspect) @@ -1473,7 +1480,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b #endif /* cut string in 2 parts - only for menu entries */ - if ((but->block->flag & UI_BLOCK_LOOP) && + if ((but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) && (but->editstr == NULL)) { if (but->flag & UI_BUT_HAS_SEP_CHAR) { @@ -3100,9 +3107,9 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat ui_block_cm_to_display_space_v3(but->block, col); rgba_float_to_uchar((unsigned char *)wcol->inner, col); + const bool show_alpha_checkers = (wcol->inner[3] < 255); wcol->shaded = 0; - wcol->alpha_check = (wcol->inner[3] < 255); if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { /* Now we reduce alpha of the inner color (i.e. the color shown) @@ -3113,7 +3120,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat wcol->inner[3] /= 2; } - widgetbase_draw(&wtb, wcol); + widgetbase_draw_ex(&wtb, wcol, show_alpha_checkers); if (but->a1 == UI_PALETTE_COLOR && ((Palette *)but->rnapoin.id.data)->active_color == (int)but->a2) { float width = rect->xmax - rect->xmin; @@ -3749,7 +3756,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct wt->wcol_theme = &tui->wcol_box; wt->state = widget_state; } - else if (but->block->flag & UI_BLOCK_LOOP) { + else if (but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) { wt->wcol_theme = &tui->wcol_menu_back; wt->state = widget_state; } @@ -3785,8 +3792,9 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct case UI_BTYPE_SEARCH_MENU: wt = widget_type(UI_WTYPE_NAME); - if (but->block->flag & UI_BLOCK_LOOP) + if (but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) { wt->wcol_theme = &btheme->tui.wcol_menu_back; + } break; case UI_BTYPE_BUT_TOGGLE: @@ -3805,9 +3813,9 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct wt = widget_type(UI_WTYPE_TOGGLE); /* option buttons have strings outside, on menus use different colors */ - if (but->block->flag & UI_BLOCK_LOOP) + if (but->block->theme_style == UI_BLOCK_THEME_STYLE_POPUP) { wt->state = widget_state_option_menu; - + } break; case UI_BTYPE_MENU: diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 299001d4e45..c60371a0bbf 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -215,8 +215,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* see eView2D_CommonViewTypes in UI_view2d.h for available view presets */ switch (type) { /* 'standard view' - optimum setup for 'standard' view behavior, - * that should be used new views as basis for their - * own unique View2D settings, which should be used instead of this in most cases... + * that should be used new views as basis for their + * own unique View2D settings, which should be used instead of this in most cases... */ case V2D_COMMONVIEW_STANDARD: { @@ -226,9 +226,9 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->maxzoom = 1000.0f; /* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now - * - region can resize 'tot' later to fit other data - * - keeptot is only within bounds, as strict locking is not that critical - * - view is aligned for (0,0) -> (winx-1, winy-1) setup + * - region can resize 'tot' later to fit other data + * - keeptot is only within bounds, as strict locking is not that critical + * - view is aligned for (0,0) -> (winx-1, winy-1) setup */ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y); v2d->keeptot = V2D_KEEPTOT_BOUNDS; @@ -260,7 +260,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) break; } /* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead. - * zoom, aspect ratio, and alignment restrictions are set here */ + * zoom, aspect ratio, and alignment restrictions are set here */ case V2D_COMMONVIEW_STACK: { /* zoom + aspect ratio are locked */ @@ -478,7 +478,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas float curRatio, winRatio; /* when a window edge changes, the aspect ratio can't be used to - * find which is the best new 'cur' rect. thats why it stores 'old' + * find which is the best new 'cur' rect. that's why it stores 'old' */ if (winx != v2d->oldwinx) do_x = true; if (winy != v2d->oldwiny) do_y = true; @@ -628,7 +628,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } else if (cur->xmax > tot->xmax) { /* - only offset by difference of cur-xmax and tot-xmax if that would not move - * cur-xmin to lie past tot-xmin + * cur-xmin to lie past tot-xmin * - otherwise, simply shift to tot-xmin??? */ temp = cur->xmax - tot->xmax; @@ -672,7 +672,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } else if (cur->xmax > tot->xmax) { /* - only offset by difference of cur-xmax and tot-xmax if that would not move - * cur-xmin to lie past tot-xmin + * cur-xmin to lie past tot-xmin * - otherwise, simply shift to tot-xmin??? */ temp = cur->xmax - tot->xmax; @@ -1189,7 +1189,7 @@ static void step_to_grid(float *step, int *power, int unit) /* for frames, we want 1.0 frame intervals only */ if (unit == V2D_UNIT_FRAMES) { rem = 1.0f; - *step = 2.0f; /* use 2 since there are grid lines drawn in between, this way to get 1 line per frane */ + *step = 2.0f; /* use 2 since there are grid lines drawn in between, this way to get 1 line per frame */ } /* prevents printing 1.0 2.0 3.0 etc */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 3cad2167cfa..b9ea5d96057 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -2098,7 +2098,7 @@ void ED_operatortypes_view2d(void) void ED_keymap_view2d(wmKeyConfig *keyconf) { - wmKeyMap *keymap = WM_keymap_find(keyconf, "View2D", 0, 0); + wmKeyMap *keymap = WM_keymap_ensure(keyconf, "View2D", 0, 0); wmKeyMapItem *kmi; /* scrollers */ @@ -2158,7 +2158,7 @@ void ED_keymap_view2d(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0); /* Alternative keymap for buttons listview */ - keymap = WM_keymap_find(keyconf, "View2D Buttons List", 0, 0); + keymap = WM_keymap_ensure(keyconf, "View2D Buttons List", 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW2D_OT_scroller_activate", MIDDLEMOUSE, KM_PRESS, 0, 0); |