Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| if (UI_editsource_enable_check()) { | if (UI_editsource_enable_check()) { | ||||
| UI_editsource_active_but_test(but); | UI_editsource_active_but_test(but); | ||||
| } | } | ||||
| #endif | #endif | ||||
| return but; | return but; | ||||
| } | } | ||||
| void ui_def_but_icon(uiBut *but, const int icon, const int flag) | void ui_def_but_icon(uiBut *but, const int icon, const int flag) | ||||
HooglyBoogly: I would recommend an explicit comparison to 0 here so it's clear the variable is an int. | |||||
| { | { | ||||
| if (icon) { | if (icon) { | ||||
| ui_icon_ensure_deferred(but->block->evil_C, icon, (flag & UI_BUT_ICON_PREVIEW) != 0); | ui_icon_ensure_deferred(but->block->evil_C, icon, (flag & UI_BUT_ICON_PREVIEW) != 0); | ||||
| } | } | ||||
| but->icon = (BIFIconID)icon; | but->icon = (BIFIconID)icon; | ||||
| but->flag |= flag; | but->flag |= flag; | ||||
| if (but->str && but->str[0]) { | if (but->str && but->str[0]) { | ||||
| Show All 25 Lines | |||||
| /* see comment in ui_item_enum_expand, re: uiname */ | /* see comment in ui_item_enum_expand, re: uiname */ | ||||
| const EnumPropertyItem *item, *item_array; | const EnumPropertyItem *item, *item_array; | ||||
| bool free; | bool free; | ||||
| uiLayout *split, *column = NULL; | uiLayout *split, *column = NULL; | ||||
| int totitems = 0; | int totitems = 0; | ||||
| int categories = 0; | |||||
| int columns, rows, a, b; | int columns, rows, a, b; | ||||
| int column_end = 0; | int column_end = 0; | ||||
| int nbr_entries_nosepr = 0; | int nbr_entries_nosepr = 0; | ||||
| UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); | UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); | ||||
| RNA_property_enum_items_gettexted( | RNA_property_enum_items_gettexted( | ||||
| block->evil_C, &but->rnapoin, but->rnaprop, &item_array, NULL, &free); | block->evil_C, &but->rnapoin, but->rnaprop, &item_array, NULL, &free); | ||||
| /* we dont want nested rows, cols in menus */ | /* we dont want nested rows, cols in menus */ | ||||
| UI_block_layout_set_current(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| for (item = item_array; item->identifier; item++, totitems++) { | for (item = item_array; item->identifier; item++, totitems++) { | ||||
| if (!item->identifier[0]) { | if (!item->identifier[0]) { | ||||
| /* inconsistent, but menus with categories do not look good flipped */ | /* inconsistent, but menus with categories do not look good flipped */ | ||||
| if (item->name) { | if (item->name) { | ||||
| block->flag |= UI_BLOCK_NO_FLIP; | block->flag |= UI_BLOCK_NO_FLIP; | ||||
| categories++; | |||||
| nbr_entries_nosepr++; | nbr_entries_nosepr++; | ||||
| } | } | ||||
| /* We do not want simple separators in nbr_entries_nosepr count */ | /* We do not want simple separators in nbr_entries_nosepr count */ | ||||
| continue; | continue; | ||||
| } | } | ||||
| nbr_entries_nosepr++; | nbr_entries_nosepr++; | ||||
| } | } | ||||
| Show All 9 Lines | |||||
| rows = totitems / columns; | rows = totitems / columns; | ||||
| if (rows < 1) { | if (rows < 1) { | ||||
| rows = 1; | rows = 1; | ||||
| } | } | ||||
| while (rows * columns < totitems) { | while (rows * columns < totitems) { | ||||
| rows++; | rows++; | ||||
| } | } | ||||
| if (block->flag & UI_BLOCK_NO_FLIP) { | const char *title = RNA_property_ui_name(but->rnaprop); | ||||
| if (title[0] && (categories == 0) && (block->flag & UI_BLOCK_NO_FLIP)) { | |||||
| /* Title at the top for menus with categories. */ | /* Title at the top for menus with categories. */ | ||||
| uiDefBut(block, | uiDefBut( | ||||
| UI_BTYPE_LABEL, | block, UI_BTYPE_LABEL, 0, title, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| 0, | |||||
| RNA_property_ui_name(but->rnaprop), | |||||
| 0, | |||||
| 0, | |||||
| UI_UNIT_X * 5, | |||||
| UI_UNIT_Y, | |||||
| NULL, | |||||
| 0.0, | |||||
| 0.0, | |||||
| 0, | |||||
| 0, | |||||
| ""); | |||||
| uiItemS(layout); | uiItemS(layout); | ||||
| } | } | ||||
| /* note, item_array[...] is reversed on access */ | /* note, item_array[...] is reversed on access */ | ||||
| /* create items */ | /* create items */ | ||||
| split = uiLayoutSplit(layout, 0.0f, false); | split = uiLayoutSplit(layout, 0.0f, false); | ||||
| bool new_column; | |||||
| for (a = 0; a < totitems; a++) { | for (a = 0; a < totitems; a++) { | ||||
| if (a == column_end) { | new_column = (a == column_end); | ||||
| if (new_column) | |||||
| { | |||||
| /* start new column, and find out where it ends in advance, so we | /* start new column, and find out where it ends in advance, so we | ||||
| * can flip the order of items properly per column */ | * can flip the order of items properly per column */ | ||||
| column_end = totitems; | column_end = totitems; | ||||
| for (b = a + 1; b < totitems; b++) { | for (b = a + 1; b < totitems; b++) { | ||||
| item = &item_array[b]; | item = &item_array[b]; | ||||
| /* new column on N rows or on separation label */ | /* new column on N rows or on separation label */ | ||||
| if (((b - a) % rows == 0) || (!item->identifier[0] && item->name)) { | if (((b - a) % rows == 0) || (!item->identifier[0] && item->name)) { | ||||
| column_end = b; | column_end = b; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| column = uiLayoutColumn(split, false); | column = uiLayoutColumn(split, false); | ||||
| } | } | ||||
| item = &item_array[a]; | item = &item_array[a]; | ||||
| if (new_column && (categories > 0) && item->identifier[0]) { | |||||
| uiItemL(column, "", ICON_NONE); | |||||
| uiItemS(column); | |||||
| } | |||||
| if (!item->identifier[0]) { | if (!item->identifier[0]) { | ||||
| if (item->name) { | if (item->name) { | ||||
| if (item->icon) { | if (item->icon) { | ||||
| uiItemL(column, item->name, item->icon); | uiItemL(column, item->name, item->icon); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Do not use uiItemL here, as our root layout is a menu one, | /* Do not use uiItemL here, as our root layout is a menu one, | ||||
| * it will add a fake blank icon! */ | * it will add a fake blank icon! */ | ||||
| uiDefBut(block, | uiDefBut(block, | ||||
| UI_BTYPE_LABEL, | UI_BTYPE_LABEL, | ||||
| 0, | 0, | ||||
| item->name, | item->name, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| UI_UNIT_X * 5, | UI_UNIT_X * 5, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| NULL, | NULL, | ||||
| 0.0, | 0.0, | ||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| ""); | ""); | ||||
| } | } | ||||
| } | |||||
| else { | |||||
| uiItemS(column); | uiItemS(column); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (item->icon) { | if (item->icon) { | ||||
| uiDefIconTextButI(block, | uiDefIconTextButI(block, | ||||
| UI_BTYPE_BUT_MENU, | UI_BTYPE_BUT_MENU, | ||||
| B_NOP, | B_NOP, | ||||
| Show All 24 Lines | |||||
| 0.0, | 0.0, | ||||
| 0, | 0, | ||||
| -1, | -1, | ||||
| item->description); | item->description); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (!(block->flag & UI_BLOCK_NO_FLIP)) { | if (title[0] && (categories == 0) && !(block->flag & UI_BLOCK_NO_FLIP)) { | ||||
| /* Title at the bottom for menus without categories. */ | /* Title at the bottom for menus without categories. */ | ||||
Not Done Inline ActionsIs it intentional that menus without named categories completely lose the capability to have simple separators? angavrilov: Is it intentional that menus without named categories completely lose the capability to have… | |||||
| uiItemS(layout); | uiItemS(layout); | ||||
| uiDefBut(block, | uiDefBut( | ||||
| UI_BTYPE_LABEL, | block, UI_BTYPE_LABEL, 0, title, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| 0, | |||||
| RNA_property_ui_name(but->rnaprop), | |||||
| 0, | |||||
| 0, | |||||
| UI_UNIT_X * 5, | |||||
| UI_UNIT_Y, | |||||
| NULL, | |||||
| 0.0, | |||||
| 0.0, | |||||
| 0, | |||||
| 0, | |||||
| ""); | |||||
| } | } | ||||
| UI_block_layout_set_current(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| if (free) { | if (free) { | ||||
| MEM_freeN((void *)item_array); | MEM_freeN((void *)item_array); | ||||
| } | } | ||||
| BLI_assert((block->flag & UI_BLOCK_IS_FLIP) == 0); | BLI_assert((block->flag & UI_BLOCK_IS_FLIP) == 0); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||
I would recommend an explicit comparison to 0 here so it's clear the variable is an int.