Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 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 (!categories && block->flag & UI_BLOCK_NO_FLIP && title[0]) { | |||||
| /* Title at the top for menus with categories. */ | /* Title at the top for menus with categories. */ | ||||
| uiDefBut(block, | uiDefBut(block, | ||||
| UI_BTYPE_LABEL, | UI_BTYPE_LABEL, | ||||
| 0, | 0, | ||||
| RNA_property_ui_name(but->rnaprop), | title, | ||||
| 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, | ||||
| ""); | ""); | ||||
| 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 && 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 (!categories && !(block->flag & UI_BLOCK_NO_FLIP) && title[0]) { | ||||
HooglyBoogly: I would recommend an explicit comparison to 0 here so it's clear the variable is an int. | |||||
| /* Title at the bottom for menus without categories. */ | /* Title at the bottom for menus without categories. */ | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| uiDefBut(block, | uiDefBut(block, | ||||
| UI_BTYPE_LABEL, | UI_BTYPE_LABEL, | ||||
| 0, | 0, | ||||
| RNA_property_ui_name(but->rnaprop), | title, | ||||
| 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, | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
| const char *str, | const char *str, | ||||
| int x, | int x, | ||||
| int y, | int y, | ||||
| short width, | short width, | ||||
| short height, | short height, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| PropertyRNA *prop, | PropertyRNA *prop, | ||||
| int index, | int index, | ||||
| float min, | float min, | ||||
| Context not available. | |||||
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… | |||||
I would recommend an explicit comparison to 0 here so it's clear the variable is an int.