diff options
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 340 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_anim.c | 24 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 46 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 56 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 29 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 10 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 52 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_utils.c | 43 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 15 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 29 |
11 files changed, 350 insertions, 297 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index ef8bff1fd7d..8e91c5c9008 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2490,138 +2490,141 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, return but; } -static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +/* ui_def_but_rna_propname and ui_def_but_rna + * both take the same args except for propname vs prop, this is done so we can + * avoid an extra lookup on 'prop' when its already available. + * + * When this kind of change won't disrupt branches, best look into making more + * of our UI functions take prop rather then propname. + */ + +#define UI_DEF_BUT_RNA_DISABLE(but) \ + but->flag |= UI_BUT_DISABLED; \ + but->lock = 1; \ + but->lockstr = "" + + +static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - PropertyRNA *prop; PropertyType proptype; int freestr= 0, icon= 0; - prop= RNA_struct_find_property(ptr, propname); + proptype= RNA_property_type(prop); - if(prop) { - proptype= RNA_property_type(prop); - - /* use rna values if parameters are not specified */ - if(!str) { - if(type == MENU && proptype == PROP_ENUM) { - EnumPropertyItem *item; - DynStr *dynstr; - int i, totitem, value, free; - - RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); - value= RNA_property_enum_get(ptr, prop); - - dynstr= BLI_dynstr_new(); - BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop)); - for(i=0; i<totitem; i++) { - if(!item[i].identifier[0]) { - if(item[i].name) - BLI_dynstr_appendf(dynstr, "|%s%%l", item[i].name); - else - BLI_dynstr_append(dynstr, "|%l"); - } - else if(item[i].icon) - BLI_dynstr_appendf(dynstr, "|%s %%i%d %%x%d", item[i].name, item[i].icon, item[i].value); + /* use rna values if parameters are not specified */ + if(!str) { + if(type == MENU && proptype == PROP_ENUM) { + EnumPropertyItem *item; + DynStr *dynstr; + int i, totitem, value, free; + + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); + value= RNA_property_enum_get(ptr, prop); + + dynstr= BLI_dynstr_new(); + BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop)); + for(i=0; i<totitem; i++) { + if(!item[i].identifier[0]) { + if(item[i].name) + BLI_dynstr_appendf(dynstr, "|%s%%l", item[i].name); else - BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value); + BLI_dynstr_append(dynstr, "|%l"); + } + else if(item[i].icon) + BLI_dynstr_appendf(dynstr, "|%s %%i%d %%x%d", item[i].name, item[i].icon, item[i].value); + else + BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value); - if(value == item[i].value) { - icon= item[i].icon; - if(!tip) - tip= item[i].description; - } + if(value == item[i].value) { + icon= item[i].icon; + if(!tip) + tip= item[i].description; } - str= BLI_dynstr_get_cstring(dynstr); - BLI_dynstr_free(dynstr); + } + str= BLI_dynstr_get_cstring(dynstr); + BLI_dynstr_free(dynstr); - if(free) - MEM_freeN(item); + if(free) + MEM_freeN(item); - freestr= 1; - } - else if(ELEM(type, ROW, LISTROW) && proptype == PROP_ENUM) { - EnumPropertyItem *item; - int i, totitem, free; - - RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); - for(i=0; i<totitem; i++) { - if(item[i].identifier[0] && item[i].value == (int)max) { - str= item[i].name; - icon= item[i].icon; - } - } + freestr= 1; + } + else if(ELEM(type, ROW, LISTROW) && proptype == PROP_ENUM) { + EnumPropertyItem *item; + int i, totitem, free; - if(!str) - str= RNA_property_ui_name(prop); - if(free) - MEM_freeN(item); + RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); + for(i=0; i<totitem; i++) { + if(item[i].identifier[0] && item[i].value == (int)max) { + str= item[i].name; + icon= item[i].icon; + } } - else { + + if(!str) str= RNA_property_ui_name(prop); - icon= RNA_property_ui_icon(prop); - } + if(free) + MEM_freeN(item); } - - if(!tip && proptype != PROP_ENUM) - tip= RNA_property_ui_description(prop); + else { + str= RNA_property_ui_name(prop); + icon= RNA_property_ui_icon(prop); + } + } - if(min == max || a1 == -1 || a2 == -1) { - if(proptype == PROP_INT) { - int hardmin, hardmax, softmin, softmax, step; + if(!tip && proptype != PROP_ENUM) + tip= RNA_property_ui_description(prop); - RNA_property_int_range(ptr, prop, &hardmin, &hardmax); - RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step); + if(min == max || a1 == -1 || a2 == -1) { + if(proptype == PROP_INT) { + int hardmin, hardmax, softmin, softmax, step; - if(!ELEM(type, ROW, LISTROW) && min == max) { - min= hardmin; - max= hardmax; - } - if(a1 == -1) - a1= step; - if(a2 == -1) - a2= 0; + RNA_property_int_range(ptr, prop, &hardmin, &hardmax); + RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step); + + if(!ELEM(type, ROW, LISTROW) && min == max) { + min= hardmin; + max= hardmax; } - else if(proptype == PROP_FLOAT) { - float hardmin, hardmax, softmin, softmax, step, precision; + if(a1 == -1) + a1= step; + if(a2 == -1) + a2= 0; + } + else if(proptype == PROP_FLOAT) { + float hardmin, hardmax, softmin, softmax, step, precision; - RNA_property_float_range(ptr, prop, &hardmin, &hardmax); - RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); + RNA_property_float_range(ptr, prop, &hardmin, &hardmax); + RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); - if(!ELEM(type, ROW, LISTROW) && min == max) { - min= hardmin; - max= hardmax; - } - if(a1 == -1) - a1= step; - if(a2 == -1) - a2= precision; - } - else if(proptype == PROP_STRING) { - min= 0; - max= RNA_property_string_maxlength(prop); - if(max == 0) /* interface code should ideally support unlimited length */ - max= UI_MAX_DRAW_STR; + if(!ELEM(type, ROW, LISTROW) && min == max) { + min= hardmin; + max= hardmax; } + if(a1 == -1) + a1= step; + if(a2 == -1) + a2= precision; + } + else if(proptype == PROP_STRING) { + min= 0; + max= RNA_property_string_maxlength(prop); + if(max == 0) /* interface code should ideally support unlimited length */ + max= UI_MAX_DRAW_STR; } - } - else { - RNA_warning("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); - str= propname; } /* now create button */ but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip); - if(prop) { - but->rnapoin= *ptr; - but->rnaprop= prop; + but->rnapoin= *ptr; + but->rnaprop= prop; - if(RNA_property_array_length(&but->rnapoin, but->rnaprop)) - but->rnaindex= index; - else - but->rnaindex= 0; - } + if(RNA_property_array_length(&but->rnapoin, but->rnaprop)) + but->rnaindex= index; + else + but->rnaindex= 0; if(icon) { but->icon= (BIFIconID)icon; @@ -2629,10 +2632,8 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s but->flag|= UI_ICON_LEFT; } - if (!prop || !RNA_property_editable(&but->rnapoin, prop)) { - but->flag |= UI_BUT_DISABLED; - but->lock = 1; - but->lockstr = ""; + if (!RNA_property_editable(&but->rnapoin, prop)) { + UI_DEF_BUT_RNA_DISABLE(but); } /* If this button uses units, calculate the step from this */ @@ -2645,6 +2646,23 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s return but; } +static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) +{ + PropertyRNA *prop= RNA_struct_find_property(ptr, propname); + uiBut *but; + + if(prop) { + but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + } + else { + but= ui_def_but(block, type, retval, propname, x1, y1, x2, y2, NULL, min, max, a1, a2, tip); + + UI_DEF_BUT_RNA_DISABLE(but); + } + + return but; +} + static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; @@ -2812,6 +2830,16 @@ static void autocomplete_id(bContext *C, char *str, void *arg_v) } } +static void ui_check_but_and_iconize(uiBut *but, int icon) +{ + if(icon) { + but->icon= (BIFIconID) icon; + but->flag|= UI_HAS_ICON; + } + + ui_check_but(but); +} + static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { int bitIdx= findBitIndex(bit); @@ -2856,31 +2884,29 @@ uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *s uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - - but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); - if(but) - ui_check_but(but); - + but= ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + ui_check_but(but); + return but; +} +uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +{ + uiBut *but; + but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + ui_check_but(but); return but; } uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip); - if(but) - ui_check_but(but); - + ui_check_but(but); return but; } uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but= ui_def_but_operator_text(block, type, opname, opcontext, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); - - if(but) - ui_check_but(but); - + ui_check_but(but); return but; } @@ -2888,12 +2914,7 @@ uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but= ui_def_but(block, type, retval, "", x1, y1, x2, y2, poin, min, max, a1, a2, tip); - - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; - - ui_check_but(but); - + ui_check_but_and_iconize(but, icon); return but; } static uiBut *uiDefIconButBit(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) @@ -2941,29 +2962,22 @@ uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - - but= ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); - if(but) { - if(icon) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; - } - ui_check_but(but); - } - + but= ui_def_but_rna_propname(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + ui_check_but_and_iconize(but, icon); + return but; +} +uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +{ + uiBut *but; + but= ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + ui_check_but_and_iconize(but, icon); return but; } uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, "", x1, y1, x2, y2, tip); - if(but) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; - ui_check_but(but); - } - + ui_check_but_and_iconize(but, icon); return but; } @@ -2971,14 +2985,8 @@ uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { uiBut *but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); - - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; - + ui_check_but_and_iconize(but, icon); but->flag|= UI_ICON_LEFT; - - ui_check_but(but); - return but; } static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) @@ -3026,31 +3034,25 @@ uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int i uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip) { uiBut *but; - - but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); - if(but) { - if(icon) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; - } - but->flag|= UI_ICON_LEFT; - ui_check_but(but); - } - + but= ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); + ui_check_but_and_iconize(but, icon); + but->flag|= UI_ICON_LEFT; + return but; +} +uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip) +{ + uiBut *but; + but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); + ui_check_but_and_iconize(but, icon); + but->flag|= UI_ICON_LEFT; return but; } uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip); - if(but) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; - but->flag|= UI_ICON_LEFT; - ui_check_but(but); - } - + ui_check_but_and_iconize(but, icon); + but->flag|= UI_ICON_LEFT; return but; } diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 75e7ee701a2..d9691819b29 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -1,3 +1,27 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + */ + /** \file blender/editors/interface/interface_anim.c * \ingroup edinterface */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 1a36130b522..066d7c470af 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1290,7 +1290,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho else if(ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; if (but->flag & UI_HAS_ICON) - startx += 16; + startx += UI_DPI_ICON_SIZE; } /* mouse dragged outside the widget to the left */ @@ -2856,7 +2856,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - int mx, my, click= 0; + int mx, my /*, click= 0 */; int retval= WM_UI_HANDLER_CONTINUE; int horizontal= (but->x2 - but->x1 > but->y2 - but->y1); @@ -2878,8 +2878,10 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); retval= WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) + /* UNUSED - otherwise code is ok, add back if needed */ + /* else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) click= 1; + */ } } else if(data->state == BUTTON_STATE_NUM_EDITING) { @@ -3677,6 +3679,9 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt return WM_UI_HANDLER_BREAK; } + /* UNUSED but keep for now */ + (void)changed; + return WM_UI_HANDLER_CONTINUE; } @@ -3691,12 +3696,12 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx Histogram *hist = (Histogram *)but->poin; /* rcti rect; */ int changed= 1; - float dx, dy, yfac=1.f; + float /* dx, */ dy, yfac=1.f; /* UNUSED */ /* rect.xmin= but->x1; rect.xmax= but->x2; */ /* rect.ymin= but->y1; rect.ymax= but->y2; */ - dx = mx - data->draglastx; + /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; @@ -3774,12 +3779,12 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, Scopes *scopes = (Scopes *)but->poin; /* rcti rect; */ int changed= 1; - float dx, dy, yfac=1.f; + float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */ /* rect.xmin= but->x1; rect.xmax= but->x2; */ /* rect.ymin= but->y1; rect.ymax= but->y2; */ - dx = mx - data->draglastx; + /* dx = mx - data->draglastx; */ /* UNUSED */ dy = my - data->draglasty; @@ -3788,7 +3793,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, scopes->wavefrm_height = (but->y2 - but->y1) + (data->dragstarty - my); } else { /* scale waveform values */ - yfac = scopes->wavefrm_yfac; + /* yfac = scopes->wavefrm_yfac; */ /* UNUSED */ scopes->wavefrm_yfac += dy/200.0f; CLAMP(scopes->wavefrm_yfac, 0.5f, 2.f); @@ -4067,7 +4072,6 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) /* complex code to change name of button */ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) { - wmKeyMap *km= NULL; char *butstr_orig; // XXX but->str changed... should not, remove the hotkey from it @@ -4080,10 +4084,6 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) but->str= but->strdata; ui_check_but(but); - - /* set the keymap editable else the key wont save */ - WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km); - WM_keymap_copy_to_user(km); } else { /* shortcut was removed */ @@ -4095,6 +4095,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) { + wmWindowManager *wm= CTX_wm_manager(C); uiBlock *block; uiBut *but = (uiBut *)arg; wmKeyMap *km; @@ -4107,7 +4108,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) kmi = WM_keymap_item_find_id(km, kmi_id); - RNA_pointer_create(NULL, &RNA_KeyMapItem, kmi, &ptr); + RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetHandleFunc(block, but_shortcut_name_func, but); @@ -4126,6 +4127,7 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg) static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) { + wmWindowManager *wm= CTX_wm_manager(C); uiBlock *block; uiBut *but = (uiBut *)arg; wmKeyMap *km; @@ -4134,19 +4136,25 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) uiLayout *layout; uiStyle *style= UI_GetStyle(); IDProperty *prop= (but->opptr)? but->opptr->data: NULL; + int kmi_id; /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */ km = WM_keymap_guess_opname(C, but->optype->idname); kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0); + kmi_id = kmi->id; - if (prop) { + /* copy properties, prop can be NULL for reset */ + if(prop) prop= IDP_CopyProperty(prop); - } - - /* prop can be NULL */ WM_keymap_properties_reset(kmi, prop); - RNA_pointer_create(NULL, &RNA_KeyMapItem, kmi, &ptr); + /* update and get pointers again */ + WM_keyconfig_update(wm); + + km = WM_keymap_guess_opname(C, but->optype->idname); + kmi = WM_keymap_item_find_id(km, kmi_id); + + RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetHandleFunc(block, but_shortcut_name_func, but); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 3bf2a9ddd02..412c0233c35 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -742,6 +742,7 @@ static DrawInfo *icon_create_drawinfo(void) return di; } +/* note!, returns unscaled by DPI, may need to multiply result by UI_DPI_ICON_FAC */ int UI_icon_get_width(int icon_id) { Icon *icon = NULL; @@ -952,7 +953,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al Icon *icon = NULL; DrawInfo *di = NULL; IconImage *iimg; - float fdraw_size= UI_DPI_FAC*draw_size; + float fdraw_size= UI_DPI_ICON_FAC*draw_size; int w, h; icon = BKE_icon_get(icon_id); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 2d0f49f293b..9ba7fc9effc 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -421,7 +421,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in } } else if(subtype == PROP_DIRECTION) { - uiDefButR(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X*3, UI_UNIT_Y*3, ptr, RNA_property_identifier(prop), 0, 0, 0, -1, -1, NULL); + 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); } else { if(ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) @@ -463,11 +463,9 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt { uiBut *but; EnumPropertyItem *item; - const char *identifier; const char *name; int a, totitem, itemw, icon, value, free; - identifier= RNA_property_identifier(prop); RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free); uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1)); @@ -481,11 +479,11 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt itemw= ui_text_icon_width(block->curlayout, name, icon, 0); if(icon && name[0] && !icon_only) - but= uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + but= uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); else if(icon) - but= uiDefIconButR(block, ROW, 0, icon, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + but= uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); else - but= uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + but= uiDefButR_prop(block, ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); if(ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) but->flag |= UI_TEXT_LEFT; @@ -542,7 +540,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); } else if(flag & UI_ITEM_R_EVENT) { - uiDefButR(block, KEYEVT, 0, name, x, y, w, h, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); + uiDefButR_prop(block, KEYEVT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL); } else if(flag & UI_ITEM_R_FULL_EVENT) { if(RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { @@ -550,7 +548,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n WM_keymap_item_to_string(ptr->data, buf, sizeof(buf)); - but= uiDefButR(block, HOTKEYEVT, 0, buf, x, y, w, h, ptr, RNA_property_identifier(prop), 0, 0, 0, -1, -1, NULL); + but= uiDefButR_prop(block, HOTKEYEVT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL); uiButSetFunc(but, ui_keymap_but_cb, but, NULL); if (flag & UI_ITEM_R_IMMEDIATE) uiButSetFlag(but, UI_BUT_IMMEDIATE); @@ -1010,11 +1008,11 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index const char *identifier= RNA_property_identifier(prop); if(icon && name[0] && !icon_only) - uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); else if(icon) uiDefIconButR(block, ROW, 0, icon, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL); else - uiDefButR(block, ROW, 0, name, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + uiDefButR_prop(block, ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); } /* expanded enum */ else if(type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG)) @@ -2749,6 +2747,25 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in uiItemL(layout, "* Redo Unsupported *", ICON_NONE); // XXX, could give some nicer feedback or not show redo panel at all? } + /* menu */ + 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! */ + PointerRNA op_ptr; + uiLayout *row; + + row= uiLayoutRow(layout, TRUE); + uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE); + + WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add"); + RNA_string_set(&op_ptr, "operator", op->type->idname); + op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMIN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); + + WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add"); + RNA_string_set(&op_ptr, "operator", op->type->idname); + RNA_boolean_set(&op_ptr, "remove_active", 1); + op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMOUT, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); + } + if(op->type->ui) { op->layout= layout; op->type->ui((bContext*)C, op); @@ -2763,25 +2780,6 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - /* menu */ - 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! */ - PointerRNA op_ptr; - uiLayout *row; - - row= uiLayoutRow(layout, TRUE); - uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE); - - WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add"); - RNA_string_set(&op_ptr, "operator", op->type->idname); - op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMIN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); - - WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add"); - RNA_string_set(&op_ptr, "operator", op->type->idname); - RNA_boolean_set(&op_ptr, "remove_active", 1); - op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMOUT, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); - } - /* main draw call */ empty= uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 17c064f3ba2..ba259ed3def 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1934,31 +1934,31 @@ static void do_picker_new_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(a #define PICKER_TOTAL_W (PICKER_W+PICKER_SPACE+PICKER_BAR) -static void circle_picker(uiBlock *block, PointerRNA *ptr, const char *propname) +static void circle_picker(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop) { uiBut *bt; /* HS circle */ - bt= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, propname, 0, 0.0, 0.0, 0, 0, "Color"); + bt= uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, prop, 0, 0.0, 0.0, 0, 0, "Color"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - bt= uiDefButR(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, propname, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "Value"); + bt= uiDefButR_prop(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, prop, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "Value"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } -static void square_picker(uiBlock *block, PointerRNA *ptr, const char *propname, int type) +static void square_picker(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int type) { uiBut *bt; int bartype = type + 3; /* HS square */ - bt= uiDefButR(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, propname, 0, 0.0, 0.0, type, 0, "Color"); + bt= uiDefButR_prop(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, prop, 0, 0.0, 0.0, type, 0, "Color"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); /* value */ - bt= uiDefButR(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, propname, 0, 0.0, 0.0, bartype, 0, "Value"); + bt= uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, prop, 0, 0.0, 0.0, bartype, 0, "Value"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } @@ -1973,7 +1973,6 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR static char hexcol[128]; float rgb_gamma[3]; float min, max, step, precision; - const char *propname = RNA_property_identifier(prop); float *hsv= ui_block_hsv_get(block); ui_block_hsv_get(block); @@ -1999,16 +1998,16 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR switch (U.color_picker_type) { case USER_CP_CIRCLE: - circle_picker(block, ptr, propname); + circle_picker(block, ptr, prop); break; case USER_CP_SQUARE_SV: - square_picker(block, ptr, propname, UI_GRAD_SV); + square_picker(block, ptr, prop, UI_GRAD_SV); break; case USER_CP_SQUARE_HS: - square_picker(block, ptr, propname, UI_GRAD_HS); + square_picker(block, ptr, prop, UI_GRAD_HS); break; case USER_CP_SQUARE_HV: - square_picker(block, ptr, propname, UI_GRAD_HV); + square_picker(block, ptr, prop, UI_GRAD_HV); break; } @@ -2027,11 +2026,11 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR /* RGB values */ uiBlockBeginAlign(block); - bt= uiDefButR(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, propname, 0, 0.0, 0.0, 0, 3, "Red"); + bt= uiDefButR_prop(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, prop, 0, 0.0, 0.0, 0, 3, "Red"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - bt= uiDefButR(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, propname, 1, 0.0, 0.0, 0, 3, "Green"); + bt= uiDefButR_prop(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, prop, 1, 0.0, 0.0, 0, 3, "Green"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); - bt= uiDefButR(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, propname, 2, 0.0, 0.0, 0, 3, "Blue"); + bt= uiDefButR_prop(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, "Blue"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); // could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2048,7 +2047,7 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR uiBlockEndAlign(block); if(rgb[3] != FLT_MAX) { - bt= uiDefButR(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, propname, 3, 0.0, 0.0, 0, 0, "Alpha"); + bt= uiDefButR_prop(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, prop, 3, 0.0, 0.0, 0, 0, "Alpha"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } else { diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 7d1596459dd..af3d1c2d5e6 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -149,9 +149,9 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str, int xofs=0, yofs; uiStyleFontSet(fs); - - height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */ - yofs= floor( 0.5f*(rect->ymax - rect->ymin - height)); + + height= BLF_ascender(fs->uifont_id); + yofs= ceil( 0.5f*(rect->ymax - rect->ymin - height)); if(fs->align==UI_STYLE_TEXT_CENTER) { xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str))); @@ -206,9 +206,9 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str) uiStyleFontSet(fs); - height= BLF_height(fs->uifont_id, "2"); /* correct offset is on baseline, the j is below that */ + height= BLF_ascender(fs->uifont_id); /* becomes x-offset when rotated */ - xofs= floor( 0.5f*(rect->ymax - rect->ymin - height)) + 1; + xofs= ceil( 0.5f*(rect->ymax - rect->ymin - height)); /* ignore UI_STYLE, always aligned to top */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index c1784da48bd..92b15ab4269 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -53,6 +53,7 @@ #include "BKE_displist.h" #include "ED_screen.h" +#include "ED_object.h" #include "ED_render.h" #include "RNA_access.h" @@ -275,18 +276,28 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) break; case UI_ID_ALONE: if(id) { + const int do_scene_obj= (GS(id->name) == ID_OB) && + (template->ptr.type == &RNA_SceneObjects); + /* make copy */ - if(id_copy(id, &newid, 0) && newid) { - /* copy animation actions too */ - BKE_copy_animdata_id_action(id); - /* us is 1 by convention, but RNA_property_pointer_set - will also incremement it, so set it to zero */ - newid->us= 0; - - /* assign copy */ - RNA_id_pointer_create(newid, &idptr); - RNA_property_pointer_set(&template->ptr, template->prop, idptr); - RNA_property_update(C, &template->ptr, template->prop); + if(do_scene_obj) { + Scene *scene= CTX_data_scene(C); + ED_object_single_user(scene, (struct Object *)id); + WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + } + else { + if(id_copy(id, &newid, 0) && newid) { + /* copy animation actions too */ + BKE_copy_animdata_id_action(id); + /* us is 1 by convention, but RNA_property_pointer_set + will also incremement it, so set it to zero */ + newid->us= 0; + + /* assign copy */ + RNA_id_pointer_create(newid, &idptr); + RNA_property_pointer_set(&template->ptr, template->prop, idptr); + RNA_property_update(C, &template->ptr, template->prop); + } } } break; @@ -404,10 +415,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str sprintf(str, "%d", id->us); - if(id->us<10) - but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X,UI_UNIT_Y, NULL, 0, 0, 0, 0, _("Displays number of users of this data. Click to make a single-user copy.")); - else - but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X+10,UI_UNIT_Y, NULL, 0, 0, 0, 0, _("Displays number of users of this data. Click to make a single-user copy.")); + but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, _("Displays number of users of this data. Click to make a single-user copy.")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable) @@ -1884,7 +1892,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam col = uiLayoutColumn(layout, 0); row= uiLayoutRow(col, 1); - but= uiDefButR(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, propname, -1, 0.0, 0.0, 0, 0, ""); + but= uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, ""); if(lock) { but->flag |= UI_BUT_COLOR_LOCK; @@ -1903,7 +1911,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam uiItemS(row); if (value_slider) - uiDefButR(block, HSVCUBE, 0, "", WHEEL_SIZE+6, 0, 14, WHEEL_SIZE, ptr, propname, -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); + uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE+6, 0, 14, WHEEL_SIZE, ptr, prop, -1, softmin, softmax, UI_GRAD_V_ALT, 0, ""); } /********************* Layer Buttons Template ************************/ @@ -2034,7 +2042,7 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int return rnaicon; } -static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon, PointerRNA *activeptr, const char *activepropname) +static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon, PointerRNA *activeptr, PropertyRNA *activeprop) { uiBlock *block= uiLayoutGetBlock(layout); uiBut *but; @@ -2048,7 +2056,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe /* list item behind label & other buttons */ sub= uiLayoutRow(overlap, 0); - but= uiDefButR(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, ""); + but= uiDefButR_prop(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); sub= uiLayoutRow(overlap, 0); @@ -2201,7 +2209,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * row= uiLayoutRow(col, 0); icon= list_item_icon_get(C, &itemptr, rnaicon, 1); - but= uiDefIconButR(block, LISTROW, 0, icon, 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, ""); + but= uiDefIconButR_prop(block, LISTROW, 0, icon, 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, ""); uiButSetFlag(but, UI_BUT_NO_TOOLTIP); @@ -2241,7 +2249,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* next/prev button */ sprintf(str, "%d :", i); - but= uiDefIconTextButR(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activepropname, 0, 0, 0, 0, 0, ""); + but= uiDefIconTextButR_prop(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); if(i == 0) uiButSetFlag(but, UI_BUT_DISABLED); } @@ -2280,7 +2288,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* create list items */ RNA_PROP_BEGIN(ptr, itemptr, prop) { if(i >= pa->list_scroll && i<pa->list_scroll+items) - list_item_row(C, col, ptr, &itemptr, i, rnaicon, activeptr, activepropname); + list_item_row(C, col, ptr, &itemptr, i, rnaicon, activeptr, activeprop); i++; } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 8f20f47f539..90735cc419b 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -53,56 +53,53 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2) { uiBut *but=NULL; - const char *propname= RNA_property_identifier(prop); - char prop_item[MAX_IDPROP_NAME+4]; /* size of the ID prop name + room for [""] */ - int arraylen= RNA_property_array_length(ptr, prop); - - /* support for custom props */ - if(RNA_property_is_idprop(prop)) { - sprintf(prop_item, "[\"%s\"]", propname); - propname= prop_item; - } switch(RNA_property_type(prop)) { - case PROP_BOOLEAN: { + case PROP_BOOLEAN: + { + int arraylen= RNA_property_array_length(ptr, prop); if(arraylen && index == -1) return NULL; if(icon && name && name[0] == '\0') - but= uiDefIconButR(block, ICONTOG, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefIconButR_prop(block, ICONTOG, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else if(icon) - but= uiDefIconTextButR(block, ICONTOG, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefIconTextButR_prop(block, ICONTOG, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else - but= uiDefButR(block, OPTION, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefButR_prop(block, OPTION, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; } case PROP_INT: case PROP_FLOAT: + { + int arraylen= RNA_property_array_length(ptr, prop); + if(arraylen && index == -1) { if(ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) - but= uiDefButR(block, COL, 0, name, x1, y1, x2, y2, ptr, propname, 0, 0, 0, -1, -1, NULL); + but= uiDefButR_prop(block, COL, 0, name, x1, y1, x2, y2, ptr, prop, 0, 0, 0, -1, -1, NULL); } else if(RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR) - but= uiDefButR(block, NUMSLI, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefButR_prop(block, NUMSLI, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else - but= uiDefButR(block, NUM, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefButR_prop(block, NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; + } case PROP_ENUM: if(icon && name && name[0] == '\0') - but= uiDefIconButR(block, MENU, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefIconButR_prop(block, MENU, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else if(icon) - but= uiDefIconTextButR(block, MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefIconTextButR_prop(block, MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else - but= uiDefButR(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefButR_prop(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; case PROP_STRING: if(icon && name && name[0] == '\0') - but= uiDefIconButR(block, TEX, 0, icon, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefIconButR_prop(block, TEX, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else if(icon) - but= uiDefIconTextButR(block, TEX, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefIconTextButR_prop(block, TEX, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else - but= uiDefButR(block, TEX, 0, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefButR_prop(block, TEX, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; case PROP_POINTER: { PointerRNA pptr; @@ -114,7 +111,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind if(icon == ICON_DOT) icon= 0; - but= uiDefIconTextButR(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, propname, index, 0, 0, -1, -1, NULL); + but= uiDefIconTextButR_prop(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; } case PROP_COLLECTION: { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 25a64994f5c..d235fd0c16a 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -771,7 +771,6 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) /* icons have been standardized... and this call draws in untransformed coordinates */ -#define ICON_HEIGHT UI_DPI_FAC*16.0f static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect) { @@ -791,15 +790,15 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect if(aspect != but->aspect) { /* prevent scaling up icon in pupmenu */ if (aspect < 1.0f) { - height= ICON_HEIGHT; + height= UI_DPI_ICON_SIZE; aspect = 1.0f; } else - height= ICON_HEIGHT/aspect; + height= UI_DPI_ICON_SIZE/aspect; } else - height= ICON_HEIGHT; + height= UI_DPI_ICON_SIZE; /* calculate blend color */ if ELEM4(but->type, TOG, ROW, TOGN, LISTROW) { @@ -866,7 +865,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) int border= (but->flag & UI_BUT_ALIGN_RIGHT)? 8: 10; int okwidth= rect->xmax-rect->xmin - border; - if (but->flag & UI_HAS_ICON) okwidth -= 16; + if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE; /* need to set this first */ uiStyleFontSet(fstyle); @@ -1149,7 +1148,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB if (but->flag & UI_HAS_ICON) { widget_draw_icon(but, but->icon+but->iconadd, 1.0f, rect); - rect->xmin += UI_icon_get_width(but->icon+but->iconadd); + rect->xmin += (int)((float)UI_icon_get_width(but->icon+but->iconadd) * UI_DPI_ICON_FAC); if(but->editstr || (but->flag & UI_TEXT_LEFT)) rect->xmin += 5; @@ -3133,7 +3132,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic /* text location offset */ rect->xmin+=5; - if(iconid) rect->xmin+= ICON_HEIGHT; + if(iconid) rect->xmin+= UI_DPI_ICON_SIZE; /* cut string in 2 parts? */ cpoin= strchr(name, '|'); @@ -3158,7 +3157,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic if(iconid) { int xs= rect->xmin+4; - int ys= 1 + (rect->ymin+rect->ymax- ICON_HEIGHT)/2; + int ys= 1 + (rect->ymin+rect->ymax- UI_DPI_ICON_SIZE)/2; glEnable(GL_BLEND); UI_icon_draw_aspect(xs, ys, iconid, 1.2f, 0.5f); /* XXX scale weak get from fstyle? */ glDisable(GL_BLEND); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 56ef5e9e8cc..e71f709f89b 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1,6 +1,3 @@ -/** \file blender/editors/interface/resources.c - * \ingroup edinterface - */ /* * $Id$ * @@ -33,6 +30,10 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ +/** \file blender/editors/interface/resources.c + * \ingroup edinterface + */ + #include <math.h> #include <stdlib.h> #include <string.h> @@ -359,7 +360,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->syntaxv; break; case TH_NODE_GROUP: cp= ts->syntaxc; break; - + case TH_NODE_CURVING: + cp= &ts->noodle_curving; break; + case TH_SEQ_MOVIE: cp= ts->movie; break; case TH_SEQ_IMAGE: @@ -786,6 +789,7 @@ void ui_theme_init_default(void) SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255); /* operator */ SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */ SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */ + btheme->tnode.noodle_curving = 5; /* space logic */ btheme->tlogic= btheme->tv3d; @@ -1421,7 +1425,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) { wmKeyMap *km; - for(km=U.keymaps.first; km; km=km->next) { + for(km=U.user_keymaps.first; km; km=km->next) { if (strcmp(km->idname, "Armature_Sketch")==0) strcpy(km->idname, "Armature Sketch"); else if (strcmp(km->idname, "View3D")==0) @@ -1552,7 +1556,14 @@ void init_userdef_do_versions(void) /* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */ U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET; } - + + if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) { + bTheme *btheme; + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + btheme->tnode.noodle_curving = 5; + } + } + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; @@ -1584,6 +1595,12 @@ void init_userdef_do_versions(void) if (U.anisotropic_filter <= 0) U.anisotropic_filter = 1; + if (U.ndof_sensitivity == 0.0f) { + U.ndof_sensitivity = 1.0f; + U.ndof_flag = NDOF_LOCK_HORIZON | + NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE; + } + /* funny name, but it is GE stuff, moves userdef stuff to engine */ // XXX space_set_commmandline_options(); /* this timer uses U */ |