Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | if (!((flag & PROP_ID_SELF_CHECK) && id == id_from)) { | ||||
| /* +1 is needed because name_uiprefix_id used 3 letter prefix | /* +1 is needed because name_uiprefix_id used 3 letter prefix | ||||
| * followed by ID_NAME-2 characters from id->name | * followed by ID_NAME-2 characters from id->name | ||||
| */ | */ | ||||
| char name_ui[MAX_ID_NAME + 1]; | char name_ui[MAX_ID_NAME + 1]; | ||||
| name_uiprefix_id(name_ui, id); | name_uiprefix_id(name_ui, id); | ||||
| iconid = ui_id_icon_get((bContext *)C, id, template->preview); | iconid = ui_id_icon_get((bContext *)C, id, template->preview); | ||||
| if (false == uiSearchItemAdd(items, name_ui, id, iconid)) | if (false == UI_search_item_add(items, name_ui, id, iconid)) | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* ID Search browse menu, open */ | /* ID Search browse menu, open */ | ||||
| static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) | static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) | ||||
| { | { | ||||
| static char search[256]; | static char search[256]; | ||||
| static TemplateID template; | static TemplateID template; | ||||
| PointerRNA idptr; | PointerRNA idptr; | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| /* clear initial search string, then all items show */ | /* clear initial search string, then all items show */ | ||||
| search[0] = 0; | search[0] = 0; | ||||
| /* arg_litem is malloced, can be freed by parent button */ | /* arg_litem is malloced, can be freed by parent button */ | ||||
| template = *((TemplateID *)arg_litem); | template = *((TemplateID *)arg_litem); | ||||
| /* get active id for showing first item */ | /* get active id for showing first item */ | ||||
| idptr = RNA_property_pointer_get(&template.ptr, template.prop); | idptr = RNA_property_pointer_get(&template.ptr, template.prop); | ||||
| block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); | block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); | ||||
| uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); | UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); | ||||
| /* preview thumbnails */ | /* preview thumbnails */ | ||||
| if (template.prv_rows > 0 && template.prv_cols > 0) { | if (template.prv_rows > 0 && template.prv_cols > 0) { | ||||
| int w = 4 * U.widget_unit * template.prv_cols; | int w = 4 * U.widget_unit * template.prv_cols; | ||||
| int h = 4 * U.widget_unit * template.prv_rows + U.widget_unit; | int h = 4 * U.widget_unit * template.prv_rows + U.widget_unit; | ||||
| /* fake button, it holds space for search items */ | /* fake button, it holds space for search items */ | ||||
| uiDefBut(block, LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, w, h, NULL, 0, 0, 0, 0, NULL); | ||||
| but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, UI_UNIT_Y, | but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, w, UI_UNIT_Y, | ||||
| template.prv_rows, template.prv_cols, ""); | template.prv_rows, template.prv_cols, ""); | ||||
| uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data); | UI_but_func_search_set(but, id_search_cb, &template, id_search_call_cb, idptr.data); | ||||
| } | } | ||||
| /* list view */ | /* list view */ | ||||
| else { | else { | ||||
| const int searchbox_width = uiSearchBoxWidth(); | const int searchbox_width = UI_searchbox_size_x(); | ||||
| const int searchbox_height = uiSearchBoxHeight(); | const int searchbox_height = UI_searchbox_size_y(); | ||||
| /* fake button, it holds space for search items */ | /* fake button, it holds space for search items */ | ||||
| uiDefBut(block, LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, searchbox_width, searchbox_height, NULL, 0, 0, 0, 0, NULL); | ||||
| but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, ""); | but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, searchbox_width, UI_UNIT_Y - 1, 0, 0, ""); | ||||
| uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb, idptr.data); | UI_but_func_search_set(but, id_search_cb, &template, id_search_call_cb, idptr.data); | ||||
| } | } | ||||
| uiBoundsBlock(block, 0.3f * U.widget_unit); | UI_block_bounds_set_normal(block, 0.3f * U.widget_unit); | ||||
| uiBlockSetDirection(block, UI_DOWN); | UI_block_direction_set(block, UI_DIR_DOWN); | ||||
| /* give search-field focus */ | /* give search-field focus */ | ||||
| uiButSetFocusOnEnter(win, but); | UI_but_focus_on_enter_event(win, but); | ||||
| /* this type of search menu requires undo */ | /* this type of search menu requires undo */ | ||||
| but->flag |= UI_BUT_UNDO; | but->flag |= UI_BUT_UNDO; | ||||
| return block; | return block; | ||||
| } | } | ||||
| /************************ ID Template ***************************/ | /************************ ID Template ***************************/ | ||||
| /* This is for browsing and editing the ID-blocks used */ | /* This is for browsing and editing the ID-blocks used */ | ||||
| /* for new/open operators */ | /* for new/open operators */ | ||||
| void uiIDContextProperty(bContext *C, PointerRNA *ptr, PropertyRNA **prop) | void UI_context_active_but_prop_get_templateID(bContext *C, PointerRNA *ptr, PropertyRNA **prop) | ||||
| { | { | ||||
| TemplateID *template; | TemplateID *template; | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| memset(ptr, 0, sizeof(*ptr)); | memset(ptr, 0, sizeof(*ptr)); | ||||
| *prop = NULL; | *prop = NULL; | ||||
| Show All 26 Lines | static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) | ||||
| switch (event) { | switch (event) { | ||||
| case UI_ID_BROWSE: | case UI_ID_BROWSE: | ||||
| case UI_ID_PIN: | case UI_ID_PIN: | ||||
| RNA_warning("warning, id event %d shouldnt come here", event); | RNA_warning("warning, id event %d shouldnt come here", event); | ||||
| break; | break; | ||||
| case UI_ID_OPEN: | case UI_ID_OPEN: | ||||
| case UI_ID_ADD_NEW: | case UI_ID_ADD_NEW: | ||||
| /* these call uiIDContextProperty */ | /* these call UI_context_active_but_prop_get_templateID */ | ||||
| break; | break; | ||||
| case UI_ID_DELETE: | case UI_ID_DELETE: | ||||
| memset(&idptr, 0, sizeof(idptr)); | memset(&idptr, 0, sizeof(idptr)); | ||||
| RNA_property_pointer_set(&template->ptr, template->prop, idptr); | RNA_property_pointer_set(&template->ptr, template->prop, idptr); | ||||
| RNA_property_update(C, &template->ptr, template->prop); | RNA_property_update(C, &template->ptr, template->prop); | ||||
| if (id && CTX_wm_window(C)->eventstate->shift) /* useful hidden functionality, */ | if (id && CTX_wm_window(C)->eventstate->shift) /* useful hidden functionality, */ | ||||
| id->us = 0; | id->us = 0; | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, short idcode, int flag, | ||||
| const bool editable = RNA_property_editable(&template->ptr, template->prop); | const bool editable = RNA_property_editable(&template->ptr, template->prop); | ||||
| idptr = RNA_property_pointer_get(&template->ptr, template->prop); | idptr = RNA_property_pointer_get(&template->ptr, template->prop); | ||||
| id = idptr.data; | id = idptr.data; | ||||
| idfrom = template->ptr.id.data; | idfrom = template->ptr.id.data; | ||||
| // lb = template->idlb; | // lb = template->idlb; | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| if (idptr.type) | if (idptr.type) | ||||
| type = idptr.type; | type = idptr.type; | ||||
| if (flag & UI_ID_PREVIEWS) { | if (flag & UI_ID_PREVIEWS) { | ||||
| template->preview = true; | template->preview = true; | ||||
| but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, | but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, | ||||
| TIP_(template_id_browse_tip(type))); | TIP_(template_id_browse_tip(type))); | ||||
| but->icon = id ? ui_id_icon_get(C, id, true) : RNA_struct_ui_icon(type); | but->icon = id ? ui_id_icon_get(C, id, true) : RNA_struct_ui_icon(type); | ||||
| uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW); | UI_but_flag_enable(but, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); | ||||
| if ((idfrom && idfrom->lib) || !editable) | if ((idfrom && idfrom->lib) || !editable) | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| uiLayoutRow(layout, true); | uiLayoutRow(layout, true); | ||||
| } | } | ||||
| else if (flag & UI_ID_BROWSE) { | else if (flag & UI_ID_BROWSE) { | ||||
| but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 1.6, UI_UNIT_Y, | but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 1.6, UI_UNIT_Y, | ||||
| TIP_(template_id_browse_tip(type))); | TIP_(template_id_browse_tip(type))); | ||||
| but->icon = RNA_struct_ui_icon(type); | but->icon = RNA_struct_ui_icon(type); | ||||
| /* default dragging of icon for id browse buttons */ | /* default dragging of icon for id browse buttons */ | ||||
| uiButSetDragID(but, id); | UI_but_drag_set_id(but, id); | ||||
| uiButSetFlag(but, UI_HAS_ICON); | UI_but_flag_enable(but, UI_HAS_ICON); | ||||
| uiButSetDrawFlag(but, UI_BUT_ICON_LEFT); | UI_but_drawflag_enable(but, UI_BUT_ICON_LEFT); | ||||
| if ((idfrom && idfrom->lib) || !editable) | if ((idfrom && idfrom->lib) || !editable) | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| /* text button with name */ | /* text button with name */ | ||||
| if (id) { | if (id) { | ||||
| char name[UI_MAX_NAME_STR]; | char name[UI_MAX_NAME_STR]; | ||||
| const bool user_alert = (id->us <= 0); | const bool user_alert = (id->us <= 0); | ||||
| //text_idbutton(id, name); | //text_idbutton(id, name); | ||||
| name[0] = '\0'; | name[0] = '\0'; | ||||
| but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, | 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)); | &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type)); | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME)); | ||||
| if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT); | if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT); | ||||
| if (id->lib) { | if (id->lib) { | ||||
| if (id->flag & LIB_INDIRECT) { | if (id->flag & LIB_INDIRECT) { | ||||
| but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| NULL, 0, 0, 0, 0, TIP_("Indirect library datablock, cannot change")); | NULL, 0, 0, 0, 0, TIP_("Indirect library datablock, cannot change")); | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| NULL, 0, 0, 0, 0, TIP_("Direct linked library datablock, click to make local")); | NULL, 0, 0, 0, 0, TIP_("Direct linked library datablock, click to make local")); | ||||
| if (!id_make_local(id, true /* test */) || (idfrom && idfrom->lib)) | if (!id_make_local(id, true /* test */) || (idfrom && idfrom->lib)) | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_LOCAL)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_LOCAL)); | ||||
| } | } | ||||
| if (id->us > 1) { | if (id->us > 1) { | ||||
| char numstr[32]; | char numstr[32]; | ||||
| BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); | BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); | ||||
| but = uiDefBut(block, BUT, 0, numstr, 0, 0, UI_UNIT_X + ((id->us < 10) ? 0 : 10), UI_UNIT_Y, | but = uiDefBut(block, UI_BTYPE_BUT, 0, numstr, 0, 0, UI_UNIT_X + ((id->us < 10) ? 0 : 10), UI_UNIT_Y, | ||||
| NULL, 0, 0, 0, 0, | NULL, 0, 0, 0, 0, | ||||
| TIP_("Display number of users of this data (click to make a single-user copy)")); | TIP_("Display number of users of this data (click to make a single-user copy)")); | ||||
| but->flag |= UI_BUT_UNDO; | but->flag |= UI_BUT_UNDO; | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); | ||||
| if (/* test only */ | if (/* test only */ | ||||
| (id_copy(id, NULL, true) == false) || | (id_copy(id, NULL, true) == false) || | ||||
| (idfrom && idfrom->lib) || | (idfrom && idfrom->lib) || | ||||
| (!editable) || | (!editable) || | ||||
| /* object in editmode - don't change data */ | /* object in editmode - don't change data */ | ||||
| (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT))) | (idfrom && GS(idfrom->name) == ID_OB && (((Object *)idfrom)->mode & OB_MODE_EDIT))) | ||||
| { | { | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| } | } | ||||
| if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT); | if (user_alert) UI_but_flag_enable(but, UI_BUT_REDALERT); | ||||
| if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB))) { | if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB))) { | ||||
| uiDefButR(block, TOG, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL); | uiDefButR(block, UI_BTYPE_TOGGLE, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL); | ||||
| } | } | ||||
| } | } | ||||
| if (flag & UI_ID_ADD_NEW) { | if (flag & UI_ID_ADD_NEW) { | ||||
| int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6; | int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6; | ||||
| /* i18n markup, does nothing! */ | /* i18n markup, does nothing! */ | ||||
| BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_DEFAULT, | BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_DEFAULT, | ||||
| Show All 19 Lines | BLF_I18N_MSGID_MULTI_CTXT("New", BLF_I18NCONTEXT_ID_SPEAKER, | ||||
| BLF_I18NCONTEXT_ID_NODETREE, | BLF_I18NCONTEXT_ID_NODETREE, | ||||
| BLF_I18NCONTEXT_ID_BRUSH, | BLF_I18NCONTEXT_ID_BRUSH, | ||||
| BLF_I18NCONTEXT_ID_PARTICLESETTINGS, | BLF_I18NCONTEXT_ID_PARTICLESETTINGS, | ||||
| BLF_I18NCONTEXT_ID_GPENCIL, | BLF_I18NCONTEXT_ID_GPENCIL, | ||||
| BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE, | BLF_I18NCONTEXT_ID_FREESTYLELINESTYLE, | ||||
| ); | ); | ||||
| if (newop) { | if (newop) { | ||||
| but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, | 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); | (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), 0, 0, w, UI_UNIT_Y, NULL); | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (id) ? "" : CTX_IFACE_(template_id_context(type), "New"), | 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); | 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); | ||||
| } | } | ||||
| if ((idfrom && idfrom->lib) || !editable) | if ((idfrom && idfrom->lib) || !editable) | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| /* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack. | /* Due to space limit in UI - skip the "open" icon for packed data, and allow to unpack. | ||||
| * Only for images, sound and fonts */ | * Only for images, sound and fonts */ | ||||
| if (id && BKE_pack_check(id)) { | if (id && BKE_pack_check(id)) { | ||||
| but = uiDefIconButO(block, BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0, | but = uiDefIconButO(block, UI_BTYPE_BUT, "FILE_OT_unpack_item", WM_OP_INVOKE_REGION_WIN, ICON_PACKAGE, 0, 0, | ||||
| UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack")); | UI_UNIT_X, UI_UNIT_Y, TIP_("Packed File, click to unpack")); | ||||
| uiButGetOperatorPtrRNA(but); | UI_but_operator_ptr_get(but); | ||||
| RNA_string_set(but->opptr, "id_name", id->name + 2); | RNA_string_set(but->opptr, "id_name", id->name + 2); | ||||
| RNA_int_set(but->opptr, "id_type", GS(id->name)); | RNA_int_set(but->opptr, "id_type", GS(id->name)); | ||||
| } | } | ||||
| else if (flag & UI_ID_OPEN) { | else if (flag & UI_ID_OPEN) { | ||||
| int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6; | int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6; | ||||
| if (openop) { | if (openop) { | ||||
| but = uiDefIconTextButO(block, BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), | but = uiDefIconTextButO(block, UI_BTYPE_BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), | ||||
| 0, 0, w, UI_UNIT_Y, NULL); | 0, 0, w, UI_UNIT_Y, NULL); | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefIconTextBut(block, BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, | but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, | ||||
| NULL, 0, 0, 0, 0, NULL); | NULL, 0, 0, 0, 0, NULL); | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); | ||||
| } | } | ||||
| if ((idfrom && idfrom->lib) || !editable) | if ((idfrom && idfrom->lib) || !editable) | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| /* delete button */ | /* delete button */ | ||||
| /* don't use RNA_property_is_unlink here */ | /* don't use RNA_property_is_unlink here */ | ||||
| if (id && (flag & UI_ID_DELETE)) { | if (id && (flag & UI_ID_DELETE)) { | ||||
| /* allow unlink if 'unlinkop' is passed, even when 'PROP_NEVER_UNLINK' is set */ | /* allow unlink if 'unlinkop' is passed, even when 'PROP_NEVER_UNLINK' is set */ | ||||
| but = NULL; | but = NULL; | ||||
| if (unlinkop) { | if (unlinkop) { | ||||
| but = uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | but = uiDefIconButO(block, UI_BTYPE_BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | ||||
| /* so we can access the template from operators, font unlinking needs this */ | /* so we can access the template from operators, font unlinking needs this */ | ||||
| uiButSetNFunc(but, NULL, MEM_dupallocN(template), NULL); | UI_but_funcN_set(but, NULL, MEM_dupallocN(template), NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| if ((RNA_property_flag(template->prop) & PROP_NEVER_UNLINK) == 0) { | if ((RNA_property_flag(template->prop) & PROP_NEVER_UNLINK) == 0) { | ||||
| but = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, | but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, | ||||
| TIP_("Unlink datablock " | TIP_("Unlink datablock " | ||||
| "(Shift + Click to set users to zero, data will then not be saved)")); | "(Shift + Click to set users to zero, data will then not be saved)")); | ||||
| uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); | UI_but_funcN_set(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); | ||||
| if (RNA_property_flag(template->prop) & PROP_NEVER_NULL) { | if (RNA_property_flag(template->prop) & PROP_NEVER_NULL) { | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (but) { | if (but) { | ||||
| if ((idfrom && idfrom->lib) || !editable) { | if ((idfrom && idfrom->lib) || !editable) { | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (idcode == ID_TE) | if (idcode == ID_TE) | ||||
| uiTemplateTextureShow(layout, C, &template->ptr, template->prop); | uiTemplateTextureShow(layout, C, &template->ptr, template->prop); | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| } | } | ||||
| static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, | static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, | ||||
| const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols) | const char *openop, const char *unlinkop, int flag, int prv_rows, int prv_cols) | ||||
| { | { | ||||
| TemplateID *template; | TemplateID *template; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| StructRNA *type; | StructRNA *type; | ||||
| ▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, | ||||
| if (isVirtual) { | if (isVirtual) { | ||||
| row = uiLayoutRow(box, false); | row = uiLayoutRow(box, false); | ||||
| uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); | uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); | ||||
| block = uiLayoutGetBlock(row); | block = uiLayoutGetBlock(row); | ||||
| /* VIRTUAL MODIFIER */ | /* VIRTUAL MODIFIER */ | ||||
| /* XXX this is not used now, since these cannot be accessed via RNA */ | /* XXX this is not used now, since these cannot be accessed via RNA */ | ||||
| BLI_snprintf(str, sizeof(str), IFACE_("%s parent deform"), md->name); | BLI_snprintf(str, sizeof(str), IFACE_("%s parent deform"), md->name); | ||||
| uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Modifier name")); | uiDefBut(block, UI_BTYPE_LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Modifier name")); | ||||
| but = uiDefBut(block, BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, | but = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, | ||||
| TIP_("Convert virtual modifier to a real modifier")); | TIP_("Convert virtual modifier to a real modifier")); | ||||
| uiButSetFunc(but, modifiers_convertToReal, ob, md); | UI_but_func_set(but, modifiers_convertToReal, ob, md); | ||||
| } | } | ||||
| else { | else { | ||||
| /* REAL MODIFIER */ | /* REAL MODIFIER */ | ||||
| row = uiLayoutRow(box, false); | row = uiLayoutRow(box, false); | ||||
| block = uiLayoutGetBlock(row); | block = uiLayoutGetBlock(row); | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| /* Open/Close ................................. */ | /* Open/Close ................................. */ | ||||
| uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE); | uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE); | ||||
| /* modifier-type icon */ | /* modifier-type icon */ | ||||
| uiItemL(row, "", RNA_struct_ui_icon(ptr.type)); | uiItemL(row, "", RNA_struct_ui_icon(ptr.type)); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| /* modifier name */ | /* modifier name */ | ||||
| md->scene = scene; | md->scene = scene; | ||||
| if (mti->isDisabled && mti->isDisabled(md, 0)) { | if (mti->isDisabled && mti->isDisabled(md, 0)) { | ||||
| uiLayoutSetRedAlert(row, true); | uiLayoutSetRedAlert(row, true); | ||||
| } | } | ||||
| uiItemR(row, &ptr, "name", 0, "", ICON_NONE); | uiItemR(row, &ptr, "name", 0, "", ICON_NONE); | ||||
| uiLayoutSetRedAlert(row, false); | uiLayoutSetRedAlert(row, false); | ||||
| /* mode enabling buttons */ | /* mode enabling buttons */ | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| /* Softbody not allowed in this situation, enforce! */ | /* Softbody not allowed in this situation, enforce! */ | ||||
| if (((md->type != eModifierType_Softbody && md->type != eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && | if (((md->type != eModifierType_Softbody && md->type != eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && | ||||
| (md->type != eModifierType_Surface) ) | (md->type != eModifierType_Surface) ) | ||||
| { | { | ||||
| uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE); | uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE); | ||||
| uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE); | uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE); | ||||
| if (mti->flags & eModifierTypeFlag_SupportsEditmode) { | if (mti->flags & eModifierTypeFlag_SupportsEditmode) { | ||||
| Show All 14 Lines | if (ob->type == OB_MESH) { | ||||
| uiItemR(sub, &ptr, "show_on_cage", 0, "", ICON_NONE); | uiItemR(sub, &ptr, "show_on_cage", 0, "", ICON_NONE); | ||||
| } | } | ||||
| } /* tessellation point for curve-typed objects */ | } /* tessellation point for curve-typed objects */ | ||||
| else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { | else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { | ||||
| /* some modifiers could work with pre-tessellated curves only */ | /* some modifiers could work with pre-tessellated curves only */ | ||||
| if (ELEM(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { | if (ELEM(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { | ||||
| /* add disabled pre-tessellated button, so users could have | /* add disabled pre-tessellated button, so users could have | ||||
| * message for this modifiers */ | * message for this modifiers */ | ||||
| but = uiDefIconButBitI(block, TOG, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, | but = uiDefIconButBitI(block, UI_BTYPE_TOGGLE, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, | ||||
| UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, | UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, | ||||
| TIP_("This modifier can only be applied on splines' points")); | TIP_("This modifier can only be applied on splines' points")); | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| } | } | ||||
| else if (mti->type != eModifierTypeType_Constructive) { | else if (mti->type != eModifierTypeType_Constructive) { | ||||
| /* constructive modifiers tessellates curve before applying */ | /* constructive modifiers tessellates curve before applying */ | ||||
| uiItemR(row, &ptr, "use_apply_on_spline", 0, "", ICON_NONE); | uiItemR(row, &ptr, "use_apply_on_spline", 0, "", ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| /* Up/Down + Delete ........................... */ | /* Up/Down + Delete ........................... */ | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_modifier_move_up"); | uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_modifier_move_up"); | ||||
| uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_modifier_move_down"); | uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_modifier_move_down"); | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| /* When Modifier is a simulation, show button to switch to context rather than the delete button. */ | /* When Modifier is a simulation, show button to switch to context rather than the delete button. */ | ||||
| if (modifier_can_delete(md) && | if (modifier_can_delete(md) && | ||||
| (!modifier_is_simulation(md) || | (!modifier_is_simulation(md) || | ||||
| STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME))) | STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME))) | ||||
| { | { | ||||
| uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove"); | uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove"); | ||||
| } | } | ||||
| else if (modifier_is_simulation(md) == 1) { | else if (modifier_is_simulation(md) == 1) { | ||||
| uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PHYSICS"); | uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PHYSICS"); | ||||
| } | } | ||||
| else if (modifier_is_simulation(md) == 2) { | else if (modifier_is_simulation(md) == 2) { | ||||
| uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PARTICLES"); | uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PARTICLES"); | ||||
| } | } | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| } | } | ||||
| /* modifier settings (under the header) --------------------------------------------------- */ | /* modifier settings (under the header) --------------------------------------------------- */ | ||||
| if (!isVirtual && (md->mode & eModifierMode_Expanded)) { | if (!isVirtual && (md->mode & eModifierMode_Expanded)) { | ||||
| /* apply/convert/copy */ | /* apply/convert/copy */ | ||||
| box = uiLayoutBox(column); | box = uiLayoutBox(column); | ||||
| row = uiLayoutRow(box, false); | row = uiLayoutRow(box, false); | ||||
| if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { | if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { | ||||
| /* only here obdata, the rest of modifiers is ob level */ | /* only here obdata, the rest of modifiers is ob level */ | ||||
| uiBlockSetButLock(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE); | UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE); | ||||
| if (md->type == eModifierType_ParticleSystem) { | if (md->type == eModifierType_ParticleSystem) { | ||||
| ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; | ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; | ||||
| if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { | if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { | ||||
| if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB)) | if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB)) | ||||
| uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE, | uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Convert"), ICON_NONE, | ||||
| "OBJECT_OT_duplicates_make_real"); | "OBJECT_OT_duplicates_make_real"); | ||||
| Show All 9 Lines | if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { | ||||
| if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) { | if (modifier_isSameTopology(md) && !modifier_isNonGeometrical(md)) { | ||||
| uiItemEnumO(row, "OBJECT_OT_modifier_apply", | uiItemEnumO(row, "OBJECT_OT_modifier_apply", | ||||
| CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"), | CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Apply as Shape Key"), | ||||
| 0, "apply_as", MODIFIER_APPLY_SHAPE); | 0, "apply_as", MODIFIER_APPLY_SHAPE); | ||||
| } | } | ||||
| } | } | ||||
| uiBlockClearButLock(block); | UI_block_lock_clear(block); | ||||
| uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE); | UI_block_lock_set(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE); | ||||
| if (!ELEM(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, | if (!ELEM(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, | ||||
| eModifierType_Cloth, eModifierType_Smoke)) | eModifierType_Cloth, eModifierType_Smoke)) | ||||
| { | { | ||||
| uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"), ICON_NONE, | uiItemO(row, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"), ICON_NONE, | ||||
| "OBJECT_OT_modifier_copy"); | "OBJECT_OT_modifier_copy"); | ||||
| } | } | ||||
| } | } | ||||
| Show All 30 Lines | uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) | ||||
| ob = ptr->id.data; | ob = ptr->id.data; | ||||
| md = ptr->data; | md = ptr->data; | ||||
| if (!ob || !(GS(ob->id.name) == ID_OB)) { | if (!ob || !(GS(ob->id.name) == ID_OB)) { | ||||
| RNA_warning("Expected modifier on object"); | RNA_warning("Expected modifier on object"); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); | UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); | ||||
| /* find modifier and draw it */ | /* find modifier and draw it */ | ||||
| cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0); | cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0); | ||||
| /* XXX virtual modifiers are not accesible for python */ | /* XXX virtual modifiers are not accesible for python */ | ||||
| vmd = modifiers_getVirtualModifierList(ob, &virtualModifierData); | vmd = modifiers_getVirtualModifierList(ob, &virtualModifierData); | ||||
| for (i = 0; vmd; i++, vmd = vmd->next) { | for (i = 0; vmd; i++, vmd = vmd->next) { | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) | ||||
| /* determine whether constraint is proxy protected or not */ | /* determine whether constraint is proxy protected or not */ | ||||
| if (BKE_constraints_proxylocked_owner(ob, pchan)) | if (BKE_constraints_proxylocked_owner(ob, pchan)) | ||||
| proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0; | proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0; | ||||
| else | else | ||||
| proxy_protected = 0; | proxy_protected = 0; | ||||
| /* unless button has own callback, it adds this callback to button */ | /* unless button has own callback, it adds this callback to button */ | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| uiBlockSetHandleFunc(block, do_constraint_panels, ob); | UI_block_func_handle_set(block, do_constraint_panels, ob); | ||||
| uiBlockSetFunc(block, constraint_active_func, ob, con); | UI_block_func_set(block, constraint_active_func, ob, con); | ||||
| RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr); | RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr); | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| uiLayoutSetContextPointer(col, "constraint", &ptr); | uiLayoutSetContextPointer(col, "constraint", &ptr); | ||||
| box = uiLayoutBox(col); | box = uiLayoutBox(col); | ||||
| row = uiLayoutRow(box, false); | row = uiLayoutRow(box, false); | ||||
| block = uiLayoutGetBlock(box); | block = uiLayoutGetBlock(box); | ||||
| /* Draw constraint header */ | /* Draw constraint header */ | ||||
| /* open/close */ | /* open/close */ | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| uiItemR(row, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); | uiItemR(row, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| /* name */ | /* name */ | ||||
| uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, | uiDefBut(block, UI_BTYPE_LABEL, B_CONSTRAINT_TEST, typestr, | ||||
| xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, ""); | xco + 0.5f * UI_UNIT_X, yco, 5 * UI_UNIT_X, 0.9f * UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, ""); | ||||
| if (con->flag & CONSTRAINT_DISABLE) | if (con->flag & CONSTRAINT_DISABLE) | ||||
| uiLayoutSetRedAlert(row, true); | uiLayoutSetRedAlert(row, true); | ||||
| if (proxy_protected == 0) { | if (proxy_protected == 0) { | ||||
| uiItemR(row, &ptr, "name", 0, "", ICON_NONE); | uiItemR(row, &ptr, "name", 0, "", ICON_NONE); | ||||
| } | } | ||||
| else | else | ||||
| uiItemL(row, con->name, ICON_NONE); | uiItemL(row, con->name, ICON_NONE); | ||||
| uiLayoutSetRedAlert(row, false); | uiLayoutSetRedAlert(row, false); | ||||
| /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */ | /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */ | ||||
| if (proxy_protected) { | if (proxy_protected) { | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| /* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */ | /* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */ | ||||
| uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y, | uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 12.2f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y, | ||||
| NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); | NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); | ||||
| uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y, | uiDefIconBut(block, UI_BTYPE_BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 13.1f * UI_UNIT_X, yco, 0.95f * UI_UNIT_X, 0.95f * UI_UNIT_Y, | ||||
| NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); | NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected")); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| } | } | ||||
| else { | else { | ||||
| short prev_proxylock, show_upbut, show_downbut; | short prev_proxylock, show_upbut, show_downbut; | ||||
| /* Up/Down buttons: | /* Up/Down buttons: | ||||
| * Proxy-constraints are not allowed to occur after local (non-proxy) constraints | * 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 | * as that poses problems when restoring them, so disable the "up" button where | ||||
| * it may cause this situation. | * it may cause this situation. | ||||
| Show All 9 Lines | else { | ||||
| } | } | ||||
| else | else | ||||
| prev_proxylock = 0; | prev_proxylock = 0; | ||||
| show_upbut = ((prev_proxylock == 0) && (con->prev)); | show_upbut = ((prev_proxylock == 0) && (con->prev)); | ||||
| show_downbut = (con->next) ? 1 : 0; | show_downbut = (con->next) ? 1 : 0; | ||||
| /* enabled */ | /* enabled */ | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| uiItemR(row, &ptr, "mute", 0, "", | uiItemR(row, &ptr, "mute", 0, "", | ||||
| (con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF); | (con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT); | uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT); | ||||
| /* up/down */ | /* up/down */ | ||||
| if (show_upbut || show_downbut) { | if (show_upbut || show_downbut) { | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| if (show_upbut) | if (show_upbut) | ||||
| uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up"); | uiItemO(row, "", ICON_TRIA_UP, "CONSTRAINT_OT_move_up"); | ||||
| if (show_downbut) | if (show_downbut) | ||||
| uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down"); | uiItemO(row, "", ICON_TRIA_DOWN, "CONSTRAINT_OT_move_down"); | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| } | } | ||||
| /* Close 'button' - emboss calls here disable drawing of 'button' behind X */ | /* Close 'button' - emboss calls here disable drawing of 'button' behind X */ | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| uiItemO(row, "", ICON_X, "CONSTRAINT_OT_delete"); | uiItemO(row, "", ICON_X, "CONSTRAINT_OT_delete"); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| } | } | ||||
| /* Set but-locks for protected settings (magic numbers are used here!) */ | /* Set but-locks for protected settings (magic numbers are used here!) */ | ||||
| if (proxy_protected) | if (proxy_protected) | ||||
| uiBlockSetButLock(block, true, IFACE_("Cannot edit Proxy-Protected Constraint")); | UI_block_lock_set(block, true, IFACE_("Cannot edit Proxy-Protected Constraint")); | ||||
| /* Draw constraint data */ | /* Draw constraint data */ | ||||
| if ((con->flag & CONSTRAINT_EXPAND) == 0) { | if ((con->flag & CONSTRAINT_EXPAND) == 0) { | ||||
| (yco) -= 10.5f * UI_UNIT_Y; | (yco) -= 10.5f * UI_UNIT_Y; | ||||
| } | } | ||||
| else { | else { | ||||
| box = uiLayoutBox(col); | box = uiLayoutBox(col); | ||||
| block = uiLayoutAbsoluteBlock(box); | block = uiLayoutAbsoluteBlock(box); | ||||
| result = box; | result = box; | ||||
| } | } | ||||
| /* clear any locks set up for proxies/lib-linking */ | /* clear any locks set up for proxies/lib-linking */ | ||||
| uiBlockClearButLock(block); | UI_block_lock_clear(block); | ||||
| return result; | return result; | ||||
| } | } | ||||
| uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) | uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) | ||||
| { | { | ||||
| Object *ob; | Object *ob; | ||||
| bConstraint *con; | bConstraint *con; | ||||
| /* verify we have valid data */ | /* verify we have valid data */ | ||||
| if (!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { | if (!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { | ||||
| RNA_warning("Expected constraint on object"); | RNA_warning("Expected constraint on object"); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| ob = ptr->id.data; | ob = ptr->id.data; | ||||
| con = ptr->data; | con = ptr->data; | ||||
| if (!ob || !(GS(ob->id.name) == ID_OB)) { | if (!ob || !(GS(ob->id.name) == ID_OB)) { | ||||
| RNA_warning("Expected constraint on object"); | RNA_warning("Expected constraint on object"); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); | UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); | ||||
| /* hrms, the temporal constraint should not draw! */ | /* hrms, the temporal constraint should not draw! */ | ||||
| if (con->type == CONSTRAINT_TYPE_KINEMATIC) { | if (con->type == CONSTRAINT_TYPE_KINEMATIC) { | ||||
| bKinematicConstraint *data = con->data; | bKinematicConstraint *data = con->data; | ||||
| if (data->flag & CONSTRAINT_IK_TEMP) | if (data->flag & CONSTRAINT_IK_TEMP) | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | void uiTemplatePreview(uiLayout *layout, bContext *C, ID *id, int show_buttons, ID *parent, MTex *slot, | ||||
| /* layout */ | /* layout */ | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| col = uiLayoutColumn(row, false); | col = uiLayoutColumn(row, false); | ||||
| uiLayoutSetKeepAspect(col, true); | uiLayoutSetKeepAspect(col, true); | ||||
| /* add preview */ | /* add preview */ | ||||
| uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X * 10, ui_preview->height, pid, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_EXTRA, 0, "", 0, 0, UI_UNIT_X * 10, ui_preview->height, pid, 0.0, 0.0, 0, 0, ""); | ||||
| uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent, slot); | UI_but_func_drawextra_set(block, ED_preview_draw, pparent, slot); | ||||
| uiBlockSetHandleFunc(block, do_preview_buttons, NULL); | UI_block_func_handle_set(block, do_preview_buttons, NULL); | ||||
| uiDefIconButS(block, GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &ui_preview->height, | uiDefIconButS(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &ui_preview->height, | ||||
| UI_UNIT_Y, UI_UNIT_Y * 50.0f, 0.0f, 0.0f, ""); | UI_UNIT_Y, UI_UNIT_Y * 50.0f, 0.0f, 0.0f, ""); | ||||
| /* add buttons */ | /* add buttons */ | ||||
| if (pid && show_buttons) { | if (pid && show_buttons) { | ||||
| if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) { | if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) { | ||||
| if (GS(pid->name) == ID_MA) ma = (Material *)pid; | if (GS(pid->name) == ID_MA) ma = (Material *)pid; | ||||
| else ma = (Material *)pparent; | else ma = (Material *)pparent; | ||||
| /* Create RNA Pointer */ | /* Create RNA Pointer */ | ||||
| RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr); | RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr); | ||||
| col = uiLayoutColumn(row, true); | col = uiLayoutColumn(row, true); | ||||
| uiLayoutSetScaleX(col, 1.5); | uiLayoutSetScaleX(col, 1.5); | ||||
| uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", ICON_NONE); | uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", ICON_NONE); | ||||
| } | } | ||||
| if (pr_texture) { | if (pr_texture) { | ||||
| /* Create RNA Pointer */ | /* Create RNA Pointer */ | ||||
| RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); | RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); | ||||
| uiLayoutRow(layout, true); | uiLayoutRow(layout, true); | ||||
| uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); | pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); | ||||
| if (GS(parent->name) == ID_MA) { | if (GS(parent->name) == ID_MA) { | ||||
| uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | ||||
| } | } | ||||
| else if (GS(parent->name) == ID_LA) { | else if (GS(parent->name) == ID_LA) { | ||||
| uiDefButS(block, ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | ||||
| } | } | ||||
| else if (GS(parent->name) == ID_WO) { | else if (GS(parent->name) == ID_WO) { | ||||
| uiDefButS(block, ROW, B_MATPRV, IFACE_("World"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("World"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | ||||
| } | } | ||||
| else if (GS(parent->name) == ID_LS) { | else if (GS(parent->name) == ID_LS) { | ||||
| uiDefButS(block, ROW, B_MATPRV, IFACE_("Line Style"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Line Style"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); | ||||
| } | } | ||||
| uiDefButS(block, ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButS(block, UI_BTYPE_ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| pr_texture, 10, TEX_PR_BOTH, 0, 0, ""); | pr_texture, 10, TEX_PR_BOTH, 0, 0, ""); | ||||
| /* Alpha button for texture preview */ | /* Alpha button for texture preview */ | ||||
| if (*pr_texture != TEX_PR_OTHER) { | if (*pr_texture != TEX_PR_OTHER) { | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE); | uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, const rctf *butr, | ||||
| float xs = butr->xmin; | float xs = butr->xmin; | ||||
| float ys = butr->ymin; | float ys = butr->ymin; | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRamp, coba, &ptr); | RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRamp, coba, &ptr); | ||||
| split = uiLayoutSplit(layout, 0.4f, false); | split = uiLayoutSplit(layout, 0.4f, false); | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| row = uiLayoutRow(split, false); | row = uiLayoutRow(split, false); | ||||
| bt = uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, "", 0, 0, 2.0f * unit, UI_UNIT_Y, NULL, | bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, "", 0, 0, 2.0f * unit, UI_UNIT_Y, NULL, | ||||
| 0, 0, 0, 0, TIP_("Add a new color stop to the colorband")); | 0, 0, 0, 0, TIP_("Add a new color stop to the colorband")); | ||||
| uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba); | UI_but_funcN_set(bt, colorband_add_cb, MEM_dupallocN(cb), coba); | ||||
| bt = uiDefIconTextBut(block, BUT, 0, ICON_ZOOMOUT, "", xs + 2.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, | bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMOUT, "", xs + 2.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, | ||||
| NULL, 0, 0, 0, 0, TIP_("Delete the active position")); | NULL, 0, 0, 0, 0, TIP_("Delete the active position")); | ||||
| uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba); | UI_but_funcN_set(bt, colorband_del_cb, MEM_dupallocN(cb), coba); | ||||
| bt = uiDefIconTextBut(block, BUT, 0, ICON_ARROW_LEFTRIGHT, "", xs + 4.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, | bt = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_ARROW_LEFTRIGHT, "", xs + 4.0f * unit, ys + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, | ||||
| NULL, 0, 0, 0, 0, TIP_("Flip the color ramp")); | NULL, 0, 0, 0, 0, TIP_("Flip the color ramp")); | ||||
| uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba); | UI_but_funcN_set(bt, colorband_flip_cb, MEM_dupallocN(cb), coba); | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| row = uiLayoutRow(split, false); | row = uiLayoutRow(split, false); | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| uiItemR(row, &ptr, "color_mode", 0, "", ICON_NONE); | uiItemR(row, &ptr, "color_mode", 0, "", ICON_NONE); | ||||
| if (ELEM(coba->color_mode, COLBAND_BLEND_HSV, COLBAND_BLEND_HSL)) { | if (ELEM(coba->color_mode, COLBAND_BLEND_HSV, COLBAND_BLEND_HSL)) { | ||||
| uiItemR(row, &ptr, "hue_interpolation", 0, "", ICON_NONE); | uiItemR(row, &ptr, "hue_interpolation", 0, "", ICON_NONE); | ||||
| } | } | ||||
| else { /* COLBAND_BLEND_RGB */ | else { /* COLBAND_BLEND_RGB */ | ||||
| uiItemR(row, &ptr, "interpolation", 0, "", ICON_NONE); | uiItemR(row, &ptr, "interpolation", 0, "", ICON_NONE); | ||||
| } | } | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, ys, BLI_rctf_size_x(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, ""); | bt = uiDefBut(block, UI_BTYPE_COLORBAND, 0, "", xs, ys, BLI_rctf_size_x(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, ""); | ||||
| uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| if (coba->tot) { | if (coba->tot) { | ||||
| CBData *cbd = coba->data + coba->cur; | CBData *cbd = coba->data + coba->cur; | ||||
| RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); | RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); | ||||
| if (!expand) { | if (!expand) { | ||||
| split = uiLayoutSplit(layout, 0.3f, false); | split = uiLayoutSplit(layout, 0.3f, false); | ||||
| row = uiLayoutRow(split, false); | row = uiLayoutRow(split, false); | ||||
| uiDefButS(block, NUM, 0, "", 0, 0, 5.0f * UI_UNIT_X, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)), | uiDefButS(block, UI_BTYPE_NUM, 0, "", 0, 0, 5.0f * UI_UNIT_X, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)), | ||||
| 0, 0, TIP_("Choose active color stop")); | 0, 0, TIP_("Choose active color stop")); | ||||
| row = uiLayoutRow(split, false); | row = uiLayoutRow(split, false); | ||||
| uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE); | uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE); | ||||
| bt = block->buttons.last; | bt = block->buttons.last; | ||||
| uiButSetFunc(bt, colorband_update_cb, bt, coba); | UI_but_func_set(bt, colorband_update_cb, bt, coba); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiItemR(row, &ptr, "color", 0, "", ICON_NONE); | uiItemR(row, &ptr, "color", 0, "", ICON_NONE); | ||||
| bt = block->buttons.last; | bt = block->buttons.last; | ||||
| uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| split = uiLayoutSplit(layout, 0.5f, false); | split = uiLayoutSplit(layout, 0.5f, false); | ||||
| subsplit = uiLayoutSplit(split, 0.35f, false); | subsplit = uiLayoutSplit(split, 0.35f, false); | ||||
| row = uiLayoutRow(subsplit, false); | row = uiLayoutRow(subsplit, false); | ||||
| uiDefButS(block, NUM, 0, "", 0, 0, 5.0f * UI_UNIT_X, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)), | uiDefButS(block, UI_BTYPE_NUM, 0, "", 0, 0, 5.0f * UI_UNIT_X, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)), | ||||
| 0, 0, TIP_("Choose active color stop")); | 0, 0, TIP_("Choose active color stop")); | ||||
| row = uiLayoutRow(subsplit, false); | row = uiLayoutRow(subsplit, false); | ||||
| uiItemR(row, &ptr, "position", UI_ITEM_R_SLIDER, IFACE_("Pos"), ICON_NONE); | uiItemR(row, &ptr, "position", UI_ITEM_R_SLIDER, IFACE_("Pos"), ICON_NONE); | ||||
| bt = block->buttons.last; | bt = block->buttons.last; | ||||
| uiButSetFunc(bt, colorband_update_cb, bt, coba); | UI_but_func_set(bt, colorband_update_cb, bt, coba); | ||||
| row = uiLayoutRow(split, false); | row = uiLayoutRow(split, false); | ||||
| uiItemR(row, &ptr, "color", 0, "", ICON_NONE); | uiItemR(row, &ptr, "color", 0, "", ICON_NONE); | ||||
| bt = block->buttons.last; | bt = block->buttons.last; | ||||
| uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, int expand) | void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, int expand) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| PointerRNA cptr; | PointerRNA cptr; | ||||
| Show All 14 Lines | void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, int expand) | ||||
| cb->prop = prop; | cb->prop = prop; | ||||
| rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X; | rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X; | ||||
| rect.ymin = 0; rect.ymax = 19.5f * UI_UNIT_X; | rect.ymin = 0; rect.ymax = 19.5f * UI_UNIT_X; | ||||
| block = uiLayoutAbsoluteBlock(layout); | block = uiLayoutAbsoluteBlock(layout); | ||||
| id = cptr.id.data; | id = cptr.id.data; | ||||
| uiBlockSetButLock(block, (id && id->lib), ERROR_LIBDATA_MESSAGE); | UI_block_lock_set(block, (id && id->lib), ERROR_LIBDATA_MESSAGE); | ||||
| colorband_buttons_layout(layout, block, cptr.data, &rect, cb, expand); | colorband_buttons_layout(layout, block, cptr.data, &rect, cb, expand); | ||||
| uiBlockClearButLock(block); | UI_block_lock_clear(block); | ||||
| MEM_freeN(cb); | MEM_freeN(cb); | ||||
| } | } | ||||
| /********************* Icon viewer Template ************************/ | /********************* Icon viewer Template ************************/ | ||||
| /* ID Search browse menu, open */ | /* ID Search browse menu, open */ | ||||
| static uiBlock *icon_view_menu(bContext *C, ARegion *ar, void *arg_litem) | static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem) | ||||
| { | { | ||||
| static RNAUpdateCb cb; | static RNAUpdateCb cb; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| int icon; | int icon; | ||||
| EnumPropertyItem *item; | EnumPropertyItem *item; | ||||
| int a; | int a; | ||||
| bool free; | bool free; | ||||
| /* arg_litem is malloced, can be freed by parent button */ | /* arg_litem is malloced, can be freed by parent button */ | ||||
| cb = *((RNAUpdateCb *)arg_litem); | cb = *((RNAUpdateCb *)arg_litem); | ||||
| /* unused */ | /* unused */ | ||||
| // icon = RNA_property_enum_get(&cb.ptr, cb.prop); | // icon = RNA_property_enum_get(&cb.ptr, cb.prop); | ||||
| block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); | block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); | ||||
| uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW); | UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW); | ||||
| RNA_property_enum_items(C, &cb.ptr, cb.prop, &item, NULL, &free); | RNA_property_enum_items(C, &cb.ptr, cb.prop, &item, NULL, &free); | ||||
| for (a = 0; item[a].identifier; a++) { | for (a = 0; item[a].identifier; a++) { | ||||
| int x, y; | int x, y; | ||||
| /* XXX hardcoded size to 5 x unit */ | /* XXX hardcoded size to 5 x unit */ | ||||
| x = (a % 8) * UI_UNIT_X * 5; | x = (a % 8) * UI_UNIT_X * 5; | ||||
| y = (a / 8) * UI_UNIT_X * 5; | y = (a / 8) * UI_UNIT_X * 5; | ||||
| icon = item[a].icon; | icon = item[a].icon; | ||||
| but = uiDefIconButR_prop(block, ROW, 0, icon, x, y, UI_UNIT_X * 5, UI_UNIT_Y * 5, &cb.ptr, cb.prop, -1, 0, icon, -1, -1, NULL); | but = uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, x, y, UI_UNIT_X * 5, UI_UNIT_Y * 5, &cb.ptr, cb.prop, -1, 0, icon, -1, -1, NULL); | ||||
| uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW); | UI_but_flag_enable(but, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); | ||||
| } | } | ||||
| uiBoundsBlock(block, 0.3f * U.widget_unit); | UI_block_bounds_set_normal(block, 0.3f * U.widget_unit); | ||||
| uiBlockSetDirection(block, UI_TOP); | UI_block_direction_set(block, UI_DIR_UP); | ||||
| if (free) { | if (free) { | ||||
| MEM_freeN(item); | MEM_freeN(item); | ||||
| } | } | ||||
| return block; | return block; | ||||
| } | } | ||||
| Show All 15 Lines | // rctf rect; /* UNUSED */ | ||||
| cb->ptr = *ptr; | cb->ptr = *ptr; | ||||
| cb->prop = prop; | cb->prop = prop; | ||||
| // rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X; | // rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X; | ||||
| // rect.ymin = 0; rect.ymax = 10.0f * UI_UNIT_X; | // rect.ymin = 0; rect.ymax = 10.0f * UI_UNIT_X; | ||||
| block = uiLayoutAbsoluteBlock(layout); | block = uiLayoutAbsoluteBlock(layout); | ||||
| but = uiDefBlockButN(block, icon_view_menu, MEM_dupallocN(cb), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, ""); | but = uiDefBlockButN(block, ui_icon_view_menu_cb, MEM_dupallocN(cb), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, ""); | ||||
| // but = uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect), ptr, prop, -1, 0, icon, -1, -1, NULL); | // but = uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect), ptr, prop, -1, 0, icon, -1, -1, NULL); | ||||
| but->icon = icon; | but->icon = icon; | ||||
| uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW); | UI_but_flag_enable(but, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); | ||||
| uiButSetNFunc(but, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), NULL); | ||||
| MEM_freeN(cb); | MEM_freeN(cb); | ||||
| } | } | ||||
| /********************* Histogram Template ************************/ | /********************* Histogram Template ************************/ | ||||
| void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname) | void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| { | { | ||||
| Show All 16 Lines | void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| } | } | ||||
| else if (hist->height > UI_UNIT_Y * 20) { | else if (hist->height > UI_UNIT_Y * 20) { | ||||
| hist->height = UI_UNIT_Y * 20; | hist->height = UI_UNIT_Y * 20; | ||||
| } | } | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| block = uiLayoutGetBlock(col); | block = uiLayoutGetBlock(col); | ||||
| uiDefBut(block, HISTOGRAM, 0, "", 0, 0, UI_UNIT_X * 10, hist->height, hist, 0, 0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_HISTOGRAM, 0, "", 0, 0, UI_UNIT_X * 10, hist->height, hist, 0, 0, 0, 0, ""); | ||||
| /* Resize grip. */ | /* Resize grip. */ | ||||
| uiDefIconButI(block, GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &hist->height, | uiDefIconButI(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &hist->height, | ||||
| UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, ""); | UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, ""); | ||||
| } | } | ||||
| /********************* Waveform Template ************************/ | /********************* Waveform Template ************************/ | ||||
| void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) | void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| Show All 15 Lines | void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| if (scopes->wavefrm_height < UI_UNIT_Y) { | if (scopes->wavefrm_height < UI_UNIT_Y) { | ||||
| scopes->wavefrm_height = UI_UNIT_Y; | scopes->wavefrm_height = UI_UNIT_Y; | ||||
| } | } | ||||
| else if (scopes->wavefrm_height > UI_UNIT_Y * 20) { | else if (scopes->wavefrm_height > UI_UNIT_Y * 20) { | ||||
| scopes->wavefrm_height = UI_UNIT_Y * 20; | scopes->wavefrm_height = UI_UNIT_Y * 20; | ||||
| } | } | ||||
| uiDefBut(block, WAVEFORM, 0, "", 0, 0, UI_UNIT_X * 10, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_WAVEFORM, 0, "", 0, 0, UI_UNIT_X * 10, scopes->wavefrm_height, scopes, 0, 0, 0, 0, ""); | ||||
| /* Resize grip. */ | /* Resize grip. */ | ||||
| uiDefIconButI(block, GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &scopes->wavefrm_height, | uiDefIconButI(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &scopes->wavefrm_height, | ||||
| UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, ""); | UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, ""); | ||||
| } | } | ||||
| /********************* Vectorscope Template ************************/ | /********************* Vectorscope Template ************************/ | ||||
| void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propname) | void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| Show All 15 Lines | void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| } | } | ||||
| else if (scopes->vecscope_height > UI_UNIT_Y * 20) { | else if (scopes->vecscope_height > UI_UNIT_Y * 20) { | ||||
| scopes->vecscope_height = UI_UNIT_Y * 20; | scopes->vecscope_height = UI_UNIT_Y * 20; | ||||
| } | } | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| block = uiLayoutGetBlock(col); | block = uiLayoutGetBlock(col); | ||||
| uiDefBut(block, VECTORSCOPE, 0, "", 0, 0, UI_UNIT_X * 10, scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_VECTORSCOPE, 0, "", 0, 0, UI_UNIT_X * 10, scopes->vecscope_height, scopes, 0, 0, 0, 0, ""); | ||||
| /* Resize grip. */ | /* Resize grip. */ | ||||
| uiDefIconButI(block, GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &scopes->vecscope_height, | uiDefIconButI(block, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10, (short)(UI_UNIT_Y * 0.3f), &scopes->vecscope_height, | ||||
| UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, ""); | UI_UNIT_Y, UI_UNIT_Y * 20.0f, 0.0f, 0.0f, ""); | ||||
| } | } | ||||
| /********************* CurveMapping Template ************************/ | /********************* CurveMapping Template ************************/ | ||||
| static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(arg)) | static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(arg)) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
| /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | ||||
| static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) | static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) | ||||
| { | { | ||||
| CurveMapping *cumap = cumap_v; | CurveMapping *cumap = cumap_v; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *bt; | uiBut *bt; | ||||
| float width = 8 * UI_UNIT_X; | float width = 8 * UI_UNIT_X; | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | 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 empy space around the buttons */ | ||||
| uiDefBut(block, LABEL, 0, "", -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_LABEL, 0, "", -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| bt = uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, IFACE_("Use Clipping"), | bt = uiDefButBitI(block, UI_BTYPE_TOGGLE, CUMA_DO_CLIP, 1, IFACE_("Use Clipping"), | ||||
| 0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); | 0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL); | UI_but_func_set(bt, curvemap_buttons_setclip, cumap, NULL); | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| uiDefButF(block, NUM, 0, IFACE_("Min X "), 0, 4 * UI_UNIT_Y, width, UI_UNIT_Y, | uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Min X "), 0, 4 * UI_UNIT_Y, width, UI_UNIT_Y, | ||||
| &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 2, ""); | &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 2, ""); | ||||
| uiDefButF(block, NUM, 0, IFACE_("Min Y "), 0, 3 * UI_UNIT_Y, width, UI_UNIT_Y, | uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Min Y "), 0, 3 * UI_UNIT_Y, width, UI_UNIT_Y, | ||||
| &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 2, ""); | &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 2, ""); | ||||
| uiDefButF(block, NUM, 0, IFACE_("Max X "), 0, 2 * UI_UNIT_Y, width, UI_UNIT_Y, | uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Max X "), 0, 2 * UI_UNIT_Y, width, UI_UNIT_Y, | ||||
| &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 2, ""); | &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 2, ""); | ||||
| uiDefButF(block, NUM, 0, IFACE_("Max Y "), 0, UI_UNIT_Y, width, UI_UNIT_Y, | uiDefButF(block, UI_BTYPE_NUM, 0, IFACE_("Max Y "), 0, UI_UNIT_Y, width, UI_UNIT_Y, | ||||
| &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 2, ""); | &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 2, ""); | ||||
| uiBlockSetDirection(block, UI_RIGHT); | UI_block_direction_set(block, UI_DIR_RIGHT); | ||||
| return block; | return block; | ||||
| } | } | ||||
| /* only for curvemap_tools_dofunc */ | /* only for curvemap_tools_dofunc */ | ||||
| enum { | enum { | ||||
| UICURVE_FUNC_RESET_NEG, | UICURVE_FUNC_RESET_NEG, | ||||
| UICURVE_FUNC_RESET_POS, | UICURVE_FUNC_RESET_POS, | ||||
| Show All 40 Lines | static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event) | ||||
| ED_region_tag_redraw(CTX_wm_region(C)); | ED_region_tag_redraw(CTX_wm_region(C)); | ||||
| } | } | ||||
| static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cumap_v) | static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cumap_v) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| short yco = 0, menuwidth = 10 * UI_UNIT_X; | short yco = 0, menuwidth = 10 * UI_UNIT_X; | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); | UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_HOZ, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_HOZ, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_EXP, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_EXP, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_POS, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_POS, ""); | ||||
| uiBlockSetDirection(block, UI_RIGHT); | UI_block_direction_set(block, UI_DIR_RIGHT); | ||||
| uiTextBoundsBlock(block, 50); | UI_block_bounds_set_text(block, 50); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *ar, void *cumap_v) | static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *ar, void *cumap_v) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| short yco = 0, menuwidth = 10 * UI_UNIT_X; | short yco = 0, menuwidth = 10 * UI_UNIT_X; | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); | UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_HOZ, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_HOZ, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_EXP, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_EXTEND_EXP, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_NEG, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_NEG, ""); | ||||
| uiBlockSetDirection(block, UI_RIGHT); | UI_block_direction_set(block, UI_DIR_RIGHT); | ||||
| uiTextBoundsBlock(block, 50); | UI_block_bounds_set_text(block, 50); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_v) | static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_v) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| short yco = 0, menuwidth = 10 * UI_UNIT_X; | short yco = 0, menuwidth = 10 * UI_UNIT_X; | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); | UI_block_func_butmenu_set(block, curvemap_tools_dofunc, cumap_v); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_VIEW, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_VECTOR, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_HANDLE_AUTO, ""); | ||||
| uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT_MENU, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, | ||||
| menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_NEG, ""); | menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, UICURVE_FUNC_RESET_NEG, ""); | ||||
| uiBlockSetDirection(block, UI_RIGHT); | UI_block_direction_set(block, UI_DIR_RIGHT); | ||||
| uiTextBoundsBlock(block, 50); | UI_block_bounds_set_text(block, 50); | ||||
| return block; | return block; | ||||
| } | } | ||||
| static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) | static void curvemap_buttons_redraw(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) | ||||
| { | { | ||||
| ED_region_tag_redraw(CTX_wm_region(C)); | ED_region_tag_redraw(CTX_wm_region(C)); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels, | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| if (labeltype == 'v') { | if (labeltype == 'v') { | ||||
| /* vector */ | /* vector */ | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); | uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); | ||||
| if (cumap->cm[0].curve) { | if (cumap->cm[0].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| if (cumap->cm[1].curve) { | if (cumap->cm[1].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| if (cumap->cm[2].curve) { | if (cumap->cm[2].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else if (labeltype == 'c') { | else if (labeltype == 'c') { | ||||
| /* color */ | /* color */ | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); | uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); | ||||
| if (cumap->cm[3].curve) { | if (cumap->cm[3].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| if (cumap->cm[0].curve) { | if (cumap->cm[0].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| if (cumap->cm[1].curve) { | if (cumap->cm[1].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| if (cumap->cm[2].curve) { | if (cumap->cm[2].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else if (labeltype == 'h') { | else if (labeltype == 'h') { | ||||
| /* HSV */ | /* HSV */ | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); | uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); | ||||
| if (cumap->cm[0].curve) { | if (cumap->cm[0].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| if (cumap->cm[1].curve) { | if (cumap->cm[1].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| if (cumap->cm[2].curve) { | if (cumap->cm[2].curve) { | ||||
| bt = uiDefButI(block, ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | bt = uiDefButI(block, UI_BTYPE_ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); | ||||
| uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); | UI_but_func_set(bt, curvemap_buttons_redraw, NULL, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); | uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); | ||||
| if (labeltype == 'h') | if (labeltype == 'h') | ||||
| bg = UI_GRAD_H; | bg = UI_GRAD_H; | ||||
| /* operation buttons */ | /* operation buttons */ | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| bt = uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom in")); | bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom in")); | ||||
| uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL); | UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, NULL); | ||||
| bt = uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out")); | bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out")); | ||||
| uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL); | UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL); | ||||
| if (brush) | if (brush) | ||||
| bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools")); | bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools")); | ||||
| else if (neg_slope) | else if (neg_slope) | ||||
| bt = uiDefIconBlockBut(block, curvemap_tools_negslope_func, cumap, 0, ICON_MODIFIER, | bt = uiDefIconBlockBut(block, curvemap_tools_negslope_func, cumap, 0, ICON_MODIFIER, | ||||
| 0, 0, dx, dx, TIP_("Tools")); | 0, 0, dx, dx, TIP_("Tools")); | ||||
| else | else | ||||
| bt = uiDefIconBlockBut(block, curvemap_tools_posslope_func, cumap, 0, ICON_MODIFIER, | bt = uiDefIconBlockBut(block, curvemap_tools_posslope_func, cumap, 0, ICON_MODIFIER, | ||||
| 0, 0, dx, dx, TIP_("Tools")); | 0, 0, dx, dx, TIP_("Tools")); | ||||
| uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | ||||
| icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT; | icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : ICON_CLIPUV_DEHLT; | ||||
| bt = uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options")); | bt = uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options")); | ||||
| uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); | ||||
| bt = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete points")); | bt = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete points")); | ||||
| uiButSetNFunc(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap); | UI_but_funcN_set(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); | UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL); | ||||
| /* curve itself */ | /* curve itself */ | ||||
| size = uiLayoutGetWidth(layout); | size = uiLayoutGetWidth(layout); | ||||
| row = uiLayoutRow(layout, false); | row = uiLayoutRow(layout, false); | ||||
| uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, ""); | uiDefBut(block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, ""); | ||||
| /* sliders for selected point */ | /* sliders for selected point */ | ||||
| for (i = 0; i < cm->totpoint; i++) { | for (i = 0; i < cm->totpoint; i++) { | ||||
| if (cm->curve[i].flag & CUMA_SELECT) { | if (cm->curve[i].flag & CUMA_SELECT) { | ||||
| cmp = &cm->curve[i]; | cmp = &cm->curve[i]; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (cmp) { | if (cmp) { | ||||
| rctf bounds; | rctf bounds; | ||||
| if (cumap->flag & CUMA_DO_CLIP) { | if (cumap->flag & CUMA_DO_CLIP) { | ||||
| bounds = cumap->clipr; | bounds = cumap->clipr; | ||||
| } | } | ||||
| else { | else { | ||||
| bounds.xmin = bounds.ymin = -1000.0; | bounds.xmin = bounds.ymin = -1000.0; | ||||
| bounds.xmax = bounds.ymax = 1000.0; | bounds.xmax = bounds.ymax = 1000.0; | ||||
| } | } | ||||
| uiLayoutRow(layout, true); | uiLayoutRow(layout, true); | ||||
| uiBlockSetNFunc(block, curvemap_buttons_update, MEM_dupallocN(cb), cumap); | UI_block_funcN_set(block, curvemap_buttons_update, MEM_dupallocN(cb), cumap); | ||||
| uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButF(block, UI_BTYPE_NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| &cmp->x, bounds.xmin, bounds.xmax, 1, 5, ""); | &cmp->x, bounds.xmin, bounds.xmax, 1, 5, ""); | ||||
| uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, | uiDefButF(block, UI_BTYPE_NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| &cmp->y, bounds.ymin, bounds.ymax, 1, 5, ""); | &cmp->y, bounds.ymin, bounds.ymax, 1, 5, ""); | ||||
| } | } | ||||
| /* black/white levels */ | /* black/white levels */ | ||||
| if (levels) { | if (levels) { | ||||
| split = uiLayoutSplit(layout, 0.0f, false); | split = uiLayoutSplit(layout, 0.0f, false); | ||||
| uiItemR(uiLayoutColumn(split, false), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiItemR(uiLayoutColumn(split, false), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | ||||
| uiItemR(uiLayoutColumn(split, false), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiItemR(uiLayoutColumn(split, false), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | ||||
| uiLayoutRow(layout, false); | uiLayoutRow(layout, false); | ||||
| bt = uiDefBut(block, BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, | bt = uiDefBut(block, UI_BTYPE_BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, | ||||
| TIP_("Reset Black/White point and curves")); | TIP_("Reset Black/White point and curves")); | ||||
| uiButSetNFunc(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap); | UI_but_funcN_set(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap); | ||||
| } | } | ||||
| uiBlockSetNFunc(block, NULL, NULL, NULL); | UI_block_funcN_set(block, NULL, NULL, NULL); | ||||
| } | } | ||||
| void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type, | void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type, | ||||
| int levels, int brush, int neg_slope) | int levels, int brush, int neg_slope) | ||||
| { | { | ||||
| RNAUpdateCb *cb; | RNAUpdateCb *cb; | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| PointerRNA cptr; | PointerRNA cptr; | ||||
| Show All 16 Lines | void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type, | ||||
| if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) | if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) | ||||
| return; | return; | ||||
| cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); | cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); | ||||
| cb->ptr = *ptr; | cb->ptr = *ptr; | ||||
| cb->prop = prop; | cb->prop = prop; | ||||
| id = cptr.id.data; | id = cptr.id.data; | ||||
| uiBlockSetButLock(block, (id && id->lib), ERROR_LIBDATA_MESSAGE); | UI_block_lock_set(block, (id && id->lib), ERROR_LIBDATA_MESSAGE); | ||||
| curvemap_buttons_layout(layout, &cptr, type, levels, brush, neg_slope, cb); | curvemap_buttons_layout(layout, &cptr, type, levels, brush, neg_slope, cb); | ||||
| uiBlockClearButLock(block); | UI_block_lock_clear(block); | ||||
| MEM_freeN(cb); | MEM_freeN(cb); | ||||
| } | } | ||||
| /********************* ColorPicker Template ************************/ | /********************* ColorPicker Template ************************/ | ||||
| #define WHEEL_SIZE (5 * U.widget_unit) | #define WHEEL_SIZE (5 * U.widget_unit) | ||||
| /* This template now follows User Preference for type - name is not correct anymore... */ | /* This template now follows User Preference for type - name is not correct anymore... */ | ||||
| void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, | void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, | ||||
| int lock, int lock_luminosity, int cubic) | int lock, int lock_luminosity, int cubic) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| uiLayout *col, *row; | uiLayout *col, *row; | ||||
| uiBut *but = NULL; | uiBut *but = NULL; | ||||
| ColorPicker *cpicker = ui_block_picker_new(block); | ColorPicker *cpicker = ui_block_colorpicker_create(block); | ||||
| float softmin, softmax, step, precision; | float softmin, softmax, step, precision; | ||||
| if (!prop) { | if (!prop) { | ||||
| RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); | ||||
| return; | return; | ||||
| } | } | ||||
| RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); | RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| row = uiLayoutRow(col, true); | row = uiLayoutRow(col, true); | ||||
| switch (U.color_picker_type) { | switch (U.color_picker_type) { | ||||
| case USER_CP_SQUARE_SV: | case USER_CP_SQUARE_SV: | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | ||||
| -1, 0.0, 0.0, UI_GRAD_SV, 0, ""); | -1, 0.0, 0.0, UI_GRAD_SV, 0, ""); | ||||
| break; | break; | ||||
| case USER_CP_SQUARE_HS: | case USER_CP_SQUARE_HS: | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | ||||
| -1, 0.0, 0.0, UI_GRAD_HS, 0, ""); | -1, 0.0, 0.0, UI_GRAD_HS, 0, ""); | ||||
| break; | break; | ||||
| case USER_CP_SQUARE_HV: | case USER_CP_SQUARE_HV: | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | ||||
| -1, 0.0, 0.0, UI_GRAD_HV, 0, ""); | -1, 0.0, 0.0, UI_GRAD_HV, 0, ""); | ||||
| break; | break; | ||||
| /* user default */ | /* user default */ | ||||
| case USER_CP_CIRCLE_HSV: | case USER_CP_CIRCLE_HSV: | ||||
| case USER_CP_CIRCLE_HSL: | case USER_CP_CIRCLE_HSL: | ||||
| default: | default: | ||||
| but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, | ||||
| -1, 0.0, 0.0, 0, 0, ""); | -1, 0.0, 0.0, 0, 0, ""); | ||||
| break; | break; | ||||
| } | } | ||||
| but->custom_data = cpicker; | but->custom_data = cpicker; | ||||
| if (lock) { | if (lock) { | ||||
| Show All 10 Lines | void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, | ||||
| if (cubic) | if (cubic) | ||||
| but->flag |= UI_BUT_COLOR_CUBIC; | but->flag |= UI_BUT_COLOR_CUBIC; | ||||
| if (value_slider) { | if (value_slider) { | ||||
| switch (U.color_picker_type) { | switch (U.color_picker_type) { | ||||
| case USER_CP_CIRCLE_HSL: | case USER_CP_CIRCLE_HSL: | ||||
| uiItemS(row); | uiItemS(row); | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, | ||||
| -1, softmin, softmax, UI_GRAD_L_ALT, 0, ""); | -1, softmin, softmax, UI_GRAD_L_ALT, 0, ""); | ||||
| break; | break; | ||||
| case USER_CP_SQUARE_SV: | case USER_CP_SQUARE_SV: | ||||
| uiItemS(col); | uiItemS(col); | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, | ||||
| -1, softmin, softmax, UI_GRAD_SV + 3, 0, ""); | -1, softmin, softmax, UI_GRAD_SV + 3, 0, ""); | ||||
| break; | break; | ||||
| case USER_CP_SQUARE_HS: | case USER_CP_SQUARE_HS: | ||||
| uiItemS(col); | uiItemS(col); | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, | ||||
| -1, softmin, softmax, UI_GRAD_HS + 3, 0, ""); | -1, softmin, softmax, UI_GRAD_HS + 3, 0, ""); | ||||
| break; | break; | ||||
| case USER_CP_SQUARE_HV: | case USER_CP_SQUARE_HV: | ||||
| uiItemS(col); | uiItemS(col); | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", 0, 4, WHEEL_SIZE, 18, ptr, prop, | ||||
| -1, softmin, softmax, UI_GRAD_HV + 3, 0, ""); | -1, softmin, softmax, UI_GRAD_HV + 3, 0, ""); | ||||
| break; | break; | ||||
| /* user default */ | /* user default */ | ||||
| case USER_CP_CIRCLE_HSV: | case USER_CP_CIRCLE_HSV: | ||||
| default: | default: | ||||
| uiItemS(row); | uiItemS(row); | ||||
| but = uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, | but = uiDefButR_prop(block, UI_BTYPE_HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, | ||||
| -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); | -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); | ||||
| break; | break; | ||||
| } | } | ||||
| but->custom_data = cpicker; | but->custom_data = cpicker; | ||||
| } | } | ||||
| } | } | ||||
| Show All 23 Lines | void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, int UNUSED(colors)) | ||||
| /* first delete any pending colors */ | /* first delete any pending colors */ | ||||
| BKE_palette_cleanup(palette); | BKE_palette_cleanup(palette); | ||||
| color = palette->colors.first; | color = palette->colors.first; | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| uiLayoutRow(col, true); | uiLayoutRow(col, true); | ||||
| uiDefIconButO(block, BUT, "PALETTE_OT_color_add", WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | uiDefIconButO(block, UI_BTYPE_BUT, "PALETTE_OT_color_add", WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | ||||
| uiDefIconButO(block, BUT, "PALETTE_OT_color_delete", WM_OP_INVOKE_DEFAULT, ICON_ZOOMOUT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | uiDefIconButO(block, UI_BTYPE_BUT, "PALETTE_OT_color_delete", WM_OP_INVOKE_DEFAULT, ICON_ZOOMOUT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| uiLayoutRow(col, true); | uiLayoutRow(col, true); | ||||
| for (; color; color = color->next) { | for (; color; color = color->next) { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| if (row_cols >= cols_per_row) { | if (row_cols >= cols_per_row) { | ||||
| uiLayoutRow(col, true); | uiLayoutRow(col, true); | ||||
| row_cols = 0; | row_cols = 0; | ||||
| } | } | ||||
| RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &ptr); | RNA_pointer_create(&palette->id, &RNA_PaletteColor, color, &ptr); | ||||
| uiDefButR(block, COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ptr, "color", -1, 0.0, 1.0, | uiDefButR(block, UI_BTYPE_COLOR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ptr, "color", -1, 0.0, 1.0, | ||||
| UI_PALETTE_COLOR, col_id, ""); | UI_PALETTE_COLOR, col_id, ""); | ||||
| row_cols++; | row_cols++; | ||||
| col_id++; | col_id++; | ||||
| } | } | ||||
| } | } | ||||
| /********************* Layer Buttons Template ************************/ | /********************* Layer Buttons Template ************************/ | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | for (row = 0; row < 2; row++) { | ||||
| int butlay = 1 << layer; | int butlay = 1 << layer; | ||||
| if (active_layer & butlay) | if (active_layer & butlay) | ||||
| icon = ICON_LAYER_ACTIVE; | icon = ICON_LAYER_ACTIVE; | ||||
| else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer)) | else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer)) | ||||
| icon = ICON_LAYER_USED; | icon = ICON_LAYER_USED; | ||||
| but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2); | but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2); | ||||
| uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer)); | UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer)); | ||||
| but->type = TOG; | but->type = UI_BTYPE_TOGGLE; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propname, | void uiTemplateGameStates(uiLayout *layout, PointerRNA *ptr, const char *propname, | ||||
| PointerRNA *used_ptr, const char *used_propname, int active_state) | PointerRNA *used_ptr, const char *used_propname, int active_state) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | for (row = 0; row < 2; row++) { | ||||
| int icon = 0; | int icon = 0; | ||||
| int butlay = 1 << state; | int butlay = 1 << state; | ||||
| if (active_state & butlay) | if (active_state & butlay) | ||||
| icon = ICON_LAYER_ACTIVE; | icon = ICON_LAYER_ACTIVE; | ||||
| else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state)) | else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, state)) | ||||
| icon = ICON_LAYER_USED; | icon = ICON_LAYER_USED; | ||||
| but = uiDefIconButR_prop(block, ICONTOG, 0, icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2, ptr, prop, | 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)); | state, 0, 0, -1, -1, sca_state_name_get(ob, state)); | ||||
| uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state)); | UI_but_func_set(but, handle_layer_buttons, but, SET_INT_IN_POINTER(state)); | ||||
| but->type = TOG; | but->type = UI_BTYPE_TOGGLE; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /************************* List Template **************************/ | /************************* List Template **************************/ | ||||
| static void uilist_draw_item_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout, | static void uilist_draw_item_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout, | ||||
| ▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | |||||
| } _uilist_item; | } _uilist_item; | ||||
| typedef struct { | typedef struct { | ||||
| int visual_items; /* Visual number of items (i.e. number of items we have room to display). */ | int visual_items; /* Visual number of items (i.e. number of items we have room to display). */ | ||||
| int start_idx; /* Index of first item to display. */ | int start_idx; /* Index of first item to display. */ | ||||
| int end_idx; /* Index of last item to display + 1. */ | int end_idx; /* Index of last item to display + 1. */ | ||||
| } uiListLayoutdata; | } uiListLayoutdata; | ||||
| static void prepare_list(uiList *ui_list, int len, int activei, int rows, int maxrows, int columns, | static void uilist_prepare(uiList *ui_list, int len, int activei, int rows, int maxrows, int columns, | ||||
| uiListLayoutdata *layoutdata) | uiListLayoutdata *layoutdata) | ||||
| { | { | ||||
| uiListDyn *dyn_data = ui_list->dyn_data; | uiListDyn *dyn_data = ui_list->dyn_data; | ||||
| int activei_row, max_scroll; | int activei_row, max_scroll; | ||||
| const bool use_auto_size = (ui_list->list_grip < (rows - UI_LIST_AUTO_SIZE_THRESHOLD)); | const bool use_auto_size = (ui_list->list_grip < (rows - UI_LIST_AUTO_SIZE_THRESHOLD)); | ||||
| /* default rows */ | /* default rows */ | ||||
| if (rows <= 0) | if (rows <= 0) | ||||
| Show All 37 Lines | static void uilist_prepare(uiList *ui_list, int len, int activei, int rows, int maxrows, int columns, | ||||
| CLAMP(ui_list->list_scroll, 0, max_scroll); | CLAMP(ui_list->list_scroll, 0, max_scroll); | ||||
| ui_list->list_last_len = len; | ui_list->list_last_len = len; | ||||
| dyn_data->visual_height = rows; | dyn_data->visual_height = rows; | ||||
| layoutdata->visual_items = rows * columns; | layoutdata->visual_items = rows * columns; | ||||
| layoutdata->start_idx = ui_list->list_scroll * columns; | layoutdata->start_idx = ui_list->list_scroll * columns; | ||||
| layoutdata->end_idx = min_ii(layoutdata->start_idx + rows * columns, len); | layoutdata->end_idx = min_ii(layoutdata->start_idx + rows * columns, len); | ||||
| } | } | ||||
| static void ui_list_resize_update_cb(bContext *UNUSED(C), void *arg1, void *UNUSED(arg2)) | static void uilist_resize_update_cb(bContext *UNUSED(C), void *arg1, void *UNUSED(arg2)) | ||||
| { | { | ||||
| uiList *ui_list = arg1; | uiList *ui_list = arg1; | ||||
| uiListDyn *dyn_data = ui_list->dyn_data; | uiListDyn *dyn_data = ui_list->dyn_data; | ||||
| /* This way we get diff in number of additional items to show (positive) or hide (negative). */ | /* This way we get diff in number of additional items to show (positive) or hide (negative). */ | ||||
| const int diff = iroundf((float)(dyn_data->resize - dyn_data->resize_prev) / (float)UI_UNIT_Y); | const int diff = iroundf((float)(dyn_data->resize - dyn_data->resize_prev) / (float)UI_UNIT_Y); | ||||
| if (diff != 0) { | if (diff != 0) { | ||||
| ▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | switch (layout_type) { | ||||
| case UILST_LAYOUT_DEFAULT: | case UILST_LAYOUT_DEFAULT: | ||||
| /* layout */ | /* layout */ | ||||
| box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop); | box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop); | ||||
| glob = uiLayoutColumn(box, true); | glob = uiLayoutColumn(box, true); | ||||
| row = uiLayoutRow(glob, false); | row = uiLayoutRow(glob, false); | ||||
| col = uiLayoutColumn(row, true); | col = uiLayoutColumn(row, true); | ||||
| /* init numbers */ | /* init numbers */ | ||||
| prepare_list(ui_list, len, activei, rows, maxrows, 1, &layoutdata); | uilist_prepare(ui_list, len, activei, rows, maxrows, 1, &layoutdata); | ||||
| if (dataptr->data && prop) { | if (dataptr->data && prop) { | ||||
| /* create list items */ | /* create list items */ | ||||
| for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) { | for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) { | ||||
| PointerRNA *itemptr = &items_ptr[i].item; | PointerRNA *itemptr = &items_ptr[i].item; | ||||
| int org_i = items_ptr[i].org_idx; | int org_i = items_ptr[i].org_idx; | ||||
| int flt_flag = items_ptr[i].flt_flag; | int flt_flag = items_ptr[i].flt_flag; | ||||
| subblock = uiLayoutGetBlock(col); | subblock = uiLayoutGetBlock(col); | ||||
| overlap = uiLayoutOverlap(col); | overlap = uiLayoutOverlap(col); | ||||
| uiBlockSetFlag(subblock, UI_BLOCK_LIST_ITEM); | UI_block_flag_enable(subblock, UI_BLOCK_LIST_ITEM); | ||||
| /* list item behind label & other buttons */ | /* list item behind label & other buttons */ | ||||
| sub = uiLayoutRow(overlap, false); | sub = uiLayoutRow(overlap, false); | ||||
| but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | but = uiDefButR_prop(subblock, UI_BTYPE_LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| active_dataptr, activeprop, 0, 0, org_i, 0, 0, TIP_("Double click to rename")); | active_dataptr, activeprop, 0, 0, org_i, 0, 0, TIP_("Double click to rename")); | ||||
| sub = uiLayoutRow(overlap, false); | sub = uiLayoutRow(overlap, false); | ||||
| icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false); | icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false); | ||||
| if (icon == ICON_DOT) | if (icon == ICON_DOT) | ||||
| icon = ICON_NONE; | icon = ICON_NONE; | ||||
| draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname, | draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname, | ||||
| org_i, flt_flag); | org_i, flt_flag); | ||||
| /* If we are "drawing" active item, set all labels as active. */ | /* If we are "drawing" active item, set all labels as active. */ | ||||
| if (i == activei) { | if (i == activei) { | ||||
| ui_layout_list_set_labels_active(sub); | ui_layout_list_set_labels_active(sub); | ||||
| } | } | ||||
| uiBlockClearFlag(subblock, UI_BLOCK_LIST_ITEM); | UI_block_flag_disable(subblock, UI_BLOCK_LIST_ITEM); | ||||
| } | } | ||||
| } | } | ||||
| /* add dummy buttons to fill space */ | /* add dummy buttons to fill space */ | ||||
| for (; i < layoutdata.start_idx + layoutdata.visual_items; i++) { | for (; i < layoutdata.start_idx + layoutdata.visual_items; i++) { | ||||
| uiItemL(col, "", ICON_NONE); | uiItemL(col, "", ICON_NONE); | ||||
| } | } | ||||
| /* add scrollbar */ | /* add scrollbar */ | ||||
| if (len > layoutdata.visual_items) { | if (len > layoutdata.visual_items) { | ||||
| col = uiLayoutColumn(row, false); | col = uiLayoutColumn(row, false); | ||||
| uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height, | uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height, | ||||
| &ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height, | &ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height, | ||||
| dyn_data->visual_height, 0, ""); | dyn_data->visual_height, 0, ""); | ||||
| } | } | ||||
| break; | break; | ||||
| case UILST_LAYOUT_COMPACT: | case UILST_LAYOUT_COMPACT: | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| if ((dataptr->data && prop) && (dyn_data->items_shown > 0) && | if ((dataptr->data && prop) && (dyn_data->items_shown > 0) && | ||||
| Show All 9 Lines | case UILST_LAYOUT_COMPACT: | ||||
| } | } | ||||
| /* if list is empty, add in dummy button */ | /* if list is empty, add in dummy button */ | ||||
| else { | else { | ||||
| uiItemL(row, "", ICON_NONE); | uiItemL(row, "", ICON_NONE); | ||||
| } | } | ||||
| /* next/prev button */ | /* next/prev button */ | ||||
| BLI_snprintf(numstr, sizeof(numstr), "%d :", dyn_data->items_shown); | BLI_snprintf(numstr, sizeof(numstr), "%d :", dyn_data->items_shown); | ||||
| but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, | but = uiDefIconTextButR_prop(block, UI_BTYPE_NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, | ||||
| active_dataptr, activeprop, 0, 0, 0, 0, 0, ""); | active_dataptr, activeprop, 0, 0, 0, 0, 0, ""); | ||||
| if (dyn_data->items_shown == 0) | if (dyn_data->items_shown == 0) | ||||
| uiButSetFlag(but, UI_BUT_DISABLED); | UI_but_flag_enable(but, UI_BUT_DISABLED); | ||||
| break; | break; | ||||
| case UILST_LAYOUT_GRID: | case UILST_LAYOUT_GRID: | ||||
| box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop); | box = uiLayoutListBox(layout, ui_list, dataptr, prop, active_dataptr, activeprop); | ||||
| glob = uiLayoutColumn(box, true); | glob = uiLayoutColumn(box, true); | ||||
| row = uiLayoutRow(glob, false); | row = uiLayoutRow(glob, false); | ||||
| col = uiLayoutColumn(row, true); | col = uiLayoutColumn(row, true); | ||||
| subrow = NULL; /* Quite gcc warning! */ | subrow = NULL; /* Quite gcc warning! */ | ||||
| prepare_list(ui_list, len, activei, rows, maxrows, columns, &layoutdata); | uilist_prepare(ui_list, len, activei, rows, maxrows, columns, &layoutdata); | ||||
| if (dataptr->data && prop) { | if (dataptr->data && prop) { | ||||
| /* create list items */ | /* create list items */ | ||||
| for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) { | for (i = layoutdata.start_idx; i < layoutdata.end_idx; i++) { | ||||
| PointerRNA *itemptr = &items_ptr[i].item; | PointerRNA *itemptr = &items_ptr[i].item; | ||||
| int org_i = items_ptr[i].org_idx; | int org_i = items_ptr[i].org_idx; | ||||
| int flt_flag = items_ptr[i].flt_flag; | int flt_flag = items_ptr[i].flt_flag; | ||||
| /* create button */ | /* create button */ | ||||
| if (!(i % columns)) | if (!(i % columns)) | ||||
| subrow = uiLayoutRow(col, false); | subrow = uiLayoutRow(col, false); | ||||
| subblock = uiLayoutGetBlock(subrow); | subblock = uiLayoutGetBlock(subrow); | ||||
| overlap = uiLayoutOverlap(subrow); | overlap = uiLayoutOverlap(subrow); | ||||
| uiBlockSetFlag(subblock, UI_BLOCK_LIST_ITEM); | UI_block_flag_enable(subblock, UI_BLOCK_LIST_ITEM); | ||||
| /* list item behind label & other buttons */ | /* list item behind label & other buttons */ | ||||
| sub = uiLayoutRow(overlap, false); | sub = uiLayoutRow(overlap, false); | ||||
| but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | but = uiDefButR_prop(subblock, UI_BTYPE_LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, | ||||
| active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL); | active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL); | ||||
| uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP); | UI_but_drawflag_enable(but, UI_BUT_NO_TOOLTIP); | ||||
| sub = uiLayoutRow(overlap, false); | sub = uiLayoutRow(overlap, false); | ||||
| icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false); | icon = UI_rnaptr_icon_get(C, itemptr, rnaicon, false); | ||||
| draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname, | draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname, | ||||
| org_i, flt_flag); | org_i, flt_flag); | ||||
| /* If we are "drawing" active item, set all labels as active. */ | /* If we are "drawing" active item, set all labels as active. */ | ||||
| if (i == activei) { | if (i == activei) { | ||||
| ui_layout_list_set_labels_active(sub); | ui_layout_list_set_labels_active(sub); | ||||
| } | } | ||||
| uiBlockClearFlag(subblock, UI_BLOCK_LIST_ITEM); | UI_block_flag_disable(subblock, UI_BLOCK_LIST_ITEM); | ||||
| } | } | ||||
| } | } | ||||
| /* add dummy buttons to fill space */ | /* add dummy buttons to fill space */ | ||||
| for (; i < layoutdata.start_idx + layoutdata.visual_items; i++) { | for (; i < layoutdata.start_idx + layoutdata.visual_items; i++) { | ||||
| if (!(i % columns)) { | if (!(i % columns)) { | ||||
| subrow = uiLayoutRow(col, false); | subrow = uiLayoutRow(col, false); | ||||
| } | } | ||||
| uiItemL(subrow, "", ICON_NONE); | uiItemL(subrow, "", ICON_NONE); | ||||
| } | } | ||||
| /* add scrollbar */ | /* add scrollbar */ | ||||
| if (len > layoutdata.visual_items) { | if (len > layoutdata.visual_items) { | ||||
| col = uiLayoutColumn(row, false); | col = uiLayoutColumn(row, false); | ||||
| uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height, | uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height, | ||||
| &ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height, | &ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height, | ||||
| dyn_data->visual_height, 0, ""); | dyn_data->visual_height, 0, ""); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| if (glob) { | if (glob) { | ||||
| /* About GRIP drag-resize: | /* About UI_BTYPE_GRIP drag-resize: | ||||
| * We can't directly use results from GRIP button, since we have a rather complex behavior here | * We can't directly use results from a grip button, since we have a rather complex behavior here | ||||
| * (sizing by discrete steps and, overall, autosize feature). | * (sizing by discrete steps and, overall, autosize feature). | ||||
| * Since we *never* know whether we are grip-resizing or not (because there is no callback for when a | * Since we *never* know whether we are grip-resizing or not (because there is no callback for when a | ||||
| * button enters/leaves its "edit mode"), we use the fact that grip-controlled value (dyn_data->resize) | * button enters/leaves its "edit mode"), we use the fact that grip-controlled value (dyn_data->resize) | ||||
| * is completely handled by the grip during the grab resize, so settings its value here has no effect | * is completely handled by the grip during the grab resize, so settings its value here has no effect | ||||
| * at all. | * at all. | ||||
| * It is only meaningful when we are not resizing, in which case this gives us the correct "init drag" value. | * It is only meaningful when we are not resizing, in which case this gives us the correct "init drag" value. | ||||
| * Note we cannot affect dyn_data->resize_prev here, since this value is not controlled by the grip! | * Note we cannot affect dyn_data->resize_prev here, since this value is not controlled by the grip! | ||||
| */ | */ | ||||
| dyn_data->resize = dyn_data->resize_prev + (dyn_data->visual_height - ui_list->list_grip) * UI_UNIT_Y; | dyn_data->resize = dyn_data->resize_prev + (dyn_data->visual_height - ui_list->list_grip) * UI_UNIT_Y; | ||||
| row = uiLayoutRow(glob, true); | row = uiLayoutRow(glob, true); | ||||
| subblock = uiLayoutGetBlock(row); | subblock = uiLayoutGetBlock(row); | ||||
| uiBlockSetEmboss(subblock, UI_EMBOSSN); | UI_block_emboss_set(subblock, UI_EMBOSS_NONE); | ||||
| if (ui_list->filter_flag & UILST_FLT_SHOW) { | if (ui_list->filter_flag & UILST_FLT_SHOW) { | ||||
| but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_DOWN, 0, 0, | but = uiDefIconButBitI(subblock, UI_BTYPE_TOGGLE, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_DOWN, 0, 0, | ||||
| UI_UNIT_X, UI_UNIT_Y * 0.5f, &(ui_list->filter_flag), 0, 0, 0, 0, | UI_UNIT_X, UI_UNIT_Y * 0.5f, &(ui_list->filter_flag), 0, 0, 0, 0, | ||||
| TIP_("Hide filtering options")); | TIP_("Hide filtering options")); | ||||
| uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ | UI_but_flag_disable(but, UI_BUT_UNDO); /* skip undo on screen buttons */ | ||||
| but = uiDefIconButI(subblock, GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.5f, | but = uiDefIconButI(subblock, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.5f, | ||||
| &dyn_data->resize, 0.0, 0.0, 0, 0, ""); | &dyn_data->resize, 0.0, 0.0, 0, 0, ""); | ||||
| uiButSetFunc(but, ui_list_resize_update_cb, ui_list, NULL); | UI_but_func_set(but, uilist_resize_update_cb, ui_list, NULL); | ||||
| uiBlockSetEmboss(subblock, UI_EMBOSS); | UI_block_emboss_set(subblock, UI_EMBOSS); | ||||
| col = uiLayoutColumn(glob, false); | col = uiLayoutColumn(glob, false); | ||||
| subblock = uiLayoutGetBlock(col); | subblock = uiLayoutGetBlock(col); | ||||
| uiDefBut(subblock, SEPR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y * 0.05f, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(subblock, UI_BTYPE_SEPR, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y * 0.05f, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| draw_filter(ui_list, C, col); | draw_filter(ui_list, C, col); | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefIconButBitI(subblock, TOG, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_RIGHT, 0, 0, | but = uiDefIconButBitI(subblock, UI_BTYPE_TOGGLE, UILST_FLT_SHOW, 0, ICON_DISCLOSURE_TRI_RIGHT, 0, 0, | ||||
| UI_UNIT_X, UI_UNIT_Y * 0.5f, &(ui_list->filter_flag), 0, 0, 0, 0, | UI_UNIT_X, UI_UNIT_Y * 0.5f, &(ui_list->filter_flag), 0, 0, 0, 0, | ||||
| TIP_("Show filtering options")); | TIP_("Show filtering options")); | ||||
| uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ | UI_but_flag_disable(but, UI_BUT_UNDO); /* skip undo on screen buttons */ | ||||
| but = uiDefIconButI(subblock, GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.5f, | but = uiDefIconButI(subblock, UI_BTYPE_GRIP, 0, ICON_GRIP, 0, 0, UI_UNIT_X * 10.0f, UI_UNIT_Y * 0.5f, | ||||
| &dyn_data->resize, 0.0, 0.0, 0, 0, ""); | &dyn_data->resize, 0.0, 0.0, 0, 0, ""); | ||||
| uiButSetFunc(but, ui_list_resize_update_cb, ui_list, NULL); | UI_but_func_set(but, uilist_resize_update_cb, ui_list, NULL); | ||||
| uiBlockSetEmboss(subblock, UI_EMBOSS); | UI_block_emboss_set(subblock, UI_EMBOSS); | ||||
| } | } | ||||
| } | } | ||||
| if (items_ptr) { | if (items_ptr) { | ||||
| MEM_freeN(items_ptr); | MEM_freeN(items_ptr); | ||||
| } | } | ||||
| } | } | ||||
| Show All 29 Lines | if (BLI_strcasestr(ot->name, str)) { | ||||
| if (len < sizeof(name) - 6) { | if (len < sizeof(name) - 6) { | ||||
| if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, true, | if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, true, | ||||
| &name[len + 1], sizeof(name) - len - 1)) | &name[len + 1], sizeof(name) - len - 1)) | ||||
| { | { | ||||
| name[len] = UI_SEP_CHAR; | name[len] = UI_SEP_CHAR; | ||||
| } | } | ||||
| } | } | ||||
| if (false == uiSearchItemAdd(items, name, ot, 0)) | if (false == UI_search_item_add(items, name, ot, 0)) | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void uiOperatorSearch_But(uiBut *but) | void UI_but_func_operator_search(uiBut *but) | ||||
| { | { | ||||
| uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL); | UI_but_func_search_set(but, operator_search_cb, NULL, operator_call_cb, NULL); | ||||
| } | } | ||||
| void uiTemplateOperatorSearch(uiLayout *layout) | void uiTemplateOperatorSearch(uiLayout *layout) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| static char search[256] = ""; | static char search[256] = ""; | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, 0, ""); | but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, 0, ""); | ||||
| uiOperatorSearch_But(but); | UI_but_func_operator_search(but); | ||||
| } | } | ||||
| /************************* Running Jobs Template **************************/ | /************************* Running Jobs Template **************************/ | ||||
| #define B_STOPRENDER 1 | #define B_STOPRENDER 1 | ||||
| #define B_STOPCAST 2 | #define B_STOPCAST 2 | ||||
| #define B_STOPANIM 3 | #define B_STOPANIM 3 | ||||
| #define B_STOPCOMPO 4 | #define B_STOPCOMPO 4 | ||||
| Show All 33 Lines | void uiTemplateRunningJobs(uiLayout *layout, bContext *C) | ||||
| bScreen *screen = CTX_wm_screen(C); | bScreen *screen = CTX_wm_screen(C); | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| void *owner = NULL; | void *owner = NULL; | ||||
| int handle_event; | int handle_event; | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| uiBlockSetHandleFunc(block, do_running_jobs, NULL); | UI_block_func_handle_set(block, do_running_jobs, NULL); | ||||
| if (sa->spacetype == SPACE_SEQ) { | if (sa->spacetype == SPACE_SEQ) { | ||||
| if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) | if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) | ||||
| owner = sa; | owner = sa; | ||||
| handle_event = B_STOPSEQ; | handle_event = B_STOPSEQ; | ||||
| } | } | ||||
| else if (sa->spacetype == SPACE_CLIP) { | else if (sa->spacetype == SPACE_CLIP) { | ||||
| if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) | if (WM_jobs_test(wm, sa, WM_JOB_TYPE_ANY)) | ||||
| Show All 33 Lines | void uiTemplateRunningJobs(uiLayout *layout, bContext *C) | ||||
| } | } | ||||
| if (owner) { | if (owner) { | ||||
| uiLayout *ui_abs; | uiLayout *ui_abs; | ||||
| ui_abs = uiLayoutAbsolute(layout, false); | ui_abs = uiLayoutAbsolute(layout, false); | ||||
| (void)ui_abs; /* UNUSED */ | (void)ui_abs; /* UNUSED */ | ||||
| uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE, 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8, | uiDefIconBut(block, UI_BTYPE_BUT, handle_event, ICON_PANEL_CLOSE, 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8, | ||||
| NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); | NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job")); | ||||
| uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner), | uiDefBut(block, UI_BTYPE_PROGRESS_BAR, 0, WM_jobs_name(wm, owner), | ||||
| UI_UNIT_X, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress")); | UI_UNIT_X, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress")); | ||||
| uiLayoutRow(layout, false); | uiLayoutRow(layout, false); | ||||
| } | } | ||||
| if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) | if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) | ||||
| uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, UI_UNIT_X * 4.25f, UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, UI_UNIT_X * 4.25f, UI_UNIT_Y, | ||||
| NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); | NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); | ||||
| if (screen->animtimer) | if (screen->animtimer) | ||||
| uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, | uiDefIconTextBut(block, UI_BTYPE_BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, UI_UNIT_X * 5.0f, UI_UNIT_Y, | ||||
| NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback")); | NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback")); | ||||
| } | } | ||||
| /************************* Reports for Last Operator Template **************************/ | /************************* Reports for Last Operator Template **************************/ | ||||
| void uiTemplateReportsBanner(uiLayout *layout, bContext *C) | void uiTemplateReportsBanner(uiLayout *layout, bContext *C) | ||||
| { | { | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| Report *report = BKE_reports_last_displayable(reports); | Report *report = BKE_reports_last_displayable(reports); | ||||
| ReportTimerInfo *rti; | ReportTimerInfo *rti; | ||||
| uiLayout *ui_abs; | uiLayout *ui_abs; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_style_get(); | ||||
| int width; | int width; | ||||
| int icon; | int icon; | ||||
| /* if the report display has timed out, don't show */ | /* if the report display has timed out, don't show */ | ||||
| if (!reports->reporttimer) return; | if (!reports->reporttimer) return; | ||||
| rti = (ReportTimerInfo *)reports->reporttimer->customdata; | rti = (ReportTimerInfo *)reports->reporttimer->customdata; | ||||
| if (!rti || rti->widthfac == 0.0f || !report) return; | if (!rti || rti->widthfac == 0.0f || !report) return; | ||||
| ui_abs = uiLayoutAbsolute(layout, false); | ui_abs = uiLayoutAbsolute(layout, false); | ||||
| block = uiLayoutGetBlock(ui_abs); | block = uiLayoutGetBlock(ui_abs); | ||||
| width = BLF_width(style->widget.uifont_id, report->message, report->len); | width = BLF_width(style->widget.uifont_id, report->message, report->len); | ||||
| width = min_ii((int)(rti->widthfac * width), width); | width = min_ii((int)(rti->widthfac * width), width); | ||||
| width = max_ii(width, 10); | width = max_ii(width, 10); | ||||
| /* make a box around the report to make it stand out */ | /* make a box around the report to make it stand out */ | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| but = uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); | but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); | ||||
| /* set the report's bg color in but->col - ROUNDBOX feature */ | /* set the report's bg color in but->col - UI_BTYPE_ROUNDBOX feature */ | ||||
| rgb_float_to_uchar(but->col, rti->col); | rgb_float_to_uchar(but->col, rti->col); | ||||
| but->col[3] = 255; | but->col[3] = 255; | ||||
| but = uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, | but = uiDefBut(block, UI_BTYPE_ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, | ||||
| NULL, 0.0f, 0.0f, 0, 0, ""); | NULL, 0.0f, 0.0f, 0, 0, ""); | ||||
| but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->grayscale); | but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->grayscale); | ||||
| but->col[3] = 255; | but->col[3] = 255; | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| /* icon and report message on top */ | /* icon and report message on top */ | ||||
| icon = uiIconFromReportType(report->type); | icon = UI_icon_from_report_type(report->type); | ||||
| /* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report | /* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report | ||||
| * to be shown instead of icon when appropriate... | * to be shown instead of icon when appropriate... | ||||
| */ | */ | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| if (reports->list.first != reports->list.last) | if (reports->list.first != reports->list.last) | ||||
| uiDefIconButO(block, BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X, | uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_reports_to_textblock", WM_OP_INVOKE_REGION_WIN, icon, 2, 0, UI_UNIT_X, | ||||
| UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'")); | UI_UNIT_Y, TIP_("Click to see the remaining reports in text block: 'Recent Reports'")); | ||||
| else | else | ||||
| uiDefIconBut(block, LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); | uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, ""); | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, | uiDefBut(block, UI_BTYPE_LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, | ||||
| NULL, 0.0f, 0.0f, 0, 0, ""); | NULL, 0.0f, 0.0f, 0, 0, ""); | ||||
| } | } | ||||
| /********************************* Keymap *************************************/ | /********************************* Keymap *************************************/ | ||||
| static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused)) | static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused)) | ||||
| { | { | ||||
| wmKeyMapItem *kmi = (wmKeyMapItem *)kmi_p; | wmKeyMapItem *kmi = (wmKeyMapItem *)kmi_p; | ||||
| Show All 32 Lines | RNA_STRUCT_BEGIN (ptr, prop) | ||||
| row = uiLayoutRow(box, false); | row = uiLayoutRow(box, false); | ||||
| /* property value */ | /* property value */ | ||||
| uiItemFullR(row, ptr, prop, -1, 0, 0, NULL, ICON_NONE); | uiItemFullR(row, ptr, prop, -1, 0, 0, NULL, ICON_NONE); | ||||
| if (is_set) { | if (is_set) { | ||||
| /* unset operator */ | /* unset operator */ | ||||
| uiBlock *block = uiLayoutGetBlock(row); | uiBlock *block = uiLayoutGetBlock(row); | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| but = uiDefIconButO(block, BUT, "UI_OT_unset_property_button", WM_OP_EXEC_DEFAULT, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | but = uiDefIconButO(block, UI_BTYPE_BUT, "UI_OT_unset_property_button", WM_OP_EXEC_DEFAULT, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); | ||||
| but->rnapoin = *ptr; | but->rnapoin = *ptr; | ||||
| but->rnaprop = prop; | but->rnaprop = prop; | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| } | } | ||||
| } | } | ||||
| RNA_STRUCT_END; | RNA_STRUCT_END; | ||||
| } | } | ||||
| void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr) | void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr) | ||||
| { | { | ||||
| PointerRNA propptr = RNA_pointer_get(ptr, "properties"); | PointerRNA propptr = RNA_pointer_get(ptr, "properties"); | ||||
| if (propptr.data) { | if (propptr.data) { | ||||
| uiBut *but = uiLayoutGetBlock(layout)->buttons.last; | uiBut *but = uiLayoutGetBlock(layout)->buttons.last; | ||||
| template_keymap_item_properties(layout, NULL, &propptr); | template_keymap_item_properties(layout, NULL, &propptr); | ||||
| /* attach callbacks to compensate for missing properties update, | /* attach callbacks to compensate for missing properties update, | ||||
| * we don't know which keymap (item) is being modified there */ | * we don't know which keymap (item) is being modified there */ | ||||
| for (; but; but = but->next) { | for (; but; but = but->next) { | ||||
| /* operator buttons may store props for use (file selector, [#36492]) */ | /* operator buttons may store props for use (file selector, [#36492]) */ | ||||
| if (but->rnaprop) { | if (but->rnaprop) { | ||||
| uiButSetFunc(but, keymap_item_modified, ptr->data, NULL); | UI_but_func_set(but, keymap_item_modified, ptr->data, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /********************************* Color management *************************************/ | /********************************* Color management *************************************/ | ||||
| void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname) | void uiTemplateColorspaceSettings(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
| } ComponentMenuArgs; | } ComponentMenuArgs; | ||||
| /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ | ||||
| static uiBlock *component_menu(bContext *C, ARegion *ar, void *args_v) | static uiBlock *component_menu(bContext *C, ARegion *ar, void *args_v) | ||||
| { | { | ||||
| ComponentMenuArgs *args = (ComponentMenuArgs *)args_v; | ComponentMenuArgs *args = (ComponentMenuArgs *)args_v; | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); | block = UI_block_begin(C, ar, __func__, UI_EMBOSS); | ||||
| uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); | UI_block_flag_enable(block, UI_BLOCK_KEEP_OPEN); | ||||
| layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, UI_GetStyle()), 0); | layout = uiLayoutColumn(UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, UI_style_get()), 0); | ||||
| uiItemR(layout, &args->ptr, args->propname, UI_ITEM_R_EXPAND, "", ICON_NONE); | uiItemR(layout, &args->ptr, args->propname, UI_ITEM_R_EXPAND, "", ICON_NONE); | ||||
| uiBoundsBlock(block, 6); | UI_block_bounds_set_normal(block, 6); | ||||
| uiBlockSetDirection(block, UI_DOWN); | UI_block_direction_set(block, UI_DIR_DOWN); | ||||
| return block; | return block; | ||||
| } | } | ||||
| void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name) | void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name) | ||||
| { | { | ||||
| ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args"); | ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args"); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| args->ptr = *ptr; | args->ptr = *ptr; | ||||
| BLI_strncpy(args->propname, propname, sizeof(args->propname)); | BLI_strncpy(args->propname, propname, sizeof(args->propname)); | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| but = uiDefBlockButN(block, component_menu, args, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, ""); | but = uiDefBlockButN(block, component_menu, args, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, ""); | ||||
| /* set rna directly, uiDefBlockButN doesn't do this */ | /* set rna directly, uiDefBlockButN doesn't do this */ | ||||
| but->rnapoin = *ptr; | but->rnapoin = *ptr; | ||||
| but->rnaprop = RNA_struct_find_property(ptr, propname); | but->rnaprop = RNA_struct_find_property(ptr, propname); | ||||
| but->rnaindex = 0; | but->rnaindex = 0; | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| } | } | ||||
| /************************* Node Socket Icon **************************/ | /************************* Node Socket Icon **************************/ | ||||
| void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float *color) | void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float *color) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| block = uiLayoutGetBlock(layout); | block = uiLayoutGetBlock(layout); | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| /* XXX using explicit socket colors is not quite ideal. | /* XXX using explicit socket colors is not quite ideal. | ||||
| * Eventually it should be possible to use theme colors for this purpose, | * Eventually it should be possible to use theme colors for this purpose, | ||||
| * but this requires a better design for extendable color palettes in user prefs. | * but this requires a better design for extendable color palettes in user prefs. | ||||
| */ | */ | ||||
| but = uiDefBut(block, NODESOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | but = uiDefBut(block, UI_BTYPE_NODE_SOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | ||||
| rgba_float_to_uchar(but->col, color); | rgba_float_to_uchar(but->col, color); | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| } | } | ||||