Cleanup: Declare variables where initialized
Also reduce the scope of some variable declarations. This also allows making some variables constant.
This commit is contained in:
@@ -312,16 +312,13 @@ static bool ui_layout_variable_size(uiLayout *layout)
|
|||||||
/* estimated size of text + icon */
|
/* estimated size of text + icon */
|
||||||
static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool compact)
|
static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool compact)
|
||||||
{
|
{
|
||||||
bool variable;
|
|
||||||
const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
|
const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
|
||||||
|
|
||||||
if (icon && !name[0]) {
|
if (icon && !name[0]) {
|
||||||
return unit_x; /* icon only */
|
return unit_x; /* icon only */
|
||||||
}
|
}
|
||||||
|
|
||||||
variable = ui_layout_variable_size(layout);
|
if (ui_layout_variable_size(layout)) {
|
||||||
|
|
||||||
if (variable) {
|
|
||||||
if (!icon && !name[0]) {
|
if (!icon && !name[0]) {
|
||||||
return unit_x; /* No icon or name. */
|
return unit_x; /* No icon or name. */
|
||||||
}
|
}
|
||||||
@@ -510,7 +507,6 @@ int uiLayoutGetLocalDir(const uiLayout *layout)
|
|||||||
static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, bool align)
|
static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, bool align)
|
||||||
{
|
{
|
||||||
uiLayout *sub;
|
uiLayout *sub;
|
||||||
|
|
||||||
if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL) {
|
if (uiLayoutGetLocalDir(test) == UI_LAYOUT_HORIZONTAL) {
|
||||||
sub = uiLayoutRow(layout, align);
|
sub = uiLayoutRow(layout, align);
|
||||||
}
|
}
|
||||||
@@ -569,17 +565,12 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
bool show_text)
|
bool show_text)
|
||||||
{
|
{
|
||||||
const uiStyle *style = layout->root->style;
|
const uiStyle *style = layout->root->style;
|
||||||
uiBut *but;
|
|
||||||
PropertyType type;
|
|
||||||
PropertySubType subtype;
|
|
||||||
uiLayout *sub;
|
|
||||||
uint a, b;
|
|
||||||
|
|
||||||
/* retrieve type and subtype */
|
/* retrieve type and subtype */
|
||||||
type = RNA_property_type(prop);
|
const PropertyType type = RNA_property_type(prop);
|
||||||
subtype = RNA_property_subtype(prop);
|
const PropertySubType subtype = RNA_property_subtype(prop);
|
||||||
|
|
||||||
sub = ui_item_local_sublayout(layout, layout, 1);
|
uiLayout *sub = ui_item_local_sublayout(layout, layout, 1);
|
||||||
UI_block_layout_set_current(block, sub);
|
UI_block_layout_set_current(block, sub);
|
||||||
|
|
||||||
/* create label */
|
/* create label */
|
||||||
@@ -590,17 +581,15 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
/* 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;
|
|
||||||
const int cols = (len >= 20) ? 2 : 1;
|
const int cols = (len >= 20) ? 2 : 1;
|
||||||
const uint colbuts = len / (2 * cols);
|
const int colbuts = len / (2 * cols);
|
||||||
uint layer_used = 0;
|
uint layer_used = 0;
|
||||||
uint layer_active = 0;
|
uint layer_active = 0;
|
||||||
|
|
||||||
UI_block_layout_set_current(block, uiLayoutAbsolute(layout, false));
|
UI_block_layout_set_current(block, uiLayoutAbsolute(layout, false));
|
||||||
|
|
||||||
unit = UI_UNIT_X * 0.75;
|
const int butw = UI_UNIT_X * 0.75;
|
||||||
butw = unit;
|
const int buth = UI_UNIT_X * 0.75;
|
||||||
buth = unit;
|
|
||||||
|
|
||||||
if (ptr->type == &RNA_Armature) {
|
if (ptr->type == &RNA_Armature) {
|
||||||
bArmature *arm = ptr->data;
|
bArmature *arm = ptr->data;
|
||||||
@@ -619,10 +608,10 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (b = 0; b < cols; b++) {
|
for (int b = 0; b < cols; b++) {
|
||||||
UI_block_align_begin(block);
|
UI_block_align_begin(block);
|
||||||
|
|
||||||
for (a = 0; a < colbuts; a++) {
|
for (int a = 0; a < colbuts; a++) {
|
||||||
const int layer_num = a + b * colbuts;
|
const int layer_num = a + b * colbuts;
|
||||||
const uint layer_flag = (1u << layer_num);
|
const uint layer_flag = (1u << layer_num);
|
||||||
|
|
||||||
@@ -638,13 +627,13 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
icon = ICON_BLANK1;
|
icon = ICON_BLANK1;
|
||||||
}
|
}
|
||||||
|
|
||||||
but = uiDefAutoButR(
|
uiBut *but = uiDefAutoButR(
|
||||||
block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
|
block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
|
||||||
if (subtype == PROP_LAYER_MEMBER) {
|
if (subtype == PROP_LAYER_MEMBER) {
|
||||||
UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num));
|
UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (a = 0; a < colbuts; a++) {
|
for (int a = 0; a < colbuts; a++) {
|
||||||
const int layer_num = a + len / 2 + b * colbuts;
|
const int layer_num = a + len / 2 + b * colbuts;
|
||||||
const uint layer_flag = (1u << layer_num);
|
const uint layer_flag = (1u << layer_num);
|
||||||
|
|
||||||
@@ -660,7 +649,8 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
icon = ICON_BLANK1;
|
icon = ICON_BLANK1;
|
||||||
}
|
}
|
||||||
|
|
||||||
but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
|
uiBut *but = uiDefAutoButR(
|
||||||
|
block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
|
||||||
if (subtype == PROP_LAYER_MEMBER) {
|
if (subtype == PROP_LAYER_MEMBER) {
|
||||||
UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num));
|
UI_but_func_set(but, ui_layer_but_cb, but, POINTER_FROM_INT(layer_num));
|
||||||
}
|
}
|
||||||
@@ -685,11 +675,11 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
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 (int 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,
|
uiBut *but = uiDefAutoButR(block,
|
||||||
ptr,
|
ptr,
|
||||||
prop,
|
prop,
|
||||||
a,
|
a,
|
||||||
@@ -734,8 +724,6 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
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 {
|
||||||
bool *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 */
|
||||||
@@ -748,6 +736,7 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* show checkboxes for rna on a non-emboss block (menu for eg) */
|
/* show checkboxes for rna on a non-emboss block (menu for eg) */
|
||||||
|
bool *boolarr = NULL;
|
||||||
if (type == PROP_BOOLEAN &&
|
if (type == PROP_BOOLEAN &&
|
||||||
ELEM(layout->root->block->emboss, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) {
|
ELEM(layout->root->block->emboss, UI_EMBOSS_NONE, UI_EMBOSS_PULLDOWN)) {
|
||||||
boolarr = MEM_callocN(sizeof(bool) * len, __func__);
|
boolarr = MEM_callocN(sizeof(bool) * len, __func__);
|
||||||
@@ -755,9 +744,7 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *str_buf = show_text ? str : "";
|
const char *str_buf = show_text ? str : "";
|
||||||
for (a = 0; a < len; a++) {
|
for (int a = 0; a < len; a++) {
|
||||||
int width_item;
|
|
||||||
|
|
||||||
if (!icon_only && show_text) {
|
if (!icon_only && show_text) {
|
||||||
str[0] = RNA_property_array_item_char(prop, a);
|
str[0] = RNA_property_array_item_char(prop, a);
|
||||||
}
|
}
|
||||||
@@ -765,11 +752,12 @@ static void ui_item_array(uiLayout *layout,
|
|||||||
icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
|
||||||
}
|
}
|
||||||
|
|
||||||
width_item = ((compact && type == PROP_BOOLEAN) ?
|
const int width_item = ((compact && type == PROP_BOOLEAN) ?
|
||||||
min_ii(w, ui_text_icon_width(layout, str_buf, icon, false)) :
|
min_ii(w, ui_text_icon_width(layout, str_buf, icon, false)) :
|
||||||
w);
|
w);
|
||||||
|
|
||||||
but = uiDefAutoButR(block, ptr, prop, a, str_buf, icon, 0, 0, width_item, UI_UNIT_Y);
|
uiBut *but = uiDefAutoButR(
|
||||||
|
block, ptr, prop, a, str_buf, icon, 0, 0, width_item, UI_UNIT_Y);
|
||||||
if (slider && but->type == UI_BTYPE_NUM) {
|
if (slider && but->type == UI_BTYPE_NUM) {
|
||||||
uiButNumber *number_but = (uiButNumber *)but;
|
uiButNumber *number_but = (uiButNumber *)but;
|
||||||
|
|
||||||
@@ -832,7 +820,6 @@ static void ui_item_enum_expand_elem_exec(uiLayout *layout,
|
|||||||
const int itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0);
|
const int itemw = ui_text_icon_width(block->curlayout, icon_only ? "" : name, icon, 0);
|
||||||
|
|
||||||
uiBut *but;
|
uiBut *but;
|
||||||
|
|
||||||
if (icon && name[0] && !icon_only) {
|
if (icon && name[0] && !icon_only) {
|
||||||
but = uiDefIconTextButR_prop(
|
but = uiDefIconTextButR_prop(
|
||||||
block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
|
||||||
@@ -886,13 +873,12 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
|
|||||||
* - mont29
|
* - mont29
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const EnumPropertyItem *item, *item_array;
|
|
||||||
bool free;
|
|
||||||
|
|
||||||
BLI_assert(RNA_property_type(prop) == PROP_ENUM);
|
BLI_assert(RNA_property_type(prop) == PROP_ENUM);
|
||||||
|
|
||||||
uiLayout *layout_radial = NULL;
|
|
||||||
const bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
|
const bool radial = (layout->root->type == UI_LAYOUT_PIEMENU);
|
||||||
|
|
||||||
|
bool free;
|
||||||
|
const EnumPropertyItem *item_array;
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -901,6 +887,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* we dont want nested rows, cols in menus */
|
/* we dont want nested rows, cols in menus */
|
||||||
|
uiLayout *layout_radial = NULL;
|
||||||
if (radial) {
|
if (radial) {
|
||||||
if (layout->root->layout == layout) {
|
if (layout->root->layout == layout) {
|
||||||
layout_radial = uiLayoutRadial(layout);
|
layout_radial = uiLayoutRadial(layout);
|
||||||
@@ -921,7 +908,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout,
|
|||||||
UI_block_layout_set_current(block, ui_item_local_sublayout(layout, layout, 1));
|
UI_block_layout_set_current(block, ui_item_local_sublayout(layout, layout, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (item = item_array; item->identifier; item++) {
|
for (const EnumPropertyItem *item = item_array; item->identifier; item++) {
|
||||||
const bool is_first = item == item_array;
|
const bool is_first = item == item_array;
|
||||||
|
|
||||||
if (!item->identifier[0]) {
|
if (!item->identifier[0]) {
|
||||||
@@ -1016,9 +1003,6 @@ static uiBut *ui_item_with_label(uiLayout *layout,
|
|||||||
int flag)
|
int flag)
|
||||||
{
|
{
|
||||||
uiLayout *sub = layout;
|
uiLayout *sub = layout;
|
||||||
uiBut *but = NULL;
|
|
||||||
PropertyType type;
|
|
||||||
PropertySubType subtype;
|
|
||||||
int prop_but_width = w_hint;
|
int prop_but_width = w_hint;
|
||||||
#ifdef UI_PROP_DECORATE
|
#ifdef UI_PROP_DECORATE
|
||||||
uiLayout *layout_prop_decorate = NULL;
|
uiLayout *layout_prop_decorate = NULL;
|
||||||
@@ -1047,7 +1031,6 @@ static uiBut *ui_item_with_label(uiLayout *layout,
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int w_label;
|
int w_label;
|
||||||
|
|
||||||
if (ui_layout_variable_size(layout)) {
|
if (ui_layout_variable_size(layout)) {
|
||||||
/* w_hint is width for label in this case.
|
/* w_hint is width for label in this case.
|
||||||
* Use a default width for property button(s) */
|
* Use a default width for property button(s) */
|
||||||
@@ -1061,9 +1044,10 @@ static uiBut *ui_item_with_label(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type = RNA_property_type(prop);
|
const PropertyType type = RNA_property_type(prop);
|
||||||
subtype = RNA_property_subtype(prop);
|
const PropertySubType subtype = RNA_property_subtype(prop);
|
||||||
|
|
||||||
|
uiBut *but;
|
||||||
if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
|
if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
|
||||||
UI_block_layout_set_current(block, uiLayoutRow(sub, true));
|
UI_block_layout_set_current(block, uiLayoutRow(sub, true));
|
||||||
but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h);
|
but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h);
|
||||||
@@ -1204,8 +1188,6 @@ static void ui_but_tip_from_enum_item(uiBut *but, const EnumPropertyItem *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;
|
|
||||||
int w;
|
|
||||||
|
|
||||||
UI_block_layout_set_current(block, layout);
|
UI_block_layout_set_current(block, layout);
|
||||||
|
|
||||||
@@ -1213,9 +1195,10 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
|
|||||||
name = "";
|
name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
w = ui_text_icon_width(layout, name, 0, 0);
|
const int w = ui_text_icon_width(layout, name, 0, 0);
|
||||||
|
|
||||||
but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
|
uiBut *but = uiDefBut(
|
||||||
|
block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
UI_but_disable(but, "");
|
UI_but_disable(but, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1235,8 +1218,6 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
|
|||||||
{
|
{
|
||||||
/* Take care to fill 'r_opptr' whatever happens. */
|
/* Take care to fill 'r_opptr' whatever happens. */
|
||||||
uiBlock *block = layout->root->block;
|
uiBlock *block = layout->root->block;
|
||||||
uiBut *but;
|
|
||||||
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) {
|
||||||
@@ -1254,7 +1235,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
|
|||||||
/* create button */
|
/* create button */
|
||||||
UI_block_layout_set_current(block, layout);
|
UI_block_layout_set_current(block, layout);
|
||||||
|
|
||||||
w = ui_text_icon_width(layout, name, icon, 0);
|
const int w = ui_text_icon_width(layout, name, icon, 0);
|
||||||
|
|
||||||
const int prev_emboss = layout->emboss;
|
const int prev_emboss = layout->emboss;
|
||||||
if (flag & UI_ITEM_R_NO_BG) {
|
if (flag & UI_ITEM_R_NO_BG) {
|
||||||
@@ -1262,6 +1243,7 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* create the button */
|
/* create the button */
|
||||||
|
uiBut *but;
|
||||||
if (icon) {
|
if (icon) {
|
||||||
if (name[0]) {
|
if (name[0]) {
|
||||||
but = uiDefIconTextButO_ptr(
|
but = uiDefIconTextButO_ptr(
|
||||||
@@ -1409,11 +1391,11 @@ static const char *ui_menu_enumpropname(uiLayout *layout,
|
|||||||
PropertyRNA *prop,
|
PropertyRNA *prop,
|
||||||
int retval)
|
int retval)
|
||||||
{
|
{
|
||||||
const EnumPropertyItem *item;
|
|
||||||
bool free;
|
bool free;
|
||||||
const char *name;
|
const EnumPropertyItem *item;
|
||||||
|
|
||||||
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
|
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
|
||||||
|
|
||||||
|
const char *name;
|
||||||
if (RNA_enum_name(item, retval, &name)) {
|
if (RNA_enum_name(item, retval, &name)) {
|
||||||
name = CTX_IFACE_(RNA_property_translation_context(prop), name);
|
name = CTX_IFACE_(RNA_property_translation_context(prop), name);
|
||||||
}
|
}
|
||||||
@@ -1436,14 +1418,10 @@ void uiItemEnumO_ptr(uiLayout *layout,
|
|||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
PointerRNA ptr;
|
PointerRNA ptr;
|
||||||
PropertyRNA *prop;
|
|
||||||
|
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
|
|
||||||
if ((prop = RNA_struct_find_property(&ptr, propname))) {
|
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
|
||||||
/* pass */
|
if (prop == NULL) {
|
||||||
}
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -1502,7 +1480,6 @@ void uiItemsFullEnumO_items(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uiLayout *target, *split = NULL;
|
uiLayout *target, *split = NULL;
|
||||||
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);
|
||||||
|
|
||||||
@@ -1534,10 +1511,9 @@ void uiItemsFullEnumO_items(uiLayout *layout,
|
|||||||
target = uiLayoutColumn(split, layout->align);
|
target = uiLayoutColumn(split, layout->align);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
|
||||||
bool last_iter = false;
|
bool last_iter = false;
|
||||||
|
const EnumPropertyItem *item = item_array;
|
||||||
for (i = 1, item = item_array; item->identifier && !last_iter; i++, item++) {
|
for (int i = 1; item->identifier && !last_iter; i++, item++) {
|
||||||
/* handle oversized pies */
|
/* handle oversized pies */
|
||||||
if (radial && (totitem > PIE_MAX_ITEMS) && (i >= PIE_MAX_ITEMS)) {
|
if (radial && (totitem > PIE_MAX_ITEMS) && (i >= PIE_MAX_ITEMS)) {
|
||||||
if (item->name) { /* only visible items */
|
if (item->name) { /* only visible items */
|
||||||
@@ -1566,7 +1542,6 @@ void uiItemsFullEnumO_items(uiLayout *layout,
|
|||||||
|
|
||||||
if (item->identifier[0]) {
|
if (item->identifier[0]) {
|
||||||
PointerRNA tptr;
|
PointerRNA tptr;
|
||||||
|
|
||||||
WM_operator_properties_create_ptr(&tptr, ot);
|
WM_operator_properties_create_ptr(&tptr, ot);
|
||||||
if (properties) {
|
if (properties) {
|
||||||
if (tptr.data) {
|
if (tptr.data) {
|
||||||
@@ -1589,8 +1564,6 @@ void uiItemsFullEnumO_items(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (item->name) {
|
if (item->name) {
|
||||||
uiBut *but;
|
|
||||||
|
|
||||||
if (item != item_array && !radial && split != NULL) {
|
if (item != item_array && !radial && split != NULL) {
|
||||||
target = uiLayoutColumn(split, layout->align);
|
target = uiLayoutColumn(split, layout->align);
|
||||||
|
|
||||||
@@ -1598,6 +1571,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
|
|||||||
block->flag |= UI_BLOCK_NO_FLIP;
|
block->flag |= UI_BLOCK_NO_FLIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiBut *but;
|
||||||
if (item->icon || radial) {
|
if (item->icon || radial) {
|
||||||
uiItemL(target, item->name, item->icon);
|
uiItemL(target, item->name, item->icon);
|
||||||
|
|
||||||
@@ -1647,24 +1621,22 @@ void uiItemsFullEnumO(uiLayout *layout,
|
|||||||
{
|
{
|
||||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||||
|
|
||||||
PointerRNA ptr;
|
|
||||||
PropertyRNA *prop;
|
|
||||||
uiBlock *block = layout->root->block;
|
|
||||||
|
|
||||||
if (!ot || !ot->srna) {
|
if (!ot || !ot->srna) {
|
||||||
ui_item_disabled(layout, opname);
|
ui_item_disabled(layout, opname);
|
||||||
RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
|
RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PointerRNA ptr;
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
/* so the context is passed to itemf functions (some need it) */
|
/* so the context is passed to itemf functions (some need it) */
|
||||||
WM_operator_properties_sanitize(&ptr, false);
|
WM_operator_properties_sanitize(&ptr, false);
|
||||||
prop = RNA_struct_find_property(&ptr, propname);
|
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
|
||||||
|
|
||||||
/* don't let bad properties slip through */
|
/* don't let bad properties slip through */
|
||||||
BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM));
|
BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM));
|
||||||
|
|
||||||
|
uiBlock *block = layout->root->block;
|
||||||
if (prop && RNA_property_type(prop) == PROP_ENUM) {
|
if (prop && RNA_property_type(prop) == PROP_ENUM) {
|
||||||
const EnumPropertyItem *item_array = NULL;
|
const EnumPropertyItem *item_array = NULL;
|
||||||
int totitem;
|
int totitem;
|
||||||
@@ -1721,18 +1693,14 @@ void uiItemEnumO_value(uiLayout *layout,
|
|||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||||
PointerRNA ptr;
|
|
||||||
PropertyRNA *prop;
|
|
||||||
|
|
||||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||||
|
|
||||||
|
PointerRNA ptr;
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
|
|
||||||
/* enum lookup */
|
/* enum lookup */
|
||||||
if ((prop = RNA_struct_find_property(&ptr, propname))) {
|
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
|
||||||
/* pass */
|
if (prop == NULL) {
|
||||||
}
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -1755,38 +1723,35 @@ void uiItemEnumO_string(uiLayout *layout,
|
|||||||
const char *value_str)
|
const char *value_str)
|
||||||
{
|
{
|
||||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||||
PointerRNA ptr;
|
|
||||||
PropertyRNA *prop;
|
|
||||||
|
|
||||||
const EnumPropertyItem *item;
|
|
||||||
int value;
|
|
||||||
bool free;
|
|
||||||
|
|
||||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||||
|
|
||||||
|
PointerRNA ptr;
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
|
|
||||||
|
PropertyRNA *prop = RNA_struct_find_property(&ptr, propname);
|
||||||
|
if (prop == NULL) {
|
||||||
|
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* enum lookup */
|
/* enum lookup */
|
||||||
if ((prop = RNA_struct_find_property(&ptr, propname))) {
|
|
||||||
/* no need for translations here */
|
/* no need for translations here */
|
||||||
|
const EnumPropertyItem *item;
|
||||||
|
bool free;
|
||||||
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
|
RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
|
||||||
|
|
||||||
|
int value;
|
||||||
if (item == NULL || RNA_enum_value_from_id(item, value_str, &value) == 0) {
|
if (item == NULL || RNA_enum_value_from_id(item, value_str, &value) == 0) {
|
||||||
if (free) {
|
if (free) {
|
||||||
MEM_freeN((void *)item);
|
MEM_freeN((void *)item);
|
||||||
}
|
}
|
||||||
RNA_warning(
|
RNA_warning("%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname, value_str);
|
||||||
"%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname, value_str);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (free) {
|
if (free) {
|
||||||
MEM_freeN((void *)item);
|
MEM_freeN((void *)item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RNA_property_enum_set(&ptr, prop, value);
|
RNA_property_enum_set(&ptr, prop, value);
|
||||||
|
|
||||||
@@ -1806,10 +1771,9 @@ void uiItemBooleanO(uiLayout *layout,
|
|||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||||
PointerRNA ptr;
|
|
||||||
|
|
||||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||||
|
|
||||||
|
PointerRNA ptr;
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
RNA_boolean_set(&ptr, propname, value);
|
RNA_boolean_set(&ptr, propname, value);
|
||||||
|
|
||||||
@@ -1824,10 +1788,9 @@ void uiItemIntO(uiLayout *layout,
|
|||||||
int value)
|
int value)
|
||||||
{
|
{
|
||||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||||
PointerRNA ptr;
|
|
||||||
|
|
||||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||||
|
|
||||||
|
PointerRNA ptr;
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
RNA_int_set(&ptr, propname, value);
|
RNA_int_set(&ptr, propname, value);
|
||||||
|
|
||||||
@@ -1842,10 +1805,10 @@ void uiItemFloatO(uiLayout *layout,
|
|||||||
float value)
|
float value)
|
||||||
{
|
{
|
||||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||||
PointerRNA ptr;
|
|
||||||
|
|
||||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||||
|
|
||||||
|
PointerRNA ptr;
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
RNA_float_set(&ptr, propname, value);
|
RNA_float_set(&ptr, propname, value);
|
||||||
|
|
||||||
@@ -1860,10 +1823,10 @@ void uiItemStringO(uiLayout *layout,
|
|||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
|
||||||
PointerRNA ptr;
|
|
||||||
|
|
||||||
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
UI_OPERATOR_ERROR_RET(ot, opname, return );
|
||||||
|
|
||||||
|
PointerRNA ptr;
|
||||||
WM_operator_properties_create_ptr(&ptr, ot);
|
WM_operator_properties_create_ptr(&ptr, ot);
|
||||||
RNA_string_set(&ptr, propname, value);
|
RNA_string_set(&ptr, propname, value);
|
||||||
|
|
||||||
@@ -1888,16 +1851,14 @@ static void ui_item_rna_size(uiLayout *layout,
|
|||||||
int *r_w,
|
int *r_w,
|
||||||
int *r_h)
|
int *r_h)
|
||||||
{
|
{
|
||||||
PropertyType type;
|
int w = 0, h;
|
||||||
PropertySubType subtype;
|
|
||||||
int len, w = 0, h;
|
|
||||||
bool is_checkbox_only = false;
|
|
||||||
|
|
||||||
/* arbitrary extended width by type */
|
/* arbitrary extended width by type */
|
||||||
type = RNA_property_type(prop);
|
PropertyType type = RNA_property_type(prop);
|
||||||
subtype = RNA_property_subtype(prop);
|
PropertySubType subtype = RNA_property_subtype(prop);
|
||||||
len = RNA_property_array_length(ptr, prop);
|
const int len = RNA_property_array_length(ptr, prop);
|
||||||
|
|
||||||
|
bool is_checkbox_only = false;
|
||||||
if (!name[0] && !icon_only) {
|
if (!name[0] && !icon_only) {
|
||||||
if (ELEM(type, PROP_STRING, PROP_POINTER)) {
|
if (ELEM(type, PROP_STRING, PROP_POINTER)) {
|
||||||
name = "non-empty text";
|
name = "non-empty text";
|
||||||
@@ -1911,12 +1872,12 @@ static void ui_item_rna_size(uiLayout *layout,
|
|||||||
}
|
}
|
||||||
else if (type == PROP_ENUM) {
|
else if (type == PROP_ENUM) {
|
||||||
/* Find the longest enum item name, instead of using a dummy text! */
|
/* Find the longest enum item name, instead of using a dummy text! */
|
||||||
const EnumPropertyItem *item, *item_array;
|
const EnumPropertyItem *item_array;
|
||||||
bool free;
|
bool free;
|
||||||
|
|
||||||
RNA_property_enum_items_gettexted(
|
RNA_property_enum_items_gettexted(
|
||||||
layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
|
layout->root->block->evil_C, ptr, prop, &item_array, NULL, &free);
|
||||||
for (item = item_array; item->identifier; item++) {
|
|
||||||
|
for (const EnumPropertyItem *item = item_array; item->identifier; item++) {
|
||||||
if (item->identifier[0]) {
|
if (item->identifier[0]) {
|
||||||
w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, compact));
|
w = max_ii(w, ui_text_icon_width(layout, item->name, item->icon, compact));
|
||||||
}
|
}
|
||||||
@@ -2606,10 +2567,6 @@ void uiItemEnumR_string_prop(uiLayout *layout,
|
|||||||
const char *name,
|
const char *name,
|
||||||
int icon)
|
int icon)
|
||||||
{
|
{
|
||||||
const EnumPropertyItem *item;
|
|
||||||
int ivalue, a;
|
|
||||||
bool free;
|
|
||||||
|
|
||||||
if (UNLIKELY(RNA_property_type(prop) != PROP_ENUM)) {
|
if (UNLIKELY(RNA_property_type(prop) != PROP_ENUM)) {
|
||||||
const char *propname = RNA_property_identifier(prop);
|
const char *propname = RNA_property_identifier(prop);
|
||||||
ui_item_disabled(layout, propname);
|
ui_item_disabled(layout, propname);
|
||||||
@@ -2617,8 +2574,11 @@ void uiItemEnumR_string_prop(uiLayout *layout,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const EnumPropertyItem *item;
|
||||||
|
bool free;
|
||||||
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
|
RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, NULL, &free);
|
||||||
|
|
||||||
|
int ivalue;
|
||||||
if (!RNA_enum_value_from_id(item, value, &ivalue)) {
|
if (!RNA_enum_value_from_id(item, value, &ivalue)) {
|
||||||
const char *propname = RNA_property_identifier(prop);
|
const char *propname = RNA_property_identifier(prop);
|
||||||
if (free) {
|
if (free) {
|
||||||
@@ -2629,7 +2589,7 @@ void uiItemEnumR_string_prop(uiLayout *layout,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (a = 0; item[a].identifier; a++) {
|
for (int a = 0; item[a].identifier; a++) {
|
||||||
if (item[a].identifier[0] == '\0') {
|
if (item[a].identifier[0] == '\0') {
|
||||||
/* Skip enum item separators. */
|
/* Skip enum item separators. */
|
||||||
continue;
|
continue;
|
||||||
@@ -2669,11 +2629,9 @@ void uiItemEnumR_string(uiLayout *layout,
|
|||||||
|
|
||||||
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname)
|
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
|
||||||
uiBlock *block = layout->root->block;
|
uiBlock *block = layout->root->block;
|
||||||
uiBut *bt;
|
|
||||||
|
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||||
|
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
ui_item_disabled(layout, propname);
|
ui_item_disabled(layout, propname);
|
||||||
@@ -2686,12 +2644,12 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EnumPropertyItem *item;
|
|
||||||
int totitem;
|
|
||||||
bool free;
|
|
||||||
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
|
uiLayout *split = uiLayoutSplit(layout, 0.0f, false);
|
||||||
uiLayout *column = uiLayoutColumn(split, false);
|
uiLayout *column = uiLayoutColumn(split, false);
|
||||||
|
|
||||||
|
int totitem;
|
||||||
|
const EnumPropertyItem *item;
|
||||||
|
bool free;
|
||||||
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
|
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
|
||||||
|
|
||||||
for (int i = 0; i < totitem; i++) {
|
for (int i = 0; i < totitem; i++) {
|
||||||
@@ -2708,7 +2666,7 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
|
|||||||
}
|
}
|
||||||
|
|
||||||
uiItemL(column, item[i].name, ICON_NONE);
|
uiItemL(column, item[i].name, ICON_NONE);
|
||||||
bt = block->buttons.last;
|
uiBut *bt = block->buttons.last;
|
||||||
bt->drawflag = UI_BUT_TEXT_LEFT;
|
bt->drawflag = UI_BUT_TEXT_LEFT;
|
||||||
|
|
||||||
ui_but_tip_from_enum_item(bt, &item[i]);
|
ui_but_tip_from_enum_item(bt, &item[i]);
|
||||||
@@ -2731,8 +2689,6 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
|
|||||||
|
|
||||||
static void search_id_collection(StructRNA *ptype, PointerRNA *r_ptr, PropertyRNA **r_prop)
|
static void search_id_collection(StructRNA *ptype, PointerRNA *r_ptr, PropertyRNA **r_prop)
|
||||||
{
|
{
|
||||||
StructRNA *srna;
|
|
||||||
|
|
||||||
/* look for collection property in Main */
|
/* look for collection property in Main */
|
||||||
/* Note: using global Main is OK-ish here, UI shall not access other Mains anyay... */
|
/* Note: using global Main is OK-ish here, UI shall not access other Mains anyay... */
|
||||||
RNA_main_pointer_create(G_MAIN, r_ptr);
|
RNA_main_pointer_create(G_MAIN, r_ptr);
|
||||||
@@ -2742,7 +2698,7 @@ static void search_id_collection(StructRNA *ptype, PointerRNA *r_ptr, PropertyRN
|
|||||||
RNA_STRUCT_BEGIN (r_ptr, iprop) {
|
RNA_STRUCT_BEGIN (r_ptr, iprop) {
|
||||||
/* if it's a collection and has same pointer type, we've got it */
|
/* if it's a collection and has same pointer type, we've got it */
|
||||||
if (RNA_property_type(iprop) == PROP_COLLECTION) {
|
if (RNA_property_type(iprop) == PROP_COLLECTION) {
|
||||||
srna = RNA_property_pointer_type(r_ptr, iprop);
|
StructRNA *srna = RNA_property_pointer_type(r_ptr, iprop);
|
||||||
|
|
||||||
if (ptype == srna) {
|
if (ptype == srna) {
|
||||||
*r_prop = iprop;
|
*r_prop = iprop;
|
||||||
@@ -2766,13 +2722,11 @@ static void ui_rna_collection_search_arg_free_fn(void *ptr)
|
|||||||
uiBut *ui_but_add_search(
|
uiBut *ui_but_add_search(
|
||||||
uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop)
|
uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop)
|
||||||
{
|
{
|
||||||
StructRNA *ptype;
|
|
||||||
PointerRNA sptr;
|
|
||||||
|
|
||||||
/* for ID's we do automatic lookup */
|
/* for ID's we do automatic lookup */
|
||||||
if (!searchprop) {
|
if (!searchprop) {
|
||||||
if (RNA_property_type(prop) == PROP_POINTER) {
|
if (RNA_property_type(prop) == PROP_POINTER) {
|
||||||
ptype = RNA_property_pointer_type(ptr, prop);
|
StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
|
||||||
|
PointerRNA sptr;
|
||||||
search_id_collection(ptype, &sptr, &searchprop);
|
search_id_collection(ptype, &sptr, &searchprop);
|
||||||
searchptr = &sptr;
|
searchptr = &sptr;
|
||||||
}
|
}
|
||||||
@@ -2833,17 +2787,11 @@ void uiItemPointerR_prop(uiLayout *layout,
|
|||||||
const char *name,
|
const char *name,
|
||||||
int icon)
|
int icon)
|
||||||
{
|
{
|
||||||
PropertyType type;
|
|
||||||
uiBut *but;
|
|
||||||
uiBlock *block;
|
|
||||||
StructRNA *icontype;
|
|
||||||
int w, h;
|
|
||||||
char namestr[UI_MAX_NAME_STR];
|
|
||||||
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
|
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
|
||||||
|
|
||||||
layout_root_new_button_group(layout->root);
|
layout_root_new_button_group(layout->root);
|
||||||
|
|
||||||
type = RNA_property_type(prop);
|
const PropertyType type = RNA_property_type(prop);
|
||||||
if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
|
if (!ELEM(type, PROP_POINTER, PROP_STRING, PROP_ENUM)) {
|
||||||
RNA_warning("Property %s.%s must be a pointer, string or enum",
|
RNA_warning("Property %s.%s must be a pointer, string or enum",
|
||||||
RNA_struct_identifier(ptr->type),
|
RNA_struct_identifier(ptr->type),
|
||||||
@@ -2859,6 +2807,7 @@ void uiItemPointerR_prop(uiLayout *layout,
|
|||||||
|
|
||||||
/* get icon & name */
|
/* get icon & name */
|
||||||
if (icon == ICON_NONE) {
|
if (icon == ICON_NONE) {
|
||||||
|
StructRNA *icontype;
|
||||||
if (type == PROP_POINTER) {
|
if (type == PROP_POINTER) {
|
||||||
icontype = RNA_property_pointer_type(ptr, prop);
|
icontype = RNA_property_pointer_type(ptr, prop);
|
||||||
}
|
}
|
||||||
@@ -2872,16 +2821,18 @@ void uiItemPointerR_prop(uiLayout *layout,
|
|||||||
name = RNA_property_ui_name(prop);
|
name = RNA_property_ui_name(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char namestr[UI_MAX_NAME_STR];
|
||||||
if (use_prop_sep == false) {
|
if (use_prop_sep == false) {
|
||||||
name = ui_item_name_add_colon(name, namestr);
|
name = ui_item_name_add_colon(name, namestr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create button */
|
/* create button */
|
||||||
block = uiLayoutGetBlock(layout);
|
uiBlock *block = uiLayoutGetBlock(layout);
|
||||||
|
|
||||||
|
int w, h;
|
||||||
ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, false, &w, &h);
|
ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, false, &w, &h);
|
||||||
w += UI_UNIT_X; /* X icon needs more space */
|
w += UI_UNIT_X; /* X icon needs more space */
|
||||||
but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
|
uiBut *but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
|
||||||
|
|
||||||
ui_but_add_search(but, ptr, prop, searchptr, searchprop);
|
ui_but_add_search(but, ptr, prop, searchptr, searchprop);
|
||||||
}
|
}
|
||||||
@@ -2894,15 +2845,13 @@ void uiItemPointerR(uiLayout *layout,
|
|||||||
const char *name,
|
const char *name,
|
||||||
int icon)
|
int icon)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop, *searchprop;
|
|
||||||
|
|
||||||
/* validate arguments */
|
/* validate arguments */
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
searchprop = RNA_struct_find_property(searchptr, searchpropname);
|
PropertyRNA *searchprop = RNA_struct_find_property(searchptr, searchpropname);
|
||||||
if (!searchprop) {
|
if (!searchprop) {
|
||||||
RNA_warning("search collection property not found: %s.%s",
|
RNA_warning("search collection property not found: %s.%s",
|
||||||
RNA_struct_identifier(searchptr->type),
|
RNA_struct_identifier(searchptr->type),
|
||||||
@@ -2944,8 +2893,6 @@ static uiBut *ui_item_menu(uiLayout *layout,
|
|||||||
{
|
{
|
||||||
uiBlock *block = layout->root->block;
|
uiBlock *block = layout->root->block;
|
||||||
uiLayout *heading_layout = ui_layout_heading_find(layout);
|
uiLayout *heading_layout = ui_layout_heading_find(layout);
|
||||||
uiBut *but;
|
|
||||||
int w, h;
|
|
||||||
|
|
||||||
UI_block_layout_set_current(block, layout);
|
UI_block_layout_set_current(block, layout);
|
||||||
layout_root_new_button_group(layout->root);
|
layout_root_new_button_group(layout->root);
|
||||||
@@ -2957,8 +2904,8 @@ static uiBut *ui_item_menu(uiLayout *layout,
|
|||||||
icon = ICON_BLANK1;
|
icon = ICON_BLANK1;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = ui_text_icon_width(layout, name, icon, 1);
|
int w = ui_text_icon_width(layout, name, icon, 1);
|
||||||
h = UI_UNIT_Y;
|
int h = UI_UNIT_Y;
|
||||||
|
|
||||||
if (layout->root->type == UI_LAYOUT_HEADER) { /* ugly .. */
|
if (layout->root->type == UI_LAYOUT_HEADER) { /* ugly .. */
|
||||||
if (icon == ICON_NONE && force_menu) {
|
if (icon == ICON_NONE && force_menu) {
|
||||||
@@ -2978,6 +2925,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
|
|||||||
ui_layout_heading_label_add(layout, heading_layout, true, true);
|
ui_layout_heading_label_add(layout, heading_layout, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiBut *but;
|
||||||
if (name[0] && icon) {
|
if (name[0] && icon) {
|
||||||
but = uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, tip);
|
but = uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, tip);
|
||||||
}
|
}
|
||||||
@@ -3058,10 +3006,9 @@ void uiItemMContents(uiLayout *layout, const char *menuname)
|
|||||||
void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index)
|
void uiItemDecoratorR_prop(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index)
|
||||||
{
|
{
|
||||||
uiBlock *block = layout->root->block;
|
uiBlock *block = layout->root->block;
|
||||||
uiLayout *col;
|
|
||||||
|
|
||||||
UI_block_layout_set_current(block, layout);
|
UI_block_layout_set_current(block, layout);
|
||||||
col = uiLayoutColumn(layout, false);
|
uiLayout *col = uiLayoutColumn(layout, false);
|
||||||
col->space = 0;
|
col->space = 0;
|
||||||
col->emboss = UI_EMBOSS_NONE;
|
col->emboss = UI_EMBOSS_NONE;
|
||||||
|
|
||||||
@@ -3212,8 +3159,6 @@ void uiItemPopoverPanelFromGroup(uiLayout *layout,
|
|||||||
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;
|
|
||||||
int w;
|
|
||||||
|
|
||||||
UI_block_layout_set_current(block, layout);
|
UI_block_layout_set_current(block, layout);
|
||||||
layout_root_new_button_group(layout->root);
|
layout_root_new_button_group(layout->root);
|
||||||
@@ -3225,8 +3170,9 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
|
|||||||
icon = ICON_BLANK1;
|
icon = ICON_BLANK1;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = ui_text_icon_width(layout, name, icon, 0);
|
const int w = ui_text_icon_width(layout, name, icon, 0);
|
||||||
|
|
||||||
|
uiBut *but;
|
||||||
if (icon && name[0]) {
|
if (icon && name[0]) {
|
||||||
but = uiDefIconTextBut(
|
but = uiDefIconTextBut(
|
||||||
block, UI_BTYPE_LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, NULL);
|
block, UI_BTYPE_LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, NULL);
|
||||||
@@ -3342,7 +3288,6 @@ 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;
|
|
||||||
|
|
||||||
UI_block_layout_set_current(block, layout);
|
UI_block_layout_set_current(block, layout);
|
||||||
|
|
||||||
@@ -3353,7 +3298,7 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
|
|||||||
icon = ICON_BLANK1;
|
icon = ICON_BLANK1;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = ui_text_icon_width(layout, name, icon, 0);
|
const int w = ui_text_icon_width(layout, name, icon, 0);
|
||||||
|
|
||||||
if (icon && name[0]) {
|
if (icon && name[0]) {
|
||||||
uiDefIconTextButI(block,
|
uiDefIconTextButI(block,
|
||||||
@@ -3501,9 +3446,6 @@ void uiItemMenuEnumO_ptr(uiLayout *layout,
|
|||||||
const char *name,
|
const char *name,
|
||||||
int icon)
|
int icon)
|
||||||
{
|
{
|
||||||
MenuItemLevel *lvl;
|
|
||||||
uiBut *but;
|
|
||||||
|
|
||||||
/* Caller must check */
|
/* Caller must check */
|
||||||
BLI_assert(ot->srna != NULL);
|
BLI_assert(ot->srna != NULL);
|
||||||
|
|
||||||
@@ -3515,12 +3457,12 @@ void uiItemMenuEnumO_ptr(uiLayout *layout,
|
|||||||
icon = ICON_BLANK1;
|
icon = ICON_BLANK1;
|
||||||
}
|
}
|
||||||
|
|
||||||
lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
|
MenuItemLevel *lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
|
||||||
BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
|
BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname));
|
||||||
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
|
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
|
||||||
lvl->opcontext = layout->root->opcontext;
|
lvl->opcontext = layout->root->opcontext;
|
||||||
|
|
||||||
but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, NULL, true);
|
uiBut *but = ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, NULL, true);
|
||||||
|
|
||||||
/* add hotkey here, lower UI code can't detect it */
|
/* add hotkey here, lower UI code can't detect it */
|
||||||
if ((layout->root->block->flag & UI_BLOCK_LOOP) && (ot->prop && ot->invoke)) {
|
if ((layout->root->block->flag & UI_BLOCK_LOOP) && (ot->prop && ot->invoke)) {
|
||||||
@@ -3591,9 +3533,7 @@ void uiItemMenuEnumR_prop(
|
|||||||
void uiItemMenuEnumR(
|
void uiItemMenuEnumR(
|
||||||
uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon)
|
uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon)
|
||||||
{
|
{
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||||
|
|
||||||
prop = RNA_struct_find_property(ptr, propname);
|
|
||||||
if (!prop) {
|
if (!prop) {
|
||||||
ui_item_disabled(layout, propname);
|
ui_item_disabled(layout, propname);
|
||||||
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
|
||||||
|
|||||||
Reference in New Issue
Block a user