diff options
Diffstat (limited to 'source/blender/editors/interface')
11 files changed, 130 insertions, 109 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2e4cab5ec24..3188829bf31 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -4164,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; @@ -4484,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; } } @@ -4502,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_layout.c b/source/blender/editors/interface/interface_layout.c index edd568e4fea..922b5779c9f 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; } } @@ -1941,8 +1941,11 @@ static uiBut *ui_item_menu( else but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip); - if (argN) { /* ugly .. */ - but->poin = (char *)but; + if (argN) { + /* ugly .. */ + if (arg != argN) { + but->poin = (char *)but; + } but->func_argN = argN; } @@ -1976,7 +1979,9 @@ void uiItemM(uiLayout *layout, const char *menuname, const char *name, int icon) if (layout->root->type == UI_LAYOUT_MENU && !icon) icon = ICON_BLANK1; - ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL, TIP_(mt->description), false); + ui_item_menu( + layout, name, icon, ui_item_menutype_func, mt, NULL, + mt->description ? TIP_(mt->description) : "", false); } /* label item */ @@ -2078,6 +2083,18 @@ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc ui_item_menu(layout, name, icon, func, arg, NULL, "", false); } +/** + * Version of #uiItemMenuF that free's `argN`. + */ +void uiItemMenuFN(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *argN) +{ + if (!func) + return; + + /* Second 'argN' only ensures it gets freed. */ + ui_item_menu(layout, name, icon, func, argN, argN, "", false); +} + typedef struct MenuItemLevel { int opcontext; /* don't use pointers to the strings because python can dynamically diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index d941f429339..56f95cd929c 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -605,8 +605,8 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) txt = BKE_text_add(bmain, "Recent Reports"); /* convert entire list to a display string, and add this to the text-block - * - if commandline debug option enabled, show debug reports too - * - otherwise, up to info (which is what users normally see) + * - if commandline debug option enabled, show debug reports too + * - otherwise, up to info (which is what users normally see) */ str = BKE_reports_string(reports, (G.debug & G_DEBUG) ? RPT_DEBUG : RPT_INFO); @@ -936,7 +936,7 @@ static int edittranslation_exec(bContext *C, wmOperator *op) } /* Try to find a valid po file for current language... */ edittranslation_find_po_file(root, uilng, popath, FILE_MAX); -/* printf("po path: %s\n", popath);*/ + /* printf("po path: %s\n", popath); */ if (popath[0] == '\0') { BKE_reportf(op->reports, RPT_ERROR, "No valid po found for language '%s' under %s", uilng, root); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 744f6b3c4d0..20f38b91b98 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; @@ -2105,9 +2105,9 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) { if (data && data->state != PANEL_STATE_ANIMATION) { /* XXX: - * - the panel tabbing function call below (test_add_new_tabs()) has been commented out - * "It is too easy to do by accident when reordering panels, - * is very hard to control and use, and has no real benefit." - BillRey + * - the panel tabbing function call below (test_add_new_tabs()) has been commented out + * "It is too easy to do by accident when reordering panels, + * is very hard to control and use, and has no real benefit." - BillRey * Aligorith, 2009Sep */ //test_add_new_tabs(ar); // also copies locations of tabs in dragged panel diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index d9be0abfb78..f9fcf9520be 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -349,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: @@ -535,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) { @@ -553,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) { @@ -568,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) || @@ -626,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) @@ -658,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) @@ -688,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); @@ -749,7 +749,7 @@ static void ui_template_id( template_ui->idlb = which_libbase(CTX_data_main(C), idcode); /* create UI elements for this template - * - template_ID makes a copy of the template data and assigns it to the relevant buttons + * - template_ID makes a copy of the template data and assigns it to the relevant buttons */ if (template_ui->idlb) { uiLayoutRow(layout, true); @@ -1144,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) { @@ -2039,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( @@ -2598,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; @@ -2638,10 +2638,10 @@ void uiTemplateLayers( } /* the number of layers determines the way we group them - * - we want 2 rows only (for now) - * - the number of columns (cols) is the total number of buttons per row - * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be - * - for now, only split into groups if group will have at least 5 items + * - we want 2 rows only (for now) + * - the number of columns (cols) is the total number of buttons per row + * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be + * - for now, only split into groups if group will have at least 5 items */ layers = RNA_property_array_length(ptr, prop); cols = (layers / 2) + (layers % 2); @@ -2682,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; } } @@ -2707,10 +2707,10 @@ void uiTemplateGameStates( } /* the number of states determines the way we group them - * - we want 2 rows only (for now) - * - the number of columns (cols) is the total number of buttons per row - * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be - * - for now, only split into groups if group will have at least 5 items + * - we want 2 rows only (for now) + * - the number of columns (cols) is the total number of buttons per row + * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be + * - for now, only split into groups if group will have at least 5 items */ states = RNA_property_array_length(ptr, prop); cols = (states / 2) + (states % 2); @@ -2753,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; } } @@ -3670,7 +3670,7 @@ void uiTemplateOperatorPropertyButs( /* only for popups, see [#36109] */ /* if button is operator's default property, and a text-field, enable focus for it - * - this is used for allowing operators with popups to rename stuff with fewer clicks + * - this is used for allowing operators with popups to rename stuff with fewer clicks */ if (is_popup) { if ((but->rnaprop == op->type->prop) && (but->type == UI_BTYPE_TEXT)) { @@ -3876,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/view2d.c b/source/blender/editors/interface/view2d.c index 7db2d7f156f..622d47bae18 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -148,8 +148,8 @@ static void view2d_masks(View2D *v2d, bool check_scrollers) scroll = view2d_scroll_mapped(v2d->scroll); /* scrollers shrink mask area, but should be based off regionsize - * - they can only be on one to two edges of the region they define - * - if they overlap, they must not occupy the corners (which are reserved for other widgets) + * - they can only be on one to two edges of the region they define + * - if they overlap, they must not occupy the corners (which are reserved for other widgets) */ if (scroll) { /* vertical scroller */ @@ -387,16 +387,16 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas tot = &v2d->tot; /* we must satisfy the following constraints (in decreasing order of importance): - * - alignment restrictions are respected - * - cur must not fall outside of tot - * - axis locks (zoom and offset) must be maintained - * - zoom must not be excessive (check either sizes or zoom values) - * - aspect ratio should be respected (NOTE: this is quite closely related to zoom too) + * - alignment restrictions are respected + * - cur must not fall outside of tot + * - axis locks (zoom and offset) must be maintained + * - zoom must not be excessive (check either sizes or zoom values) + * - aspect ratio should be respected (NOTE: this is quite closely related to zoom too) */ /* Step 1: if keepzoom, adjust the sizes of the rects only - * - firstly, we calculate the sizes of the rects - * - curwidth and curheight are saved as reference... modify width and height values here + * - firstly, we calculate the sizes of the rects + * - curwidth and curheight are saved as reference... modify width and height values here */ totwidth = BLI_rctf_size_x(tot); totheight = BLI_rctf_size_y(tot); @@ -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; @@ -506,9 +506,9 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas if (do_cur) { if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) { /* special exception for Outliner (and later channel-lists): - * - The view may be moved left to avoid contents being pushed out of view when view shrinks. - * - The keeptot code will make sure cur->xmin will not be less than tot->xmin (which cannot be allowed) - * - width is not adjusted for changed ratios here... + * - The view may be moved left to avoid contents being pushed out of view when view shrinks. + * - The keeptot code will make sure cur->xmin will not be less than tot->xmin (which cannot be allowed) + * - width is not adjusted for changed ratios here... */ if (winx < v2d->oldwinx) { float temp = v2d->oldwinx - winx; @@ -529,7 +529,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas else { if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winy != v2d->oldwiny)) { /* special exception for Outliner (and later channel-lists): - * - Currently, no actions need to be taken here... + * - Currently, no actions need to be taken here... */ if (winy < v2d->oldwiny) { @@ -616,8 +616,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } else if (v2d->keeptot == V2D_KEEPTOT_STRICT) { /* This is an exception for the outliner (and later channel-lists, headers) - * - must clamp within tot rect (absolutely no excuses) - * --> therefore, cur->xmin must not be less than tot->xmin + * - must clamp within tot rect (absolutely no excuses) + * --> therefore, cur->xmin must not be less than tot->xmin */ if (cur->xmin < tot->xmin) { /* move cur across so that it sits at minimum of tot */ @@ -648,8 +648,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } else { /* This here occurs when: - * - width too big, but maintaining zoom (i.e. widths cannot be changed) - * - width is OK, but need to check if outside of boundaries + * - width too big, but maintaining zoom (i.e. widths cannot be changed) + * - width is OK, but need to check if outside of boundaries * * So, resolution is to just shift view by the gap between the extremities. * We favour moving the 'minimum' across, as that's origin for most things @@ -699,8 +699,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } else { /* This here occurs when: - * - height too big, but maintaining zoom (i.e. heights cannot be changed) - * - height is OK, but need to check if outside of boundaries + * - height too big, but maintaining zoom (i.e. heights cannot be changed) + * - height is OK, but need to check if outside of boundaries * * So, resolution is to just shift view by the gap between the extremities. * We favour moving the 'minimum' across, as that's origin for most things @@ -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 */ @@ -1561,8 +1561,8 @@ View2DScrollers *UI_view2d_scrollers_calc( scrollers->hor = hor; /* scroller 'buttons': - * - These should always remain within the visible region of the scrollbar - * - They represent the region of 'tot' that is visible in 'cur' + * - These should always remain within the visible region of the scrollbar + * - They represent the region of 'tot' that is visible in 'cur' */ /* horizontal scrollers */ @@ -1722,11 +1722,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v state = (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE) ? UI_SCROLL_PRESSED : 0; /* show zoom handles if: - * - zooming on x-axis is allowed (no scroll otherwise) - * - slider bubble is large enough (no overdraw confusion) - * - scale is shown on the scroller - * (workaround to make sure that button windows don't show these, - * and only the time-grids with their zoomability can do so) + * - zooming on x-axis is allowed (no scroll otherwise) + * - slider bubble is large enough (no overdraw confusion) + * - scale is shown on the scroller + * (workaround to make sure that button windows don't show these, + * and only the time-grids with their zoomability can do so) */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) && @@ -1750,8 +1750,8 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v float fac, dfac, fac2, val; /* the numbers: convert grid->startx and -dx to scroll coordinates - * - fac is x-coordinate to draw to - * - dfac is gap between scale markings + * - fac is x-coordinate to draw to + * - dfac is gap between scale markings */ fac = (grid->startx - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur); fac = (float)hor.xmin + fac * BLI_rcti_size_x(&hor); @@ -1823,11 +1823,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v state = (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE) ? UI_SCROLL_PRESSED : 0; /* show zoom handles if: - * - zooming on y-axis is allowed (no scroll otherwise) - * - slider bubble is large enough (no overdraw confusion) - * - scale is shown on the scroller - * (workaround to make sure that button windows don't show these, - * and only the time-grids with their zoomability can do so) + * - zooming on y-axis is allowed (no scroll otherwise) + * - slider bubble is large enough (no overdraw confusion) + * - scale is shown on the scroller + * (workaround to make sure that button windows don't show these, + * and only the time-grids with their zoomability can do so) */ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) && @@ -1852,10 +1852,10 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v float fac, dfac, val; /* the numbers: convert grid->starty and dy to scroll coordinates - * - fac is y-coordinate to draw to - * - dfac is gap between scale markings - * - these involve a correction for horizontal scrollbar - * NOTE: it's assumed that that scrollbar is there if this is involved! + * - fac is y-coordinate to draw to + * - dfac is gap between scale markings + * - these involve a correction for horizontal scrollbar + * NOTE: it's assumed that that scrollbar is there if this is involved! */ fac = (grid->starty - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur); fac = vert.ymin + fac * BLI_rcti_size_y(&vert); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index b9ea5d96057..e08f9535e1f 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1147,7 +1147,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event vzd->dy += dy; /* store mouse coordinates for next time, if not doing continuous zoom - * - continuous zoom only depends on distance of mouse to starting point to determine rate of change + * - continuous zoom only depends on distance of mouse to starting point to determine rate of change */ if (U.viewzoom != USER_ZOOM_CONT) { // XXX store this setting as RNA prop? vzd->lastx = event->x; @@ -1239,9 +1239,9 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) if (zoom_in) { /* zoom in: - * - 'cur' rect will be defined by the coordinates of the border region - * - just set the 'cur' rect to have the same coordinates as the border region - * if zoom is allowed to be changed + * - 'cur' rect will be defined by the coordinates of the border region + * - just set the 'cur' rect to have the same coordinates as the border region + * if zoom is allowed to be changed */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { cur_new.xmin = rect.xmin; @@ -1254,9 +1254,9 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) } else { /* zoom out: - * - the current 'cur' rect coordinates are going to end up where the 'rect' ones are, - * but the 'cur' rect coordinates will need to be adjusted to take in more of the view - * - calculate zoom factor, and adjust using center-point + * - the current 'cur' rect coordinates are going to end up where the 'rect' ones are, + * but the 'cur' rect coordinates will need to be adjusted to take in more of the view + * - calculate zoom factor, and adjust using center-point */ float zoom, center, size; @@ -1545,7 +1545,6 @@ static void VIEW2D_OT_smoothview(wmOperatorType *ot) { /* identifiers */ ot->name = "Smooth View 2D"; - ot->description = ""; ot->idname = "VIEW2D_OT_smoothview"; /* api callbacks */ @@ -1627,8 +1626,8 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ bool in_min, in_max, in_bar, out_min, out_max, in_view = 1; /* firstly, check if - * - 'bubble' fills entire scroller - * - 'bubble' completely out of view on either side + * - 'bubble' fills entire scroller + * - 'bubble' completely out of view on either side */ if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view = 0; if (sh_min == sh_max) { @@ -1691,7 +1690,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e vsm->lastx = event->x; vsm->lasty = event->y; /* 'zone' depends on where mouse is relative to bubble - * - zooming must be allowed on this axis, otherwise, default to pan + * - zooming must be allowed on this axis, otherwise, default to pan */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); |