Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_layout.c
| Show First 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool compact) | ||||
| if (icon && !name[0]) | if (icon && !name[0]) | ||||
| return UI_UNIT_X; /* icon only */ | return UI_UNIT_X; /* icon only */ | ||||
| variable = (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X); | variable = (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X); | ||||
| if (variable) { | if (variable) { | ||||
| /* it may seem odd that the icon only adds (UI_UNIT_X / 4) | /* it may seem odd that the icon only adds (UI_UNIT_X / 4) | ||||
| * but taking margins into account its fine */ | * but taking margins into account its fine */ | ||||
| return (UI_GetStringWidth(name) + | return (UI_fontstyle_string_width(name) + | ||||
| (UI_UNIT_X * ((compact ? 1.25f : 1.50f) + | (UI_UNIT_X * ((compact ? 1.25f : 1.50f) + | ||||
| (icon ? 0.25f : 0.0f)))); | (icon ? 0.25f : 0.0f)))); | ||||
| } | } | ||||
| else { | else { | ||||
| return UI_UNIT_X * 10; | return UI_UNIT_X * 10; | ||||
| } | } | ||||
| } | } | ||||
| Show All 32 Lines | static void ui_item_position(uiItem *item, int x, int y, int w, int h) | ||||
| if (item->type == ITEM_BUTTON) { | if (item->type == ITEM_BUTTON) { | ||||
| uiButtonItem *bitem = (uiButtonItem *)item; | uiButtonItem *bitem = (uiButtonItem *)item; | ||||
| bitem->but->rect.xmin = x; | bitem->but->rect.xmin = x; | ||||
| bitem->but->rect.ymin = y; | bitem->but->rect.ymin = y; | ||||
| bitem->but->rect.xmax = x + w; | bitem->but->rect.xmax = x + w; | ||||
| bitem->but->rect.ymax = y + h; | bitem->but->rect.ymax = y + h; | ||||
| ui_check_but(bitem->but); /* for strlen */ | ui_but_update(bitem->but); /* for strlen */ | ||||
| } | } | ||||
| else { | else { | ||||
| uiLayout *litem = (uiLayout *)item; | uiLayout *litem = (uiLayout *)item; | ||||
| litem->x = x; | litem->x = x; | ||||
| litem->y = y + h; | litem->y = y + h; | ||||
| litem->w = w; | litem->w = w; | ||||
| litem->h = h; | litem->h = h; | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if (!shift) { | ||||
| for (i = 0; i < len; i++) | for (i = 0; i < len; i++) | ||||
| if (i != index) | if (i != index) | ||||
| RNA_property_boolean_set_index(ptr, prop, i, 0); | RNA_property_boolean_set_index(ptr, prop, i, 0); | ||||
| RNA_property_update(C, ptr, prop); | RNA_property_update(C, ptr, prop); | ||||
| for (cbut = but->block->buttons.first; cbut; cbut = cbut->next) | for (cbut = but->block->buttons.first; cbut; cbut = cbut->next) | ||||
| ui_check_but(cbut); | ui_but_update(cbut); | ||||
| } | } | ||||
| } | } | ||||
| /* create buttons for an item with an RNA array */ | /* create buttons for an item with an RNA array */ | ||||
| static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, int icon, | static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, int icon, | ||||
| PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h), | PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h), | ||||
| int expand, int slider, int toggle, int icon_only) | int expand, int slider, int toggle, int icon_only) | ||||
| { | { | ||||
| uiStyle *style = layout->root->style; | uiStyle *style = layout->root->style; | ||||
| uiBut *but; | uiBut *but; | ||||
| PropertyType type; | PropertyType type; | ||||
| PropertySubType subtype; | PropertySubType subtype; | ||||
| uiLayout *sub; | uiLayout *sub; | ||||
| unsigned int a, b; | unsigned int a, b; | ||||
| /* retrieve type and subtype */ | /* retrieve type and subtype */ | ||||
| type = RNA_property_type(prop); | type = RNA_property_type(prop); | ||||
| subtype = RNA_property_subtype(prop); | subtype = RNA_property_subtype(prop); | ||||
| sub = ui_item_local_sublayout(layout, layout, 1); | sub = ui_item_local_sublayout(layout, layout, 1); | ||||
| uiBlockSetCurLayout(block, sub); | UI_block_layout_set_current(block, sub); | ||||
| /* create label */ | /* create label */ | ||||
| if (name[0]) | if (name[0]) | ||||
| uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| /* create buttons */ | /* create buttons */ | ||||
| if (type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { | if (type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { | ||||
| /* special check for layer layout */ | /* special check for layer layout */ | ||||
| int butw, buth, unit; | int butw, buth, unit; | ||||
| int cols = (len >= 20) ? 2 : 1; | int cols = (len >= 20) ? 2 : 1; | ||||
| const unsigned int colbuts = len / (2 * cols); | const unsigned int colbuts = len / (2 * cols); | ||||
| unsigned int layer_used = 0; | unsigned int layer_used = 0; | ||||
| unsigned int layer_active = 0; | unsigned int layer_active = 0; | ||||
| uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, false)); | UI_block_layout_set_current(block, uiLayoutAbsolute(layout, false)); | ||||
| unit = UI_UNIT_X * 0.75; | unit = UI_UNIT_X * 0.75; | ||||
| butw = unit; | butw = unit; | ||||
| buth = unit; | buth = unit; | ||||
| if (ptr->type == &RNA_Armature) { | if (ptr->type == &RNA_Armature) { | ||||
| bArmature *arm = (bArmature *)ptr->data; | bArmature *arm = (bArmature *)ptr->data; | ||||
| layer_used = arm->layer_used; | layer_used = arm->layer_used; | ||||
| if (arm->edbo) { | if (arm->edbo) { | ||||
| if (arm->act_edbone) { | if (arm->act_edbone) { | ||||
| layer_active |= arm->act_edbone->layer; | layer_active |= arm->act_edbone->layer; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (arm->act_bone) { | if (arm->act_bone) { | ||||
| layer_active |= arm->act_bone->layer; | layer_active |= arm->act_bone->layer; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (b = 0; b < cols; b++) { | for (b = 0; b < cols; b++) { | ||||
| uiBlockBeginAlign(block); | UI_block_align_begin(block); | ||||
| for (a = 0; a < colbuts; a++) { | for (a = 0; a < colbuts; a++) { | ||||
| const int layer_num = a + b * colbuts; | const int layer_num = a + b * colbuts; | ||||
| const unsigned int layer_flag = (1u << layer_num); | const unsigned int layer_flag = (1u << layer_num); | ||||
| if (layer_used & layer_flag) { | if (layer_used & layer_flag) { | ||||
| if (layer_active & layer_flag) | if (layer_active & layer_flag) | ||||
| icon = ICON_LAYER_ACTIVE; | icon = ICON_LAYER_ACTIVE; | ||||
| else | else | ||||
| icon = ICON_LAYER_USED; | icon = ICON_LAYER_USED; | ||||
| } | } | ||||
| else { | else { | ||||
| icon = ICON_BLANK1; | icon = ICON_BLANK1; | ||||
| } | } | ||||
| but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); | but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth); | ||||
| if (subtype == PROP_LAYER_MEMBER) | if (subtype == PROP_LAYER_MEMBER) | ||||
| uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); | UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); | ||||
| } | } | ||||
| for (a = 0; a < colbuts; a++) { | for (a = 0; a < colbuts; a++) { | ||||
| const int layer_num = a + len / 2 + b * colbuts; | const int layer_num = a + len / 2 + b * colbuts; | ||||
| const unsigned int layer_flag = (1u << layer_num); | const unsigned int layer_flag = (1u << layer_num); | ||||
| if (layer_used & layer_flag) { | if (layer_used & layer_flag) { | ||||
| if (layer_active & layer_flag) | if (layer_active & layer_flag) | ||||
| icon = ICON_LAYER_ACTIVE; | icon = ICON_LAYER_ACTIVE; | ||||
| else | else | ||||
| icon = ICON_LAYER_USED; | icon = ICON_LAYER_USED; | ||||
| } | } | ||||
| else { | else { | ||||
| icon = ICON_BLANK1; | icon = ICON_BLANK1; | ||||
| } | } | ||||
| but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); | but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth); | ||||
| if (subtype == PROP_LAYER_MEMBER) | if (subtype == PROP_LAYER_MEMBER) | ||||
| uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); | UI_but_func_set(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(layer_num)); | ||||
| } | } | ||||
| uiBlockEndAlign(block); | UI_block_align_end(block); | ||||
| x += colbuts * butw + style->buttonspacex; | x += colbuts * butw + style->buttonspacex; | ||||
| } | } | ||||
| } | } | ||||
| else if (subtype == PROP_MATRIX) { | else if (subtype == PROP_MATRIX) { | ||||
| int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */ | int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */ | ||||
| int row, col; | int row, col; | ||||
| uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, true)); | UI_block_layout_set_current(block, uiLayoutAbsolute(layout, true)); | ||||
| totdim = RNA_property_array_dimension(ptr, prop, dim_size); | totdim = RNA_property_array_dimension(ptr, prop, dim_size); | ||||
| if (totdim != 2) return; /* only 2D matrices supported in UI so far */ | if (totdim != 2) return; /* only 2D matrices supported in UI so far */ | ||||
| w /= dim_size[0]; | w /= dim_size[0]; | ||||
| /* h /= dim_size[1]; */ /* UNUSED */ | /* h /= dim_size[1]; */ /* UNUSED */ | ||||
| for (a = 0; a < len; a++) { | for (a = 0; a < len; a++) { | ||||
| col = a % dim_size[0]; | col = a % dim_size[0]; | ||||
| row = a / dim_size[0]; | row = a / dim_size[0]; | ||||
| but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w * col, y + (dim_size[1] * UI_UNIT_Y) - (row * UI_UNIT_Y), w, UI_UNIT_Y); | but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w * col, y + (dim_size[1] * UI_UNIT_Y) - (row * UI_UNIT_Y), w, UI_UNIT_Y); | ||||
| if (slider && but->type == NUM) | if (slider && but->type == UI_BTYPE_NUM) | ||||
| but->type = NUMSLI; | but->type = UI_BTYPE_NUM_SLIDER; | ||||
| } | } | ||||
| } | } | ||||
| else if (subtype == PROP_DIRECTION && !expand) { | else if (subtype == PROP_DIRECTION && !expand) { | ||||
| uiDefButR_prop(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X * 3, UI_UNIT_Y * 3, ptr, prop, 0, 0, 0, -1, -1, NULL); | uiDefButR_prop(block, UI_BTYPE_UNITVEC, 0, name, x, y, UI_UNIT_X * 3, UI_UNIT_Y * 3, ptr, prop, 0, 0, 0, -1, -1, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| /* note, this block of code is a bit arbitrary and has just been made | /* note, this block of code is a bit arbitrary and has just been made | ||||
| * to work with common cases, but may need to be re-worked */ | * to work with common cases, but may need to be re-worked */ | ||||
| /* special case, boolean array in a menu, this could be used in a more generic way too */ | /* special case, boolean array in a menu, this could be used in a more generic way too */ | ||||
| if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) { | if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) { | ||||
| uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); | uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); | ||||
| } | } | ||||
| else { | else { | ||||
| int *boolarr = NULL; | int *boolarr = NULL; | ||||
| /* even if 'expand' is fale, expanding anyway */ | /* even if 'expand' is fale, expanding anyway */ | ||||
| /* layout for known array subtypes */ | /* layout for known array subtypes */ | ||||
| char str[3] = {'\0'}; | char str[3] = {'\0'}; | ||||
| if (!icon_only) { | if (!icon_only) { | ||||
| if (type != PROP_BOOLEAN) { | if (type != PROP_BOOLEAN) { | ||||
| str[1] = ':'; | str[1] = ':'; | ||||
| } | } | ||||
| } | } | ||||
| /* show checkboxes for rna on a non-emboss block (menu for eg) */ | /* show checkboxes for rna on a non-emboss block (menu for eg) */ | ||||
| if (type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSSN, UI_EMBOSSP)) { | if (type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) { | ||||
| boolarr = MEM_callocN(sizeof(int) * len, "ui_item_array"); | boolarr = MEM_callocN(sizeof(int) * len, "ui_item_array"); | ||||
| RNA_property_boolean_get_array(ptr, prop, boolarr); | RNA_property_boolean_get_array(ptr, prop, boolarr); | ||||
| } | } | ||||
| for (a = 0; a < len; a++) { | for (a = 0; a < len; a++) { | ||||
| if (!icon_only) str[0] = RNA_property_array_item_char(prop, a); | if (!icon_only) str[0] = RNA_property_array_item_char(prop, a); | ||||
| if (boolarr) icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; | if (boolarr) icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT; | ||||
| but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y); | but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y); | ||||
| if (slider && but->type == NUM) | if (slider && but->type == UI_BTYPE_NUM) | ||||
| but->type = NUMSLI; | but->type = UI_BTYPE_NUM_SLIDER; | ||||
| if (toggle && but->type == OPTION) | if (toggle && but->type == UI_BTYPE_CHECKBOX) | ||||
| but->type = TOG; | but->type = UI_BTYPE_TOGGLE; | ||||
| if ((a == 0) && (subtype == PROP_AXISANGLE)) | if ((a == 0) && (subtype == PROP_AXISANGLE)) | ||||
| uiButSetUnitType(but, PROP_UNIT_ROTATION); | UI_but_unit_type_set(but, PROP_UNIT_ROTATION); | ||||
| } | } | ||||
| if (boolarr) { | if (boolarr) { | ||||
| MEM_freeN(boolarr); | MEM_freeN(boolarr); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| } | } | ||||
| static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2) | static void ui_item_enum_expand_handle(bContext *C, void *arg1, void *arg2) | ||||
| { | { | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| if (!win->eventstate->shift) { | if (!win->eventstate->shift) { | ||||
| uiBut *but = (uiBut *)arg1; | uiBut *but = (uiBut *)arg1; | ||||
| Show All 31 Lines | static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, | ||||
| if (radial) | if (radial) | ||||
| RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free); | RNA_property_enum_items_gettexted_all(block->evil_C, ptr, prop, &item_array, NULL, &free); | ||||
| else | else | ||||
| RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free); | RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item_array, NULL, &free); | ||||
| /* we dont want nested rows, cols in menus */ | /* we dont want nested rows, cols in menus */ | ||||
| if (radial) { | if (radial) { | ||||
| layout_radial = uiLayoutRadial(layout); | layout_radial = uiLayoutRadial(layout); | ||||
| uiBlockSetCurLayout(block, layout_radial); | UI_block_layout_set_current(block, layout_radial); | ||||
| } | } | ||||
| else if (layout->root->type != UI_LAYOUT_MENU) { | else if (layout->root->type != UI_LAYOUT_MENU) { | ||||
| uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1)); | UI_block_layout_set_current(block, ui_item_local_sublayout(layout, layout, 1)); | ||||
| } | } | ||||
| else { | else { | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| } | } | ||||
| for (item = item_array; item->identifier; item++) { | for (item = item_array; item->identifier; item++) { | ||||
| if (!item->identifier[0]) { | if (!item->identifier[0]) { | ||||
| if (radial) | if (radial) | ||||
| uiItemS(layout_radial); | uiItemS(layout_radial); | ||||
| continue; | continue; | ||||
| } | } | ||||
| name = (!uiname || uiname[0]) ? item->name : ""; | name = (!uiname || uiname[0]) ? item->name : ""; | ||||
| icon = item->icon; | icon = item->icon; | ||||
| value = item->value; | value = item->value; | ||||
| itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0); | itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0); | ||||
| if (icon && name[0] && !icon_only) | if (icon && name[0] && !icon_only) | ||||
| but = uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); | but = uiDefIconTextButR_prop(block, UI_BTYPE_ROW, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); | ||||
| else if (icon) | else if (icon) | ||||
| but = uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); | but = uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); | ||||
| else | else | ||||
| but = uiDefButR_prop(block, ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); | but = uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); | ||||
| if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { | if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { | ||||
| uiButSetFunc(but, ui_item_enum_expand_handle, but, SET_INT_IN_POINTER(value)); | UI_but_func_set(but, ui_item_enum_expand_handle, but, SET_INT_IN_POINTER(value)); | ||||
| } | } | ||||
| if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) | if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) | ||||
| but->drawflag |= UI_BUT_TEXT_LEFT; | but->drawflag |= UI_BUT_TEXT_LEFT; | ||||
| } | } | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| if (free) { | if (free) { | ||||
| MEM_freeN(item_array); | MEM_freeN(item_array); | ||||
| } | } | ||||
| } | } | ||||
| /* callback for keymap item change button */ | /* callback for keymap item change button */ | ||||
| static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_v)) | static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_v)) | ||||
| Show All 11 Lines | |||||
| { | { | ||||
| uiLayout *sub; | uiLayout *sub; | ||||
| uiBut *but = NULL; | uiBut *but = NULL; | ||||
| PropertyType type; | PropertyType type; | ||||
| PropertySubType subtype; | PropertySubType subtype; | ||||
| int labelw; | int labelw; | ||||
| sub = uiLayoutRow(layout, layout->align); | sub = uiLayoutRow(layout, layout->align); | ||||
| uiBlockSetCurLayout(block, sub); | UI_block_layout_set_current(block, sub); | ||||
| if (name[0]) { | if (name[0]) { | ||||
| /* XXX UI_GetStringWidth is not accurate */ | /* XXX UI_fontstyle_string_width is not accurate */ | ||||
| #if 0 | #if 0 | ||||
| labelw = UI_GetStringWidth(name); | labelw = UI_fontstyle_string_width(name); | ||||
| CLAMP(labelw, w / 4, 3 * w / 4); | CLAMP(labelw, w / 4, 3 * w / 4); | ||||
| #endif | #endif | ||||
| labelw = w / 3; | labelw = w / 3; | ||||
| uiDefBut(block, LABEL, 0, name, x, y, labelw, h, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_LABEL, 0, name, x, y, labelw, h, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| w = w - labelw; | w = w - labelw; | ||||
| } | } | ||||
| type = RNA_property_type(prop); | type = RNA_property_type(prop); | ||||
| subtype = RNA_property_subtype(prop); | subtype = RNA_property_subtype(prop); | ||||
| if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { | if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { | ||||
| uiBlockSetCurLayout(block, uiLayoutRow(sub, true)); | UI_block_layout_set_current(block, uiLayoutRow(sub, true)); | ||||
| but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h); | but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h); | ||||
| /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ | /* BUTTONS_OT_file_browse calls UI_context_active_but_prop_get_filebrowser */ | ||||
| uiDefIconButO(block, BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse", | uiDefIconButO(block, UI_BTYPE_BUT, subtype == PROP_DIRPATH ? "BUTTONS_OT_directory_browse" : "BUTTONS_OT_file_browse", | ||||
| WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); | WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); | ||||
| } | } | ||||
| else if (flag & UI_ITEM_R_EVENT) { | else if (flag & UI_ITEM_R_EVENT) { | ||||
| uiDefButR_prop(block, KEYEVT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL); | uiDefButR_prop(block, UI_BTYPE_KEY_EVENT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL); | ||||
| } | } | ||||
| else if (flag & UI_ITEM_R_FULL_EVENT) { | else if (flag & UI_ITEM_R_FULL_EVENT) { | ||||
| if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { | if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { | ||||
| char buf[128]; | char buf[128]; | ||||
| WM_keymap_item_to_string(ptr->data, buf, sizeof(buf)); | WM_keymap_item_to_string(ptr->data, buf, sizeof(buf)); | ||||
| but = uiDefButR_prop(block, HOTKEYEVT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL); | but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL); | ||||
| uiButSetFunc(but, ui_keymap_but_cb, but, NULL); | UI_but_func_set(but, ui_keymap_but_cb, but, NULL); | ||||
| if (flag & UI_ITEM_R_IMMEDIATE) | if (flag & UI_ITEM_R_IMMEDIATE) | ||||
| uiButSetFlag(but, UI_BUT_IMMEDIATE); | UI_but_flag_enable(but, UI_BUT_IMMEDIATE); | ||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| but = uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "", icon, x, y, w, h); | but = uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "", icon, x, y, w, h); | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| return but; | return but; | ||||
| } | } | ||||
| void uiFileBrowseContextProperty(const bContext *C, PointerRNA *ptr, PropertyRNA **prop) | void UI_context_active_but_prop_get_filebrowser(const bContext *C, PointerRNA *ptr, PropertyRNA **prop) | ||||
| { | { | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but, *prevbut; | uiBut *but, *prevbut; | ||||
| memset(ptr, 0, sizeof(*ptr)); | memset(ptr, 0, sizeof(*ptr)); | ||||
| *prop = NULL; | *prop = NULL; | ||||
| Show All 32 Lines | |||||
| /* disabled item */ | /* disabled item */ | ||||
| static void ui_item_disabled(uiLayout *layout, const char *name) | static void ui_item_disabled(uiLayout *layout, const char *name) | ||||
| { | { | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| uiBut *but; | uiBut *but; | ||||
| int w; | int w; | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| if (!name) | if (!name) | ||||
| name = ""; | name = ""; | ||||
| w = ui_text_icon_width(layout, name, 0, 0); | w = ui_text_icon_width(layout, name, 0, 0); | ||||
| but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| but->flag |= UI_BUT_DISABLED; | but->flag |= UI_BUT_DISABLED; | ||||
| but->lock = true; | but->lock = true; | ||||
| but->lockstr = ""; | but->lockstr = ""; | ||||
| } | } | ||||
| /* operator items */ | /* operator items */ | ||||
| PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag) | PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag) | ||||
| { | { | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| uiBut *but; | uiBut *but; | ||||
| int w; | int w; | ||||
| if (!name) { | if (!name) { | ||||
| if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0) | if (ot && ot->srna && (flag & UI_ITEM_R_ICON_ONLY) == 0) | ||||
| name = RNA_struct_ui_name(ot->srna); | name = RNA_struct_ui_name(ot->srna); | ||||
| else | else | ||||
| name = ""; | name = ""; | ||||
| } | } | ||||
| if (layout->root->type == UI_LAYOUT_MENU && !icon) | if (layout->root->type == UI_LAYOUT_MENU && !icon) | ||||
| icon = ICON_BLANK1; | icon = ICON_BLANK1; | ||||
| /* create button */ | /* create button */ | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| w = ui_text_icon_width(layout, name, icon, 0); | w = ui_text_icon_width(layout, name, icon, 0); | ||||
| if (flag & UI_ITEM_R_NO_BG) | if (flag & UI_ITEM_R_NO_BG) | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| /* create the button */ | /* create the button */ | ||||
| if (icon) { | if (icon) { | ||||
| if (name[0]) { | if (name[0]) { | ||||
| but = uiDefIconTextButO_ptr(block, BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL); | but = uiDefIconTextButO_ptr(block, UI_BTYPE_BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefIconButO_ptr(block, BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, NULL); | but = uiDefIconButO_ptr(block, UI_BTYPE_BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, NULL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| but = uiDefButO_ptr(block, BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, NULL); | but = uiDefButO_ptr(block, UI_BTYPE_BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, NULL); | ||||
| } | } | ||||
| assert(but->optype != NULL); | assert(but->optype != NULL); | ||||
| /* text alignment for toolbar buttons */ | /* text alignment for toolbar buttons */ | ||||
| if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) | if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) | ||||
| but->drawflag |= UI_BUT_TEXT_LEFT; | but->drawflag |= UI_BUT_TEXT_LEFT; | ||||
| if (flag & UI_ITEM_R_NO_BG) | if (flag & UI_ITEM_R_NO_BG) | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| if (layout->redalert) | if (layout->redalert) | ||||
| uiButSetFlag(but, UI_BUT_REDALERT); | UI_but_flag_enable(but, UI_BUT_REDALERT); | ||||
| /* assign properties */ | /* assign properties */ | ||||
| if (properties || (flag & UI_ITEM_O_RETURN_PROPS)) { | if (properties || (flag & UI_ITEM_O_RETURN_PROPS)) { | ||||
| PointerRNA *opptr = uiButGetOperatorPtrRNA(but); | PointerRNA *opptr = UI_but_operator_ptr_get(but); | ||||
| if (properties) { | if (properties) { | ||||
| opptr->data = properties; | opptr->data = properties; | ||||
| } | } | ||||
| else { | else { | ||||
| IDPropertyTemplate val = {0}; | IDPropertyTemplate val = {0}; | ||||
| opptr->data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties"); | opptr->data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | for (item = item_array; item->identifier; item++) { | ||||
| if (item->icon || radial) { | if (item->icon || radial) { | ||||
| uiItemL(target, item->name, item->icon); | uiItemL(target, item->name, item->icon); | ||||
| but = block->buttons.last; | but = block->buttons.last; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */ | /* Do not use uiItemL here, as our root layout is a menu one, it will add a fake blank icon! */ | ||||
| but = uiDefBut(block, LABEL, 0, item->name, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, | but = uiDefBut(block, UI_BTYPE_LABEL, 0, item->name, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, | ||||
| 0.0, 0.0, 0, 0, ""); | 0.0, 0.0, 0, 0, ""); | ||||
| } | } | ||||
| ui_but_tip_from_enum_item(but, item); | ui_but_tip_from_enum_item(but, item); | ||||
| } | } | ||||
| else { | else { | ||||
| if (radial) { | if (radial) { | ||||
| uiItemS(target); | uiItemS(target); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| uiBut *but = NULL; | uiBut *but = NULL; | ||||
| PropertyType type; | PropertyType type; | ||||
| char namestr[UI_MAX_NAME_STR]; | char namestr[UI_MAX_NAME_STR]; | ||||
| int len, w, h, slider, toggle, expand, icon_only, no_bg; | int len, w, h, slider, toggle, expand, icon_only, no_bg; | ||||
| bool is_array; | bool is_array; | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| /* retrieve info */ | /* retrieve info */ | ||||
| type = RNA_property_type(prop); | type = RNA_property_type(prop); | ||||
| is_array = RNA_property_array_check(prop); | is_array = RNA_property_array_check(prop); | ||||
| len = (is_array) ? RNA_property_array_length(ptr, prop) : 0; | len = (is_array) ? RNA_property_array_length(ptr, prop) : 0; | ||||
| /* set name and icon */ | /* set name and icon */ | ||||
| if (!name) { | if (!name) { | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, const char *name, int icon) | ||||
| expand = (flag & UI_ITEM_R_EXPAND); | expand = (flag & UI_ITEM_R_EXPAND); | ||||
| icon_only = (flag & UI_ITEM_R_ICON_ONLY); | icon_only = (flag & UI_ITEM_R_ICON_ONLY); | ||||
| no_bg = (flag & UI_ITEM_R_NO_BG); | no_bg = (flag & UI_ITEM_R_NO_BG); | ||||
| /* get size */ | /* get size */ | ||||
| ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h); | ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h); | ||||
| if (no_bg) | if (no_bg) | ||||
| uiBlockSetEmboss(block, UI_EMBOSSN); | UI_block_emboss_set(block, UI_EMBOSS_NONE); | ||||
| /* array property */ | /* array property */ | ||||
| if (index == RNA_NO_INDEX && is_array) | if (index == RNA_NO_INDEX && is_array) | ||||
| ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only); | ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only); | ||||
| /* enum item */ | /* enum item */ | ||||
| else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) { | else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) { | ||||
| if (icon && name[0] && !icon_only) | if (icon && name[0] && !icon_only) | ||||
| uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); | uiDefIconTextButR_prop(block, UI_BTYPE_ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); | ||||
| else if (icon) | else if (icon) | ||||
| uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); | uiDefIconButR_prop(block, UI_BTYPE_ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); | ||||
| else | else | ||||
| uiDefButR_prop(block, ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); | uiDefButR_prop(block, UI_BTYPE_ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); | ||||
| } | } | ||||
| /* expanded enum */ | /* expanded enum */ | ||||
| else if (type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG)) | else if (type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG)) | ||||
| ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only); | ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only); | ||||
| /* property with separate label */ | /* property with separate label */ | ||||
| else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { | else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { | ||||
| but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag); | but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag); | ||||
| ui_but_add_search(but, ptr, prop, NULL, NULL); | ui_but_add_search(but, ptr, prop, NULL, NULL); | ||||
| if (layout->redalert) | if (layout->redalert) | ||||
| uiButSetFlag(but, UI_BUT_REDALERT); | UI_but_flag_enable(but, UI_BUT_REDALERT); | ||||
| } | } | ||||
| /* single button */ | /* single button */ | ||||
| else { | else { | ||||
| but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h); | but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h); | ||||
| if (slider && but->type == NUM) | if (slider && but->type == UI_BTYPE_NUM) | ||||
| but->type = NUMSLI; | but->type = UI_BTYPE_NUM_SLIDER; | ||||
| if (toggle && but->type == OPTION) | if (toggle && but->type == UI_BTYPE_CHECKBOX) | ||||
| but->type = TOG; | but->type = UI_BTYPE_TOGGLE; | ||||
| if (layout->redalert) | if (layout->redalert) | ||||
| uiButSetFlag(but, UI_BUT_REDALERT); | UI_but_flag_enable(but, UI_BUT_REDALERT); | ||||
| } | } | ||||
| /* Mark non-embossed textfields inside a listbox. */ | /* Mark non-embossed textfields inside a listbox. */ | ||||
| if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->type == TEX) && (but->dt & UI_EMBOSSN)) { | if (but && (block->flag & UI_BLOCK_LIST_ITEM) && (but->type == UI_BTYPE_TEXT) && (but->dt & UI_EMBOSS_NONE)) { | ||||
| uiButSetFlag(but, UI_BUT_LIST_ITEM); | UI_but_flag_enable(but, UI_BUT_LIST_ITEM); | ||||
| } | } | ||||
| if (no_bg) | if (no_bg) | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| /* ensure text isn't added to icon_only buttons */ | /* ensure text isn't added to icon_only buttons */ | ||||
| if (but && icon_only) { | if (but && icon_only) { | ||||
| BLI_assert(but->str[0] == '\0'); | BLI_assert(but->str[0] == '\0'); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | #endif | ||||
| i++; | i++; | ||||
| } | } | ||||
| RNA_PROP_END; | RNA_PROP_END; | ||||
| BLI_sortlist(items_list, sort_search_items_list); | BLI_sortlist(items_list, sort_search_items_list); | ||||
| /* add search items from temporary list */ | /* add search items from temporary list */ | ||||
| for (cis = items_list->first; cis; cis = cis->next) { | for (cis = items_list->first; cis; cis = cis->next) { | ||||
| if (false == uiSearchItemAdd(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) { | if (false == UI_search_item_add(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| for (cis = items_list->first; cis; cis = cis->next) { | for (cis = items_list->first; cis; cis = cis->next) { | ||||
| MEM_freeN(cis->name); | MEM_freeN(cis->name); | ||||
| } | } | ||||
| BLI_freelistN(items_list); | BLI_freelistN(items_list); | ||||
| Show All 35 Lines | if (RNA_property_type(prop) == PROP_POINTER) { | ||||
| ptype = RNA_property_pointer_type(ptr, prop); | ptype = RNA_property_pointer_type(ptr, prop); | ||||
| search_id_collection(ptype, &sptr, &searchprop); | search_id_collection(ptype, &sptr, &searchprop); | ||||
| searchptr = &sptr; | searchptr = &sptr; | ||||
| } | } | ||||
| } | } | ||||
| /* turn button into search button */ | /* turn button into search button */ | ||||
| if (searchprop) { | if (searchprop) { | ||||
| but->type = RNA_property_is_unlink(prop) ? SEARCH_MENU_UNLINK : SEARCH_MENU; | but->type = RNA_property_is_unlink(prop) ? UI_BTYPE_SEARCH_MENU_UNLINK : UI_BTYPE_SEARCH_MENU; | ||||
| but->hardmax = MAX2(but->hardmax, 256.0f); | but->hardmax = MAX2(but->hardmax, 256.0f); | ||||
| but->rnasearchpoin = *searchptr; | but->rnasearchpoin = *searchptr; | ||||
| but->rnasearchprop = searchprop; | but->rnasearchprop = searchprop; | ||||
| but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT; | but->drawflag |= UI_BUT_ICON_LEFT | UI_BUT_TEXT_LEFT; | ||||
| if (RNA_property_type(prop) == PROP_ENUM) { | if (RNA_property_type(prop) == PROP_ENUM) { | ||||
| /* XXX, this will have a menu string, | /* XXX, this will have a menu string, | ||||
| * but in this case we just want the text */ | * but in this case we just want the text */ | ||||
| but->str[0] = 0; | but->str[0] = 0; | ||||
| } | } | ||||
| uiButSetSearchFunc(but, rna_search_cb, but, NULL, NULL); | UI_but_func_search_set(but, rna_search_cb, but, NULL, NULL); | ||||
| } | } | ||||
| } | } | ||||
| void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon) | void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *searchptr, const char *searchpropname, const char *name, int icon) | ||||
| { | { | ||||
| PropertyRNA *prop, *searchprop; | PropertyRNA *prop, *searchprop; | ||||
| PropertyType type; | PropertyType type; | ||||
| uiBut *but; | uiBut *but; | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| static uiBut *ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN, | static uiBut *ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN, | ||||
| const char *tip, bool force_menu) | const char *tip, bool force_menu) | ||||
| { | { | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| uiBut *but; | uiBut *but; | ||||
| int w, h; | int w, h; | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| if (layout->root->type == UI_LAYOUT_HEADER) | if (layout->root->type == UI_LAYOUT_HEADER) | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| if (!name) | if (!name) | ||||
| name = ""; | name = ""; | ||||
| if (layout->root->type == UI_LAYOUT_MENU && !icon) | if (layout->root->type == UI_LAYOUT_MENU && !icon) | ||||
| icon = ICON_BLANK1; | icon = ICON_BLANK1; | ||||
| w = ui_text_icon_width(layout, name, icon, 1); | w = ui_text_icon_width(layout, name, icon, 1); | ||||
| h = UI_UNIT_Y; | h = UI_UNIT_Y; | ||||
| Show All 17 Lines | else | ||||
| but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip); | but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip); | ||||
| if (argN) { /* ugly .. */ | if (argN) { /* ugly .. */ | ||||
| but->poin = (char *)but; | but->poin = (char *)but; | ||||
| but->func_argN = argN; | but->func_argN = argN; | ||||
| } | } | ||||
| if (layout->root->type == UI_LAYOUT_HEADER) { | if (layout->root->type == UI_LAYOUT_HEADER) { | ||||
| uiBlockSetEmboss(block, UI_EMBOSS); | UI_block_emboss_set(block, UI_EMBOSS); | ||||
| } | } | ||||
| if (ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR) || | if (ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR) || | ||||
| (force_menu && layout->root->type != UI_LAYOUT_MENU)) /* We never want a dropdown in menu! */ | (force_menu && layout->root->type != UI_LAYOUT_MENU)) /* We never want a dropdown in menu! */ | ||||
| { | { | ||||
| uiButSetMenuFromPulldown(but); | UI_but_type_set_menu_from_pulldown(but); | ||||
| } | } | ||||
| return but; | return but; | ||||
| } | } | ||||
| void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const char *name, int icon) | void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const char *name, int icon) | ||||
| { | { | ||||
| MenuType *mt; | MenuType *mt; | ||||
| Show All 17 Lines | |||||
| /* label item */ | /* label item */ | ||||
| static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) | static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) | ||||
| { | { | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| uiBut *but; | uiBut *but; | ||||
| int w; | int w; | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| if (!name) | if (!name) | ||||
| name = ""; | name = ""; | ||||
| if (layout->root->type == UI_LAYOUT_MENU && !icon) | if (layout->root->type == UI_LAYOUT_MENU && !icon) | ||||
| icon = ICON_BLANK1; | icon = ICON_BLANK1; | ||||
| w = ui_text_icon_width(layout, name, icon, 0); | w = ui_text_icon_width(layout, name, icon, 0); | ||||
| if (icon && name[0]) | if (icon && name[0]) | ||||
| but = uiDefIconTextBut(block, LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | but = uiDefIconTextBut(block, UI_BTYPE_LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| else if (icon) | else if (icon) | ||||
| but = uiDefIconBut(block, LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| else | else | ||||
| but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| /* to compensate for string size padding in ui_text_icon_width, | /* to compensate for string size padding in ui_text_icon_width, | ||||
| * make text aligned right if the layout is aligned right. | * make text aligned right if the layout is aligned right. | ||||
| */ | */ | ||||
| if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) { | if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) { | ||||
| but->drawflag &= ~UI_BUT_TEXT_LEFT; /* default, needs to be unset */ | but->drawflag &= ~UI_BUT_TEXT_LEFT; /* default, needs to be unset */ | ||||
| but->drawflag |= UI_BUT_TEXT_RIGHT; | but->drawflag |= UI_BUT_TEXT_RIGHT; | ||||
| } | } | ||||
| Show All 12 Lines | |||||
| } | } | ||||
| void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon) | void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon) | ||||
| { | { | ||||
| uiBut *but = uiItemL_(layout, name, icon); | uiBut *but = uiItemL_(layout, name, icon); | ||||
| if (ptr && ptr->type) | if (ptr && ptr->type) | ||||
| if (RNA_struct_is_ID(ptr->type)) | if (RNA_struct_is_ID(ptr->type)) | ||||
| uiButSetDragID(but, ptr->id.data); | UI_but_drag_set_id(but, ptr->id.data); | ||||
| } | } | ||||
| /* value item */ | /* value item */ | ||||
| void uiItemV(uiLayout *layout, const char *name, int icon, int argval) | void uiItemV(uiLayout *layout, const char *name, int icon, int argval) | ||||
| { | { | ||||
| /* label */ | /* label */ | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| int *retvalue = (block->handle) ? &block->handle->retvalue : NULL; | int *retvalue = (block->handle) ? &block->handle->retvalue : NULL; | ||||
| int w; | int w; | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| if (!name) | if (!name) | ||||
| name = ""; | name = ""; | ||||
| if (layout->root->type == UI_LAYOUT_MENU && !icon) | if (layout->root->type == UI_LAYOUT_MENU && !icon) | ||||
| icon = ICON_BLANK1; | icon = ICON_BLANK1; | ||||
| w = ui_text_icon_width(layout, name, icon, 0); | w = ui_text_icon_width(layout, name, icon, 0); | ||||
| if (icon && name[0]) | if (icon && name[0]) | ||||
| uiDefIconTextButI(block, BUT, argval, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); | uiDefIconTextButI(block, UI_BTYPE_BUT, argval, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); | ||||
| else if (icon) | else if (icon) | ||||
| uiDefIconButI(block, BUT, argval, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); | uiDefIconButI(block, UI_BTYPE_BUT, argval, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); | ||||
| else | else | ||||
| uiDefButI(block, BUT, argval, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); | uiDefButI(block, UI_BTYPE_BUT, argval, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, -1, ""); | ||||
| } | } | ||||
| /* separator item */ | /* separator item */ | ||||
| void uiItemS(uiLayout *layout) | void uiItemS(uiLayout *layout) | ||||
| { | { | ||||
| uiBlock *block = layout->root->block; | uiBlock *block = layout->root->block; | ||||
| bool is_menu = ui_block_is_menu(block); | bool is_menu = ui_block_is_menu(block); | ||||
| int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X; | int space = (is_menu) ? 0.45f * UI_UNIT_X : 0.3f * UI_UNIT_X; | ||||
| uiBlockSetCurLayout(block, layout); | UI_block_layout_set_current(block, layout); | ||||
| uiDefBut(block, (is_menu) ? SEPRLINE : SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, (is_menu) ? UI_BTYPE_SEPR_LINE : UI_BTYPE_SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| } | } | ||||
| /* level items */ | /* level items */ | ||||
| void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg) | void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg) | ||||
| { | { | ||||
| if (!func) | if (!func) | ||||
| return; | return; | ||||
| Show All 12 Lines | |||||
| 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); | ||||
| /* override default, needed since this was assumed pre 2.70 */ | /* override default, needed since this was assumed pre 2.70 */ | ||||
| uiBlockSetDirection(layout->root->block, UI_DOWN); | UI_block_direction_set(layout->root->block, UI_DIR_DOWN); | ||||
| } | } | ||||
| void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name, int icon) | void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name, int icon) | ||||
| { | { | ||||
| wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ | wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ | ||||
| MenuItemLevel *lvl; | MenuItemLevel *lvl; | ||||
| uiBut *but; | uiBut *but; | ||||
| ▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | static RadialDirection ui_get_radialbut_vec(float vec[2], short itemnum) | ||||
| ui_but_pie_dir(dir, vec); | ui_but_pie_dir(dir, vec); | ||||
| return dir; | return dir; | ||||
| } | } | ||||
| static bool ui_item_is_radial_displayable(uiItem *item) | static bool ui_item_is_radial_displayable(uiItem *item) | ||||
| { | { | ||||
| if ((item->type == ITEM_BUTTON) && (((uiButtonItem *)item)->but->type == LABEL)) | if ((item->type == ITEM_BUTTON) && (((uiButtonItem *)item)->but->type == UI_BTYPE_LABEL)) | ||||
| return false; | return false; | ||||
| return true; | return true; | ||||
| } | } | ||||
| static bool ui_item_is_radial_drawable(uiButtonItem *bitem) | static bool ui_item_is_radial_drawable(uiButtonItem *bitem) | ||||
| { | { | ||||
| if (ELEM(bitem->but->type, SEPR, SEPRLINE)) | if (ELEM(bitem->but->type, UI_BTYPE_SEPR, UI_BTYPE_SEPR_LINE)) | ||||
| return false; | return false; | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void ui_litem_layout_radial(uiLayout *litem) | static void ui_litem_layout_radial(uiLayout *litem) | ||||
| { | { | ||||
| uiItem *item; | uiItem *item; | ||||
| Show All 39 Lines | if (ui_item_is_radial_displayable(item)) { | ||||
| bitem->but->pie_dir = dir; | bitem->but->pie_dir = dir; | ||||
| /* scale the buttons */ | /* scale the buttons */ | ||||
| bitem->but->rect.ymax *= 1.5f; | bitem->but->rect.ymax *= 1.5f; | ||||
| /* add a little bit more here to include number */ | /* add a little bit more here to include number */ | ||||
| bitem->but->rect.xmax += 1.5f * UI_UNIT_X; | bitem->but->rect.xmax += 1.5f * UI_UNIT_X; | ||||
| /* enable drawing as pie item if supported by widget */ | /* enable drawing as pie item if supported by widget */ | ||||
| if (ui_item_is_radial_drawable(bitem)) | if (ui_item_is_radial_drawable(bitem)) | ||||
| bitem->but->dt = UI_EMBOSSR; | bitem->but->dt = UI_EMBOSS_RADIAL; | ||||
| } | } | ||||
| ui_item_size(item, &itemw, &itemh); | ui_item_size(item, &itemw, &itemh); | ||||
| ui_item_position(item, x + vec[0] * pie_radius + factor[0] * itemw, y + vec[1] * pie_radius + factor[1] * itemh, itemw, itemh); | ui_item_position(item, x + vec[0] * pie_radius + factor[0] * itemw, y + vec[1] * pie_radius + factor[1] * itemh, itemw, itemh); | ||||
| minx = min_ii(minx, x + vec[0] * pie_radius - itemw / 2); | minx = min_ii(minx, x + vec[0] * pie_radius - itemw / 2); | ||||
| maxx = max_ii(maxx, x + vec[0] * pie_radius + itemw / 2); | maxx = max_ii(maxx, x + vec[0] * pie_radius + itemw / 2); | ||||
| ▲ Show 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | uiLayout *uiLayoutRow(uiLayout *layout, int align) | ||||
| litem->active = true; | litem->active = true; | ||||
| litem->enabled = true; | litem->enabled = true; | ||||
| litem->context = layout->context; | litem->context = layout->context; | ||||
| litem->space = (align) ? 0 : layout->root->style->buttonspacex; | litem->space = (align) ? 0 : layout->root->style->buttonspacex; | ||||
| litem->redalert = layout->redalert; | litem->redalert = layout->redalert; | ||||
| litem->w = layout->w; | litem->w = layout->w; | ||||
| BLI_addtail(&layout->items, litem); | BLI_addtail(&layout->items, litem); | ||||
| uiBlockSetCurLayout(layout->root->block, litem); | UI_block_layout_set_current(layout->root->block, litem); | ||||
| return litem; | return litem; | ||||
| } | } | ||||
| uiLayout *uiLayoutColumn(uiLayout *layout, int align) | uiLayout *uiLayoutColumn(uiLayout *layout, int align) | ||||
| { | { | ||||
| uiLayout *litem; | uiLayout *litem; | ||||
| litem = MEM_callocN(sizeof(uiLayout), "uiLayoutColumn"); | litem = MEM_callocN(sizeof(uiLayout), "uiLayoutColumn"); | ||||
| litem->item.type = ITEM_LAYOUT_COLUMN; | litem->item.type = ITEM_LAYOUT_COLUMN; | ||||
| litem->root = layout->root; | litem->root = layout->root; | ||||
| litem->align = align; | litem->align = align; | ||||
| litem->active = true; | litem->active = true; | ||||
| litem->enabled = true; | litem->enabled = true; | ||||
| litem->context = layout->context; | litem->context = layout->context; | ||||
| litem->space = (litem->align) ? 0 : layout->root->style->buttonspacey; | litem->space = (litem->align) ? 0 : layout->root->style->buttonspacey; | ||||
| litem->redalert = layout->redalert; | litem->redalert = layout->redalert; | ||||
| litem->w = layout->w; | litem->w = layout->w; | ||||
| BLI_addtail(&layout->items, litem); | BLI_addtail(&layout->items, litem); | ||||
| uiBlockSetCurLayout(layout->root->block, litem); | UI_block_layout_set_current(layout->root->block, litem); | ||||
| return litem; | return litem; | ||||
| } | } | ||||
| uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align) | uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align) | ||||
| { | { | ||||
| uiLayoutItemFlow *flow; | uiLayoutItemFlow *flow; | ||||
| flow = MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow"); | flow = MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow"); | ||||
| flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW; | flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW; | ||||
| flow->litem.root = layout->root; | flow->litem.root = layout->root; | ||||
| flow->litem.align = align; | flow->litem.align = align; | ||||
| flow->litem.active = true; | flow->litem.active = true; | ||||
| flow->litem.enabled = true; | flow->litem.enabled = true; | ||||
| flow->litem.context = layout->context; | flow->litem.context = layout->context; | ||||
| flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace; | flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace; | ||||
| flow->litem.redalert = layout->redalert; | flow->litem.redalert = layout->redalert; | ||||
| flow->litem.w = layout->w; | flow->litem.w = layout->w; | ||||
| flow->number = number; | flow->number = number; | ||||
| BLI_addtail(&layout->items, flow); | BLI_addtail(&layout->items, flow); | ||||
| uiBlockSetCurLayout(layout->root->block, &flow->litem); | UI_block_layout_set_current(layout->root->block, &flow->litem); | ||||
| return &flow->litem; | return &flow->litem; | ||||
| } | } | ||||
| static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type) | static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type) | ||||
| { | { | ||||
| uiLayoutItemBx *box; | uiLayoutItemBx *box; | ||||
| box = MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx"); | box = MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx"); | ||||
| box->litem.item.type = ITEM_LAYOUT_BOX; | box->litem.item.type = ITEM_LAYOUT_BOX; | ||||
| box->litem.root = layout->root; | box->litem.root = layout->root; | ||||
| box->litem.active = 1; | box->litem.active = 1; | ||||
| box->litem.enabled = 1; | box->litem.enabled = 1; | ||||
| box->litem.context = layout->context; | box->litem.context = layout->context; | ||||
| box->litem.space = layout->root->style->columnspace; | box->litem.space = layout->root->style->columnspace; | ||||
| box->litem.redalert = layout->redalert; | box->litem.redalert = layout->redalert; | ||||
| box->litem.w = layout->w; | box->litem.w = layout->w; | ||||
| BLI_addtail(&layout->items, box); | BLI_addtail(&layout->items, box); | ||||
| uiBlockSetCurLayout(layout->root->block, &box->litem); | UI_block_layout_set_current(layout->root->block, &box->litem); | ||||
| box->roundbox = uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, ""); | box->roundbox = uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| return box; | return box; | ||||
| } | } | ||||
| uiLayout *uiLayoutRadial(uiLayout *layout) | uiLayout *uiLayoutRadial(uiLayout *layout) | ||||
| { | { | ||||
| uiLayout *litem; | uiLayout *litem; | ||||
| uiItem *item; | uiItem *item; | ||||
| /* radial layouts are only valid for radial menus */ | /* radial layouts are only valid for radial menus */ | ||||
| if (layout->root->type != UI_LAYOUT_PIEMENU) | if (layout->root->type != UI_LAYOUT_PIEMENU) | ||||
| return ui_item_local_sublayout(layout, layout, 0); | return ui_item_local_sublayout(layout, layout, 0); | ||||
| /* only one radial wheel per root layout is allowed, so check and return that, if it exists */ | /* only one radial wheel per root layout is allowed, so check and return that, if it exists */ | ||||
| for (item = layout->root->layout->items.first; item; item = item->next) { | for (item = layout->root->layout->items.first; item; item = item->next) { | ||||
| litem = (uiLayout *)item; | litem = (uiLayout *)item; | ||||
| if (litem->item.type == ITEM_LAYOUT_RADIAL) { | if (litem->item.type == ITEM_LAYOUT_RADIAL) { | ||||
| uiBlockSetCurLayout(layout->root->block, litem); | UI_block_layout_set_current(layout->root->block, litem); | ||||
| return litem; | return litem; | ||||
| } | } | ||||
| } | } | ||||
| litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRadial"); | litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRadial"); | ||||
| litem->item.type = ITEM_LAYOUT_RADIAL; | litem->item.type = ITEM_LAYOUT_RADIAL; | ||||
| litem->root = layout->root; | litem->root = layout->root; | ||||
| litem->active = true; | litem->active = true; | ||||
| litem->enabled = true; | litem->enabled = true; | ||||
| litem->context = layout->context; | litem->context = layout->context; | ||||
| litem->redalert = layout->redalert; | litem->redalert = layout->redalert; | ||||
| litem->w = layout->w; | litem->w = layout->w; | ||||
| BLI_addtail(&layout->root->layout->items, litem); | BLI_addtail(&layout->root->layout->items, litem); | ||||
| uiBlockSetCurLayout(layout->root->block, litem); | UI_block_layout_set_current(layout->root->block, litem); | ||||
| return litem; | return litem; | ||||
| } | } | ||||
| uiLayout *uiLayoutBox(uiLayout *layout) | uiLayout *uiLayoutBox(uiLayout *layout) | ||||
| { | { | ||||
| return (uiLayout *)ui_layout_box(layout, ROUNDBOX); | return (uiLayout *)ui_layout_box(layout, UI_BTYPE_ROUNDBOX); | ||||
| } | } | ||||
| /* Check all buttons defined in this layout, and set any button flagged as UI_BUT_LIST_ITEM as active/selected. | /* Check all buttons defined in this layout, and set any button flagged as UI_BUT_LIST_ITEM as active/selected. | ||||
| * Needed to handle correctly text colors of active (selected) list item. | * Needed to handle correctly text colors of active (selected) list item. | ||||
| */ | */ | ||||
| void ui_layout_list_set_labels_active(uiLayout *layout) | void ui_layout_list_set_labels_active(uiLayout *layout) | ||||
| { | { | ||||
| uiButtonItem *bitem; | uiButtonItem *bitem; | ||||
| for (bitem = layout->items.first; bitem; bitem = bitem->item.next) { | for (bitem = layout->items.first; bitem; bitem = bitem->item.next) { | ||||
| if (bitem->item.type != ITEM_BUTTON) { | if (bitem->item.type != ITEM_BUTTON) { | ||||
| ui_layout_list_set_labels_active((uiLayout *)(&bitem->item)); | ui_layout_list_set_labels_active((uiLayout *)(&bitem->item)); | ||||
| } | } | ||||
| else if (bitem->but->flag & UI_BUT_LIST_ITEM) { | else if (bitem->but->flag & UI_BUT_LIST_ITEM) { | ||||
| uiButSetFlag(bitem->but, UI_SELECT); | UI_but_flag_enable(bitem->but, UI_SELECT); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| uiLayout *uiLayoutListBox(uiLayout *layout, uiList *ui_list, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *actptr, | uiLayout *uiLayoutListBox(uiLayout *layout, uiList *ui_list, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *actptr, | ||||
| PropertyRNA *actprop) | PropertyRNA *actprop) | ||||
| { | { | ||||
| uiLayoutItemBx *box = ui_layout_box(layout, LISTBOX); | uiLayoutItemBx *box = ui_layout_box(layout, UI_BTYPE_LISTBOX); | ||||
| uiBut *but = box->roundbox; | uiBut *but = box->roundbox; | ||||
| but->custom_data = ui_list; | but->custom_data = ui_list; | ||||
| but->rnasearchpoin = *ptr; | but->rnasearchpoin = *ptr; | ||||
| but->rnasearchprop = prop; | but->rnasearchprop = prop; | ||||
| but->rnapoin = *actptr; | but->rnapoin = *actptr; | ||||
| but->rnaprop = actprop; | but->rnaprop = actprop; | ||||
| Show All 15 Lines | uiLayout *uiLayoutAbsolute(uiLayout *layout, int align) | ||||
| litem->root = layout->root; | litem->root = layout->root; | ||||
| litem->align = align; | litem->align = align; | ||||
| litem->active = 1; | litem->active = 1; | ||||
| litem->enabled = 1; | litem->enabled = 1; | ||||
| litem->context = layout->context; | litem->context = layout->context; | ||||
| litem->redalert = layout->redalert; | litem->redalert = layout->redalert; | ||||
| BLI_addtail(&layout->items, litem); | BLI_addtail(&layout->items, litem); | ||||
| uiBlockSetCurLayout(layout->root->block, litem); | UI_block_layout_set_current(layout->root->block, litem); | ||||
| return litem; | return litem; | ||||
| } | } | ||||
| uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout) | uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout) | ||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| Show All 11 Lines | uiLayout *uiLayoutOverlap(uiLayout *layout) | ||||
| litem->item.type = ITEM_LAYOUT_OVERLAP; | litem->item.type = ITEM_LAYOUT_OVERLAP; | ||||
| litem->root = layout->root; | litem->root = layout->root; | ||||
| litem->active = true; | litem->active = true; | ||||
| litem->enabled = true; | litem->enabled = true; | ||||
| litem->context = layout->context; | litem->context = layout->context; | ||||
| litem->redalert = layout->redalert; | litem->redalert = layout->redalert; | ||||
| BLI_addtail(&layout->items, litem); | BLI_addtail(&layout->items, litem); | ||||
| uiBlockSetCurLayout(layout->root->block, litem); | UI_block_layout_set_current(layout->root->block, litem); | ||||
| return litem; | return litem; | ||||
| } | } | ||||
| uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) | uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) | ||||
| { | { | ||||
| uiLayoutItemSplit *split; | uiLayoutItemSplit *split; | ||||
| split = MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit"); | split = MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit"); | ||||
| split->litem.item.type = ITEM_LAYOUT_SPLIT; | split->litem.item.type = ITEM_LAYOUT_SPLIT; | ||||
| split->litem.root = layout->root; | split->litem.root = layout->root; | ||||
| split->litem.align = align; | split->litem.align = align; | ||||
| split->litem.active = true; | split->litem.active = true; | ||||
| split->litem.enabled = true; | split->litem.enabled = true; | ||||
| split->litem.context = layout->context; | split->litem.context = layout->context; | ||||
| split->litem.space = layout->root->style->columnspace; | split->litem.space = layout->root->style->columnspace; | ||||
| split->litem.redalert = layout->redalert; | split->litem.redalert = layout->redalert; | ||||
| split->litem.w = layout->w; | split->litem.w = layout->w; | ||||
| split->percentage = percentage; | split->percentage = percentage; | ||||
| BLI_addtail(&layout->items, split); | BLI_addtail(&layout->items, split); | ||||
| uiBlockSetCurLayout(layout->root->block, &split->litem); | UI_block_layout_set_current(layout->root->block, &split->litem); | ||||
| return &split->litem; | return &split->litem; | ||||
| } | } | ||||
| void uiLayoutSetActive(uiLayout *layout, bool active) | void uiLayoutSetActive(uiLayout *layout, bool active) | ||||
| { | { | ||||
| layout->active = active; | layout->active = active; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | if (item->type != ITEM_BUTTON) { | ||||
| for (subitem = litem->items.first; subitem; subitem = subitem->next) | for (subitem = litem->items.first; subitem; subitem = subitem->next) | ||||
| ui_item_layout(subitem); | ui_item_layout(subitem); | ||||
| } | } | ||||
| } | } | ||||
| static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y) | static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y) | ||||
| { | { | ||||
| if (layout->root->handlefunc) | if (layout->root->handlefunc) | ||||
| uiBlockSetHandleFunc(block, layout->root->handlefunc, layout->root->argv); | UI_block_func_handle_set(block, layout->root->handlefunc, layout->root->argv); | ||||
| ui_item_estimate(&layout->item); | ui_item_estimate(&layout->item); | ||||
| ui_item_layout(&layout->item); | ui_item_layout(&layout->item); | ||||
| if (x) *x = layout->x; | if (x) *x = layout->x; | ||||
| if (y) *y = layout->y; | if (y) *y = layout->y; | ||||
| } | } | ||||
| Show All 16 Lines | |||||
| static void ui_layout_add_padding_button(uiLayoutRoot *root) | static void ui_layout_add_padding_button(uiLayoutRoot *root) | ||||
| { | { | ||||
| if (root->padding) { | if (root->padding) { | ||||
| /* add an invisible button for padding */ | /* add an invisible button for padding */ | ||||
| uiBlock *block = root->block; | uiBlock *block = root->block; | ||||
| uiLayout *prev_layout = block->curlayout; | uiLayout *prev_layout = block->curlayout; | ||||
| block->curlayout = root->layout; | block->curlayout = root->layout; | ||||
| uiDefBut(block, SEPR, 0, "", 0, 0, root->padding, root->padding, NULL, 0.0, 0.0, 0, 0, ""); | uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, root->padding, root->padding, NULL, 0.0, 0.0, 0, 0, ""); | ||||
| block->curlayout = prev_layout; | block->curlayout = prev_layout; | ||||
| } | } | ||||
| } | } | ||||
| uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, uiStyle *style) | uiLayout *UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, uiStyle *style) | ||||
| { | { | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| uiLayoutRoot *root; | uiLayoutRoot *root; | ||||
| root = MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot"); | root = MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot"); | ||||
| root->type = type; | root->type = type; | ||||
| root->style = style; | root->style = style; | ||||
| root->block = block; | root->block = block; | ||||
| Show All 38 Lines | |||||
| } | } | ||||
| int uiLayoutGetOperatorContext(uiLayout *layout) | int uiLayoutGetOperatorContext(uiLayout *layout) | ||||
| { | { | ||||
| return layout->root->opcontext; | return layout->root->opcontext; | ||||
| } | } | ||||
| void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout) | void UI_block_layout_set_current(uiBlock *block, uiLayout *layout) | ||||
| { | { | ||||
| block->curlayout = layout; | block->curlayout = layout; | ||||
| } | } | ||||
| void ui_layout_add_but(uiLayout *layout, uiBut *but) | void ui_layout_add_but(uiLayout *layout, uiBut *but) | ||||
| { | { | ||||
| uiButtonItem *bitem; | uiButtonItem *bitem; | ||||
| Show All 14 Lines | |||||
| } | } | ||||
| void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv) | void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv) | ||||
| { | { | ||||
| layout->root->handlefunc = handlefunc; | layout->root->handlefunc = handlefunc; | ||||
| layout->root->argv = argv; | layout->root->argv = argv; | ||||
| } | } | ||||
| void uiBlockLayoutResolve(uiBlock *block, int *x, int *y) | void UI_block_layout_resolve(uiBlock *block, int *x, int *y) | ||||
| { | { | ||||
| uiLayoutRoot *root; | uiLayoutRoot *root; | ||||
| BLI_assert(block->active); | BLI_assert(block->active); | ||||
| if (x) *x = 0; | if (x) *x = 0; | ||||
| if (y) *y = 0; | if (y) *y = 0; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | static void ui_intro_items(DynStr *ds, ListBase *lb) | ||||
| for (item = lb->first; item; item = item->next) { | for (item = lb->first; item; item = item->next) { | ||||
| BLI_dynstr_append(ds, "{"); | BLI_dynstr_append(ds, "{"); | ||||
| /* could also use the INT but this is nicer*/ | /* could also use the INT but this is nicer*/ | ||||
| switch (item->type) { | switch (item->type) { | ||||
| case ITEM_BUTTON: BLI_dynstr_append(ds, "'type':'BUTTON', "); break; | case ITEM_BUTTON: BLI_dynstr_append(ds, "'type':'BUTTON', "); break; | ||||
| case ITEM_LAYOUT_ROW: BLI_dynstr_append(ds, "'type':'ROW', "); break; | case ITEM_LAYOUT_ROW: BLI_dynstr_append(ds, "'type':'UI_BTYPE_ROW', "); break; | ||||
| case ITEM_LAYOUT_COLUMN: BLI_dynstr_append(ds, "'type':'COLUMN', "); break; | case ITEM_LAYOUT_COLUMN: BLI_dynstr_append(ds, "'type':'COLUMN', "); break; | ||||
| case ITEM_LAYOUT_COLUMN_FLOW: BLI_dynstr_append(ds, "'type':'COLUMN_FLOW', "); break; | case ITEM_LAYOUT_COLUMN_FLOW: BLI_dynstr_append(ds, "'type':'COLUMN_FLOW', "); break; | ||||
| case ITEM_LAYOUT_ROW_FLOW: BLI_dynstr_append(ds, "'type':'ROW_FLOW', "); break; | case ITEM_LAYOUT_ROW_FLOW: BLI_dynstr_append(ds, "'type':'ROW_FLOW', "); break; | ||||
| case ITEM_LAYOUT_BOX: BLI_dynstr_append(ds, "'type':'BOX', "); break; | case ITEM_LAYOUT_BOX: BLI_dynstr_append(ds, "'type':'BOX', "); break; | ||||
| case ITEM_LAYOUT_ABSOLUTE: BLI_dynstr_append(ds, "'type':'ABSOLUTE', "); break; | case ITEM_LAYOUT_ABSOLUTE: BLI_dynstr_append(ds, "'type':'ABSOLUTE', "); break; | ||||
| case ITEM_LAYOUT_SPLIT: BLI_dynstr_append(ds, "'type':'SPLIT', "); break; | case ITEM_LAYOUT_SPLIT: BLI_dynstr_append(ds, "'type':'SPLIT', "); break; | ||||
| case ITEM_LAYOUT_OVERLAP: BLI_dynstr_append(ds, "'type':'OVERLAP', "); break; | case ITEM_LAYOUT_OVERLAP: BLI_dynstr_append(ds, "'type':'OVERLAP', "); break; | ||||
| case ITEM_LAYOUT_ROOT: BLI_dynstr_append(ds, "'type':'ROOT', "); break; | case ITEM_LAYOUT_ROOT: BLI_dynstr_append(ds, "'type':'ROOT', "); break; | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, | ||||
| if (flag & UI_LAYOUT_OP_SHOW_TITLE) { | if (flag & UI_LAYOUT_OP_SHOW_TITLE) { | ||||
| uiItemL(layout, RNA_struct_ui_name(op->type->srna), ICON_NONE); | uiItemL(layout, RNA_struct_ui_name(op->type->srna), ICON_NONE); | ||||
| } | } | ||||
| /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens | /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens | ||||
| * just fails silently */ | * just fails silently */ | ||||
| if (!WM_operator_repeat_check(C, op)) { | if (!WM_operator_repeat_check(C, op)) { | ||||
| uiBlockSetButLock(uiLayoutGetBlock(layout), true, "Operator can't' redo"); | UI_block_lock_set(uiLayoutGetBlock(layout), true, "Operator can't' redo"); | ||||
| /* XXX, could give some nicer feedback or not show redo panel at all? */ | /* XXX, could give some nicer feedback or not show redo panel at all? */ | ||||
| uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE); | uiItemL(layout, IFACE_("* Redo Unsupported *"), ICON_NONE); | ||||
| } | } | ||||
| /* menu */ | /* menu */ | ||||
| if (op->type->flag & OPTYPE_PRESET) { | if (op->type->flag & OPTYPE_PRESET) { | ||||
| /* XXX, no simple way to get WM_MT_operator_presets.bl_label from python! Label remains the same always! */ | /* XXX, no simple way to get WM_MT_operator_presets.bl_label from python! Label remains the same always! */ | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | #ifdef USE_OP_RESET_BUT | ||||
| * (which isn't all that likely anyway) - campbell */ | * (which isn't all that likely anyway) - campbell */ | ||||
| if (op->properties->len) { | if (op->properties->len) { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiBut *but; | uiBut *but; | ||||
| uiLayout *col; /* needed to avoid alignment errors with previous buttons */ | uiLayout *col; /* needed to avoid alignment errors with previous buttons */ | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| block = uiLayoutGetBlock(col); | block = uiLayoutGetBlock(col); | ||||
| but = uiDefIconTextBut(block, BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, UI_UNIT_X, UI_UNIT_Y, | but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, UI_UNIT_X, UI_UNIT_Y, | ||||
| NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults")); | NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults")); | ||||
| uiButSetFunc(but, ui_layout_operator_buts__reset_cb, op, NULL); | UI_but_func_set(but, ui_layout_operator_buts__reset_cb, op, NULL); | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* set various special settings for buttons */ | /* set various special settings for buttons */ | ||||
| { | { | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; | const bool is_popup = (block->flag & UI_BLOCK_KEEP_OPEN) != 0; | ||||
| uiBut *but; | uiBut *but; | ||||
| for (but = block->buttons.first; but; but = but->next) { | for (but = block->buttons.first; but; but = but->next) { | ||||
| /* no undo for buttons for operator redo panels */ | /* no undo for buttons for operator redo panels */ | ||||
| uiButClearFlag(but, UI_BUT_UNDO); | UI_but_flag_disable(but, UI_BUT_UNDO); | ||||
| /* only for popups, see [#36109] */ | /* only for popups, see [#36109] */ | ||||
| /* if button is operator's default property, and a text-field, enable focus for it | /* if button is operator's default property, and a text-field, enable focus for it | ||||
| * - this is used for allowing operators with popups to rename stuff with fewer clicks | * - this is used for allowing operators with popups to rename stuff with fewer clicks | ||||
| */ | */ | ||||
| if (is_popup) { | if (is_popup) { | ||||
| if ((but->rnaprop == op->type->prop) && (but->type == TEX)) { | if ((but->rnaprop == op->type->prop) && (but->type == UI_BTYPE_TEXT)) { | ||||
| uiButSetFocusOnEnter(CTX_wm_window(C), but); | UI_but_focus_on_enter_event(CTX_wm_window(C), but); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* this is a bit of a hack but best keep it in one place at least */ | /* this is a bit of a hack but best keep it in one place at least */ | ||||
| MenuType *uiButGetMenuType(uiBut *but) | MenuType *UI_but_menutype_get(uiBut *but) | ||||
| { | { | ||||
| if (but->menu_create_func == ui_item_menutype_func) { | if (but->menu_create_func == ui_item_menutype_func) { | ||||
| return (MenuType *)but->poin; | return (MenuType *)but->poin; | ||||
| } | } | ||||
| else { | else { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| } | } | ||||