Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_layout.c
| Show First 20 Lines • Show All 1,202 Lines • ▼ Show 20 Lines | static uiBut *uiItemFullO_ptr_ex(uiLayout *layout, | ||||
| if (flag & UI_ITEM_R_NO_BG) { | if (flag & UI_ITEM_R_NO_BG) { | ||||
| layout->emboss = prev_emboss; | layout->emboss = prev_emboss; | ||||
| } | } | ||||
| if (flag & UI_ITEM_O_DEPRESS) { | if (flag & UI_ITEM_O_DEPRESS) { | ||||
| but->flag |= UI_SELECT_DRAW; | but->flag |= UI_SELECT_DRAW; | ||||
| } | } | ||||
| if (flag & UI_ITEM_R_ICON_ONLY) { | |||||
| UI_but_drawflag_disable(but, UI_BUT_ICON_LEFT); | |||||
| } | |||||
| if (layout->redalert) { | if (layout->redalert) { | ||||
| UI_but_flag_enable(but, UI_BUT_REDALERT); | UI_but_flag_enable(but, UI_BUT_REDALERT); | ||||
| } | } | ||||
| if (layout->active_default) { | if (layout->active_default) { | ||||
| UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); | UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | void uiItemsFullEnumO_items(uiLayout *layout, | ||||
| uiLayout *target, *split = NULL; | uiLayout *target, *split = NULL; | ||||
| const EnumPropertyItem *item; | const EnumPropertyItem *item; | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| const bool radial = ui_layout_is_radial(layout); | const bool radial = ui_layout_is_radial(layout); | ||||
| if (radial) { | if (radial) { | ||||
| target = uiLayoutRadial(layout); | target = uiLayoutRadial(layout); | ||||
| } | } | ||||
| else if (layout->item.type == ITEM_LAYOUT_ROW && flag & UI_ITEM_R_ICON_ONLY) { | |||||
| target = layout; | |||||
| /* Add a blank button to the beginning of the row. */ | |||||
| uiDefIconBut( | |||||
| block, UI_BTYPE_LABEL, 0, ICON_BLANK1, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); | |||||
| } | |||||
| else { | else { | ||||
| split = uiLayoutSplit(layout, 0.0f, false); | split = uiLayoutSplit(layout, 0.0f, false); | ||||
| target = uiLayoutColumn(split, layout->align); | target = uiLayoutColumn(split, layout->align); | ||||
| } | } | ||||
| int i; | int i; | ||||
| bool last_iter = false; | bool last_iter = false; | ||||
| Show All 31 Lines | if (item->identifier[0]) { | ||||
| if (properties) { | if (properties) { | ||||
| if (tptr.data) { | if (tptr.data) { | ||||
| IDP_FreeProperty(tptr.data); | IDP_FreeProperty(tptr.data); | ||||
| } | } | ||||
| tptr.data = IDP_CopyProperty(properties); | tptr.data = IDP_CopyProperty(properties); | ||||
| } | } | ||||
| RNA_property_enum_set(&tptr, prop, item->value); | RNA_property_enum_set(&tptr, prop, item->value); | ||||
| uiItemFullO_ptr(target, ot, item->name, item->icon, tptr.data, context, flag, NULL); | uiItemFullO_ptr(target, | ||||
| ot, | |||||
| (flag & UI_ITEM_R_ICON_ONLY) ? NULL : item->name, | |||||
| item->icon, | |||||
| tptr.data, | |||||
| context, | |||||
| flag, | |||||
| NULL); | |||||
| ui_but_tip_from_enum_item(block->buttons.last, item); | ui_but_tip_from_enum_item(block->buttons.last, item); | ||||
| } | } | ||||
| else { | else { | ||||
| if (item->name) { | if (item->name) { | ||||
| uiBut *but; | uiBut *but; | ||||
| if (item != item_array && !radial) { | if (item != item_array && !radial) { | ||||
| ▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | else if (prop && RNA_property_type(prop) != PROP_ENUM) { | ||||
| return; | return; | ||||
| } | } | ||||
| else { | else { | ||||
| RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); | RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) | void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname, const bool icon_only) | ||||
| { | { | ||||
| uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0); | uiItemsFullEnumO(layout, | ||||
| opname, | |||||
| propname, | |||||
| NULL, | |||||
| layout->root->opcontext, | |||||
| icon_only ? UI_ITEM_R_ICON_ONLY : 0); | |||||
| } | } | ||||
| /* for use in cases where we have */ | /* for use in cases where we have */ | ||||
| void uiItemEnumO_value(uiLayout *layout, | void uiItemEnumO_value(uiLayout *layout, | ||||
| const char *name, | const char *name, | ||||
| int icon, | int icon, | ||||
| const char *opname, | const char *opname, | ||||
| const char *propname, | const char *propname, | ||||
| ▲ Show 20 Lines • Show All 1,754 Lines • ▼ Show 20 Lines | typedef struct MenuItemLevel { | ||||
| PointerRNA rnapoin; | PointerRNA rnapoin; | ||||
| } MenuItemLevel; | } MenuItemLevel; | ||||
| static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, void *arg) | static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, void *arg) | ||||
| { | { | ||||
| MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN); | MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN); | ||||
| uiLayoutSetOperatorContext(layout, lvl->opcontext); | uiLayoutSetOperatorContext(layout, lvl->opcontext); | ||||
| uiItemsEnumO(layout, lvl->opname, lvl->propname); | uiItemsEnumO(layout, lvl->opname, lvl->propname, false); | ||||
| layout->root->block->flag |= UI_BLOCK_IS_FLIP; | layout->root->block->flag |= UI_BLOCK_IS_FLIP; | ||||
| /* override default, needed since this was assumed pre 2.70 */ | /* override default, needed since this was assumed pre 2.70 */ | ||||
| UI_block_direction_set(layout->root->block, UI_DIR_DOWN); | UI_block_direction_set(layout->root->block, UI_DIR_DOWN); | ||||
| } | } | ||||
| void uiItemMenuEnumO_ptr(uiLayout *layout, | void uiItemMenuEnumO_ptr(uiLayout *layout, | ||||
| ▲ Show 20 Lines • Show All 329 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (uiItem *, item, &litem->items) { | ||||
| } | } | ||||
| } | } | ||||
| if (min_size_flag) { | if (min_size_flag) { | ||||
| litem->item.flag |= UI_ITEM_FIXED_SIZE; | litem->item.flag |= UI_ITEM_FIXED_SIZE; | ||||
| } | } | ||||
| } | } | ||||
| static void ui_litem_layout_column(uiLayout *litem, bool is_box) | static void ui_litem_layout_column(uiLayout *litem, bool is_box, bool is_menu) | ||||
| { | { | ||||
| int itemh, x, y; | int itemw, itemh, x, y; | ||||
| x = litem->x; | x = litem->x; | ||||
| y = litem->y; | y = litem->y; | ||||
| LISTBASE_FOREACH (uiItem *, item, &litem->items) { | LISTBASE_FOREACH (uiItem *, item, &litem->items) { | ||||
| ui_item_size(item, NULL, &itemh); | ui_item_size(item, &itemw, &itemh); | ||||
| y -= itemh; | y -= itemh; | ||||
| ui_item_position(item, x, y, litem->w, itemh); | ui_item_position(item, x, y, is_menu ? itemw : litem->w, itemh); | ||||
| if (item->next && (!is_box || item != litem->items.first)) { | if (item->next && (!is_box || item != litem->items.first)) { | ||||
| y -= litem->space; | y -= litem->space; | ||||
| } | } | ||||
| if (is_box) { | if (is_box) { | ||||
| item->flag |= UI_ITEM_BOX_ITEM; | item->flag |= UI_ITEM_BOX_ITEM; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | |||||
| static void ui_litem_layout_root(uiLayout *litem) | static void ui_litem_layout_root(uiLayout *litem) | ||||
| { | { | ||||
| if (litem->root->type == UI_LAYOUT_HEADER) { | if (litem->root->type == UI_LAYOUT_HEADER) { | ||||
| ui_litem_layout_row(litem); | ui_litem_layout_row(litem); | ||||
| } | } | ||||
| else if (litem->root->type == UI_LAYOUT_PIEMENU) { | else if (litem->root->type == UI_LAYOUT_PIEMENU) { | ||||
| ui_litem_layout_root_radial(litem); | ui_litem_layout_root_radial(litem); | ||||
| } | } | ||||
| else if (litem->root->type == UI_LAYOUT_MENU) { | |||||
| ui_litem_layout_column(litem, false, true); | |||||
| } | |||||
| else { | else { | ||||
| ui_litem_layout_column(litem, false); | ui_litem_layout_column(litem, false, false); | ||||
| } | } | ||||
| } | } | ||||
| /* box layout */ | /* box layout */ | ||||
| static void ui_litem_estimate_box(uiLayout *litem) | static void ui_litem_estimate_box(uiLayout *litem) | ||||
| { | { | ||||
| const uiStyle *style = litem->root->style; | const uiStyle *style = litem->root->style; | ||||
| Show All 27 Lines | static void ui_litem_layout_box(uiLayout *litem) | ||||
| if (w != 0) { | if (w != 0) { | ||||
| litem->w -= 2 * boxspace; | litem->w -= 2 * boxspace; | ||||
| } | } | ||||
| if (h != 0) { | if (h != 0) { | ||||
| litem->h -= 2 * boxspace; | litem->h -= 2 * boxspace; | ||||
| } | } | ||||
| ui_litem_layout_column(litem, true); | ui_litem_layout_column(litem, true, false); | ||||
| litem->x -= boxspace; | litem->x -= boxspace; | ||||
| litem->y -= boxspace; | litem->y -= boxspace; | ||||
| if (w != 0) { | if (w != 0) { | ||||
| litem->w += 2 * boxspace; | litem->w += 2 * boxspace; | ||||
| } | } | ||||
| if (h != 0) { | if (h != 0) { | ||||
| ▲ Show 20 Lines • Show All 1,244 Lines • ▼ Show 20 Lines | if (!litem->active) { | ||||
| ui_item_flag(litem, UI_BUT_INACTIVE); | ui_item_flag(litem, UI_BUT_INACTIVE); | ||||
| } | } | ||||
| if (!litem->enabled) { | if (!litem->enabled) { | ||||
| ui_item_flag(litem, UI_BUT_DISABLED); | ui_item_flag(litem, UI_BUT_DISABLED); | ||||
| } | } | ||||
| switch (litem->item.type) { | switch (litem->item.type) { | ||||
| case ITEM_LAYOUT_COLUMN: | case ITEM_LAYOUT_COLUMN: | ||||
| ui_litem_layout_column(litem, false); | ui_litem_layout_column(litem, false, false); | ||||
| break; | break; | ||||
| case ITEM_LAYOUT_COLUMN_FLOW: | case ITEM_LAYOUT_COLUMN_FLOW: | ||||
| ui_litem_layout_column_flow(litem); | ui_litem_layout_column_flow(litem); | ||||
| break; | break; | ||||
| case ITEM_LAYOUT_GRID_FLOW: | case ITEM_LAYOUT_GRID_FLOW: | ||||
| ui_litem_layout_grid_flow(litem); | ui_litem_layout_grid_flow(litem); | ||||
| break; | break; | ||||
| case ITEM_LAYOUT_ROW: | case ITEM_LAYOUT_ROW: | ||||
| ▲ Show 20 Lines • Show All 423 Lines • Show Last 20 Lines | |||||