Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c43
-rw-r--r--source/blender/editors/interface/interface_anim.c30
-rw-r--r--source/blender/editors/interface/interface_handlers.c46
-rw-r--r--source/blender/editors/interface/interface_icons.c1
-rw-r--r--source/blender/editors/interface/interface_intern.h16
-rw-r--r--source/blender/editors/interface/interface_layout.c185
-rw-r--r--source/blender/editors/interface/interface_regions.c824
-rw-r--r--source/blender/editors/interface/interface_templates.c142
-rw-r--r--source/blender/editors/interface/interface_utils.c20
-rw-r--r--source/blender/editors/interface/interface_widgets.c22
-rw-r--r--source/blender/editors/interface/resources.c13
-rw-r--r--source/blender/editors/interface/view2d_ops.c13
12 files changed, 717 insertions, 638 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 3c6e12905d6..92a3a4cf841 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -225,7 +225,6 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
uiStyle *style= U.uistyles.first; // XXX pass on as arg
uiBut *bt;
int i = 0, j, x1addval= offset, nextcol;
- int lastcol= 0, col= 0;
uiStyleFontSet(&style->widget);
@@ -238,26 +237,18 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
if(j > i) i = j;
}
-
- if(bt->next && bt->x1 < bt->next->x1)
- lastcol++;
}
/* cope with multi collumns */
bt= block->buttons.first;
while(bt) {
- if(bt->next && bt->x1 < bt->next->x1) {
+ if(bt->next && bt->x1 < bt->next->x1)
nextcol= 1;
- col++;
- }
else nextcol= 0;
bt->x1 = x1addval;
bt->x2 = bt->x1 + i + block->bounds;
- if(col == lastcol)
- bt->x2= MAX2(bt->x2, offset + block->minbounds);
-
ui_check_but(bt); // clips text again
if(nextcol)
@@ -290,7 +281,7 @@ void ui_bounds_block(uiBlock *block)
if(bt->x2 > block->maxx) block->maxx= bt->x2;
if(bt->y2 > block->maxy) block->maxy= bt->y2;
-
+
bt= bt->next;
}
@@ -300,8 +291,6 @@ void ui_bounds_block(uiBlock *block)
block->maxy += block->bounds;
}
- block->maxx= block->minx + MAX2(block->maxx - block->minx, block->minbounds);
-
/* hardcoded exception... but that one is annoying with larger safety */
bt= block->buttons.first;
if(bt && strncmp(bt->str, "ERROR", 5)==0) xof= 10;
@@ -1089,7 +1078,7 @@ void ui_get_but_vectorf(uiBut *but, float *vec)
vec[0]= vec[1]= vec[2]= 0.0f;
if(RNA_property_type(prop) == PROP_FLOAT) {
- tot= RNA_property_array_length(&but->rnapoin, prop);
+ tot= RNA_property_array_length(prop);
tot= MIN2(tot, 3);
for(a=0; a<tot; a++)
@@ -1123,7 +1112,7 @@ void ui_set_but_vectorf(uiBut *but, float *vec)
prop= but->rnaprop;
if(RNA_property_type(prop) == PROP_FLOAT) {
- tot= RNA_property_array_length(&but->rnapoin, prop);
+ tot= RNA_property_array_length(prop);
tot= MIN2(tot, 3);
for(a=0; a<tot; a++)
@@ -1181,19 +1170,19 @@ double ui_get_but_val(uiBut *but)
switch(RNA_property_type(prop)) {
case PROP_BOOLEAN:
- if(RNA_property_array_length(&but->rnapoin, prop))
+ if(RNA_property_array_length(prop))
value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_boolean_get(&but->rnapoin, prop);
break;
case PROP_INT:
- if(RNA_property_array_length(&but->rnapoin, prop))
+ if(RNA_property_array_length(prop))
value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_int_get(&but->rnapoin, prop);
break;
case PROP_FLOAT:
- if(RNA_property_array_length(&but->rnapoin, prop))
+ if(RNA_property_array_length(prop))
value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
else
value= RNA_property_float_get(&but->rnapoin, prop);
@@ -1245,19 +1234,19 @@ void ui_set_but_val(uiBut *but, double value)
if(RNA_property_editable(&but->rnapoin, prop)) {
switch(RNA_property_type(prop)) {
case PROP_BOOLEAN:
- if(RNA_property_array_length(&but->rnapoin, prop))
+ if(RNA_property_array_length(prop))
RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_boolean_set(&but->rnapoin, prop, value);
break;
case PROP_INT:
- if(RNA_property_array_length(&but->rnapoin, prop))
+ if(RNA_property_array_length(prop))
RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_int_set(&but->rnapoin, prop, value);
break;
case PROP_FLOAT:
- if(RNA_property_array_length(&but->rnapoin, prop))
+ if(RNA_property_array_length(prop))
RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_float_set(&but->rnapoin, prop, value);
@@ -2297,12 +2286,8 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
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");
- }
+ if(!item[i].identifier[0])
+ 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
@@ -2414,7 +2399,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
but->rnapoin= *ptr;
but->rnaprop= prop;
- if(RNA_property_array_length(&but->rnapoin, but->rnaprop))
+ if(RNA_property_array_length(but->rnaprop))
but->rnaindex= index;
else
but->rnaindex= 0;
@@ -2854,8 +2839,6 @@ void uiBlockFlipOrder(uiBlock *block)
if(U.uiflag & USER_MENUFIXEDORDER)
return;
- else if(block->flag & UI_BLOCK_NO_FLIP)
- return;
for(but= block->buttons.first; but; but= but->next) {
if(but->flag & UI_BUT_ALIGN) return;
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 8c41726b81b..2993a1aba15 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -152,8 +152,6 @@ void ui_but_anim_autokey(uiBut *but, Scene *scene, float cfra)
flag |= INSERTKEY_NEEDED;
if (IS_AUTOKEY_FLAG(AUTOMATKEY))
flag |= INSERTKEY_MATRIX;
- if (IS_AUTOKEY_MODE(scene, EDITKEYS))
- flag |= INSERTKEY_REPLACE;
fcu->flag &= ~FCURVE_SELECTED;
insert_keyframe(id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
@@ -209,18 +207,6 @@ void ui_but_anim_remove_driver(bContext *C)
WM_operator_name_call(C, "ANIM_OT_remove_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
}
-void ui_but_anim_add_keyingset(bContext *C)
-{
- /* this operator calls uiAnimContextProperty above */
- WM_operator_name_call(C, "ANIM_OT_add_keyingset_button", WM_OP_INVOKE_DEFAULT, NULL);
-}
-
-void ui_but_anim_remove_keyingset(bContext *C)
-{
- /* this operator calls uiAnimContextProperty above */
- WM_operator_name_call(C, "ANIM_OT_remove_keyingset_button", WM_OP_INVOKE_DEFAULT, NULL);
-}
-
void ui_but_anim_menu(bContext *C, uiBut *but)
{
uiPopupMenu *pup;
@@ -231,7 +217,7 @@ void ui_but_anim_menu(bContext *C, uiBut *but)
pup= uiPupMenuBegin(C, RNA_property_ui_name(but->rnaprop), 0);
layout= uiPupMenuLayout(pup);
- length= RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ length= RNA_property_array_length(but->rnaprop);
if(but->flag & UI_BUT_ANIMATED_KEY) {
if(length) {
@@ -276,20 +262,6 @@ void ui_but_anim_menu(bContext *C, uiBut *but)
else
uiItemBooleanO(layout, "Add Driver", 0, "ANIM_OT_add_driver_button", "all", 0);
}
-
- if(RNA_property_animateable(&but->rnapoin, but->rnaprop)) {
- uiItemS(layout);
-
- if(length) {
- uiItemBooleanO(layout, "Add All to Keying Set", 0, "ANIM_OT_add_keyingset_button", "all", 1);
- uiItemBooleanO(layout, "Add Single to Keying Set", 0, "ANIM_OT_add_keyingset_button", "all", 0);
- uiItemO(layout, "Remove from Keying Set", 0, "ANIM_OT_remove_keyingset_button");
- }
- else {
- uiItemBooleanO(layout, "Add to Keying Set", 0, "ANIM_OT_add_keyingset_button", "all", 0);
- uiItemO(layout, "Remove from Keying Set", 0, "ANIM_OT_remove_keyingset_button");
- }
- }
uiPupMenuEnd(C, pup);
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 259ccba6b89..e3518b446ba 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -678,11 +678,7 @@ static void ui_add_link(uiBut *from, uiBut *to)
return;
}
- if (from->type==INLINK && to->type==INLINK) {
- printf("cannot link\n");
- return;
- }
- else if (from->type==LINK && to->type==INLINK) {
+ if (from->type==LINK && to->type==INLINK) {
if( from->link->tocode != (int)to->hardmin ) {
printf("cannot link\n");
return;
@@ -1724,7 +1720,6 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
uiBlockCreateFunc func= NULL;
uiBlockHandleCreateFunc handlefunc= NULL;
uiMenuCreateFunc menufunc= NULL;
- char *menustr= NULL;
void *arg= NULL;
switch(but->type) {
@@ -1749,15 +1744,16 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
data->value= data->origvalue;
but->editval= &data->value;
- menustr= but->str;
+ handlefunc= ui_block_func_MENU;
+ arg= but;
}
break;
case ICONROW:
- menufunc= ui_block_func_ICONROW;
+ handlefunc= ui_block_func_ICONROW;
arg= but;
break;
case ICONTEXTROW:
- menufunc= ui_block_func_ICONTEXTROW;
+ handlefunc= ui_block_func_ICONTEXTROW;
arg= but;
break;
case COL:
@@ -1775,8 +1771,8 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
if(but->block->handle)
data->menu->popup= but->block->handle->popup;
}
- else if(menufunc || menustr) {
- data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg, menustr);
+ else if(menufunc) {
+ data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg);
if(but->block->handle)
data->menu->popup= but->block->handle->popup;
}
@@ -3265,18 +3261,18 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
ui_but_copy_paste(C, but, data, (event->type == CKEY)? 'c': 'v');
return WM_UI_HANDLER_BREAK;
}
- /* handle keyframing */
+ /* handle keyframeing */
else if(event->type == IKEY && event->val == KM_PRESS) {
if(event->alt)
ui_but_anim_delete_keyframe(C);
else
ui_but_anim_insert_keyframe(C);
-
+
ED_region_tag_redraw(CTX_wm_region(C));
-
+
return WM_UI_HANDLER_BREAK;
}
- /* handle drivers */
+ /* handle driver adding */
else if(event->type == DKEY && event->val == KM_PRESS) {
if(event->alt)
ui_but_anim_remove_driver(C);
@@ -3287,17 +3283,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
return WM_UI_HANDLER_BREAK;
}
- /* handle keyingsets */
- else if(event->type == KKEY && event->val == KM_PRESS) {
- if(event->alt)
- ui_but_anim_remove_keyingset(C);
- else
- ui_but_anim_remove_keyingset(C);
-
- ED_region_tag_redraw(CTX_wm_region(C));
-
- return WM_UI_HANDLER_BREAK;
- }
/* handle menu */
else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {
/* RMB has two options now */
@@ -3744,15 +3729,10 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
}
}
- if(!data->cancel) {
- /* autokey & undo push */
+ /* autokey & undo push */
+ if(!data->cancel)
ui_apply_autokey_undo(C, but);
- /* popup menu memory */
- if(block->flag & UI_BLOCK_POPUP_MEMORY)
- ui_popup_menu_memory(block, but);
- }
-
/* disable tooltips until mousemove + last active flag */
for(block=data->region->uiblocks.first; block; block=block->next) {
for(bt=block->buttons.first; bt; bt=bt->next)
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 6c4110c8c37..549164c23a1 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -34,7 +34,6 @@
#else
#include <io.h>
#include <direct.h>
-#include "BLI_winstuff.h"
#endif
#include "MEM_guardedalloc.h"
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 2e623114fe9..9ef5d65b69f 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -287,8 +287,7 @@ struct uiBlock {
char *lockstr;
float xofs, yofs; // offset to parent button
- int dobounds, mx, my; // for doing delayed
- int bounds, minbounds; // for doing delayed
+ int bounds, dobounds, mx, my; // for doing delayed
int endblock; // uiEndBlock done?
rctf safety; // pulldowns, to detect outside, can differ per case how it is created
@@ -298,7 +297,6 @@ struct uiBlock {
int tooltipdisabled; // to avoid tooltip after click
int active; // to keep blocks while drawing and free them afterwards
- int puphash; // popup menu hash for memory
void *evil_C; // XXX hack for dynamic operator enums
};
@@ -374,15 +372,14 @@ struct uiPopupBlockHandle {
float retvec[3];
};
+uiBlock *ui_block_func_MENU(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
+uiBlock *ui_block_func_ICONROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
+uiBlock *ui_block_func_ICONTEXTROW(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
uiBlock *ui_block_func_COL(struct bContext *C, uiPopupBlockHandle *handle, void *arg_but);
-void ui_block_func_ICONROW(struct bContext *C, uiLayout *layout, void *arg_but);
-void ui_block_func_ICONTEXTROW(struct bContext *C, uiLayout *layout, void *arg_but);
struct ARegion *ui_tooltip_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
void ui_tooltip_free(struct bContext *C, struct ARegion *ar);
-uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but);
-
/* searchbox for string button */
ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but);
int ui_searchbox_inside(struct ARegion *ar, int x, int y);
@@ -397,8 +394,7 @@ typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBl
uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg);
uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but,
- uiMenuCreateFunc create_func, void *arg, char *str);
-
+ uiMenuCreateFunc create_func, void *arg);
void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle);
void ui_set_name_menu(uiBut *but, int value);
@@ -467,8 +463,6 @@ void ui_but_anim_insert_keyframe(struct bContext *C);
void ui_but_anim_delete_keyframe(struct bContext *C);
void ui_but_anim_add_driver(struct bContext *C);
void ui_but_anim_remove_driver(struct bContext *C);
-void ui_but_anim_add_keyingset(struct bContext *C);
-void ui_but_anim_remove_keyingset(struct bContext *C);
void ui_but_anim_menu(struct bContext *C, uiBut *but);
int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen);
int ui_but_anim_expression_set(uiBut *but, const char *str);
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 04d575d96d4..fc4f7da56d2 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -310,30 +310,6 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int a
return sub;
}
-static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
-{
- wmWindow *win= CTX_wm_window(C);
- uiBut *but= arg_but, *cbut;
- PointerRNA *ptr= &but->rnapoin;
- PropertyRNA *prop= but->rnaprop;
- int i, index= GET_INT_FROM_POINTER(arg_index);
- int shift= win->eventstate->shift;
- int len= RNA_property_array_length(ptr, prop);
-
- if(!shift) {
- RNA_property_boolean_set_index(ptr, prop, index, 1);
-
- for(i=0; i<len; i++)
- if(i != index)
- RNA_property_boolean_set_index(ptr, prop, i, 0);
-
- RNA_property_update(C, ptr, prop);
-
- for(cbut=but->block->buttons.first; cbut; cbut=cbut->next)
- ui_check_but(cbut);
- }
-}
-
/* create buttons for an item with an RNA array */
static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand, int slider)
{
@@ -342,7 +318,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
PropertyType type;
PropertySubType subtype;
uiLayout *sub;
- int a, b;
+ int a;
/* retrieve type and subtype */
type= RNA_property_type(prop);
@@ -356,11 +332,9 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
/* create buttons */
- if(type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) {
+ if(type == PROP_BOOLEAN && len == 20) {
/* special check for layer layout */
int butw, buth, unit;
- int cols= (len >= 20)? 2: 1;
- int colbuts= len/(2*cols);
uiBlockSetCurLayout(block, uiLayoutFree(layout, 0));
@@ -368,23 +342,21 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
butw= unit;
buth= unit;
- for(b=0; b<cols; b++) {
- uiBlockBeginAlign(block);
+ uiBlockBeginAlign(block);
+ for(a=0; a<5; a++)
+ uiDefAutoButR(block, ptr, prop, a, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth);
+ for(a=0; a<5; a++)
+ uiDefAutoButR(block, ptr, prop, a+10, "", ICON_BLANK1, x + butw*a, y, butw, buth);
+ uiBlockEndAlign(block);
- for(a=0; a<colbuts; a++) {
- but= uiDefAutoButR(block, ptr, prop, a+b*colbuts, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth);
- if(subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+b*colbuts));
- }
- for(a=0; a<colbuts; a++) {
- but= uiDefAutoButR(block, ptr, prop, a+len/2+b*colbuts, "", ICON_BLANK1, x + butw*a, y, butw, buth);
- if(subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+len/2+b*colbuts));
- }
- uiBlockEndAlign(block);
+ x += 5*butw + style->buttonspacex;
- x += colbuts*butw + style->buttonspacex;
- }
+ uiBlockBeginAlign(block);
+ for(a=0; a<5; a++)
+ uiDefAutoButR(block, ptr, prop, a+5, "", ICON_BLANK1, x + butw*a, y+buth, butw, buth);
+ for(a=0; a<5; a++)
+ uiDefAutoButR(block, ptr, prop, a+15, "", ICON_BLANK1, x + butw*a, y, butw, buth);
+ uiBlockEndAlign(block);
}
else if(subtype == PROP_MATRIX) {
/* matrix layout */
@@ -563,7 +535,7 @@ static void ui_item_disabled(uiLayout *layout, char *name)
}
/* operator items */
-PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context, int flag)
+void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDProperty *properties, int context)
{
uiBlock *block= layout->root->block;
wmOperatorType *ot= WM_operatortype_find(idname, 0);
@@ -572,7 +544,7 @@ PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDP
if(!ot) {
ui_item_disabled(layout, idname);
- return PointerRNA_NULL;
+ return;
}
if(!name)
@@ -593,21 +565,10 @@ PointerRNA uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDP
but= uiDefButO(block, BUT, ot->idname, context, (char*)name, 0, 0, w, UI_UNIT_Y, NULL);
/* assign properties */
- if(properties || (flag & UI_ITEM_O_RETURN_PROPS)) {
+ if(properties) {
PointerRNA *opptr= uiButGetOperatorPtrRNA(but);
-
- if(properties) {
- opptr->data= properties;
- }
- else {
- IDPropertyTemplate val = {0};
- opptr->data= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
- }
-
- return *opptr;
+ opptr->data= properties;
}
-
- return PointerRNA_NULL;
}
static char *ui_menu_enumpropname(uiLayout *layout, char *opname, char *propname, int retval)
@@ -650,7 +611,7 @@ void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *pro
if(!name)
name= ui_menu_enumpropname(layout, opname, propname, value);
- uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
}
void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
@@ -658,8 +619,6 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
wmOperatorType *ot= WM_operatortype_find(opname, 0);
PointerRNA ptr;
PropertyRNA *prop;
- uiBut *bt;
- uiBlock *block= layout->root->block;
if(!ot || !ot->srna) {
ui_item_disabled(layout, opname);
@@ -672,31 +631,14 @@ void uiItemsEnumO(uiLayout *layout, char *opname, char *propname)
if(prop && RNA_property_type(prop) == PROP_ENUM) {
EnumPropertyItem *item;
int totitem, i, free;
- uiLayout *split= uiLayoutSplit(layout, 0);
- uiLayout *column= uiLayoutColumn(split, 0);
-
- RNA_property_enum_items(block->evil_C, &ptr, prop, &item, &totitem, &free);
- for(i=0; i<totitem; i++) {
- if(item[i].identifier[0]) {
- uiItemEnumO(column, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
- }
- else {
- if(item[i].name) {
- if(i != 0) {
- column= uiLayoutColumn(split, 0);
- /* inconsistent, but menus with labels do not look good flipped */
- block->flag |= UI_BLOCK_NO_FLIP;
- }
+ RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free);
- uiItemL(column, (char*)item[i].name, 0);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
- }
- else
- uiItemS(column);
- }
- }
+ for(i=0; i<totitem; i++)
+ if(item[i].identifier[0])
+ uiItemEnumO(layout, (char*)item[i].name, item[i].icon, opname, propname, item[i].value);
+ else
+ uiItemS(layout);
if(free)
MEM_freeN(item);
@@ -738,7 +680,7 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch
if(!name)
name= ui_menu_enumpropname(layout, opname, propname, value);
- uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
}
void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value)
@@ -748,7 +690,7 @@ void uiItemBooleanO(uiLayout *layout, char *name, int icon, char *opname, char *
WM_operator_properties_create(&ptr, opname);
RNA_boolean_set(&ptr, propname, value);
- uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
}
void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value)
@@ -758,7 +700,7 @@ void uiItemIntO(uiLayout *layout, char *name, int icon, char *opname, char *prop
WM_operator_properties_create(&ptr, opname);
RNA_int_set(&ptr, propname, value);
- uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
}
void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *propname, float value)
@@ -768,7 +710,7 @@ void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *pr
WM_operator_properties_create(&ptr, opname);
RNA_float_set(&ptr, propname, value);
- uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
}
void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value)
@@ -778,17 +720,17 @@ void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *p
WM_operator_properties_create(&ptr, opname);
RNA_string_set(&ptr, propname, value);
- uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext, 0);
+ uiItemFullO(layout, name, icon, opname, ptr.data, layout->root->opcontext);
}
void uiItemO(uiLayout *layout, char *name, int icon, char *opname)
{
- uiItemFullO(layout, name, icon, opname, NULL, layout->root->opcontext, 0);
+ uiItemFullO(layout, name, icon, opname, NULL, layout->root->opcontext);
}
/* RNA property items */
-static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int *r_w, int *r_h)
+static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA *prop, int index, int *r_w, int *r_h)
{
PropertyType type;
PropertySubType subtype;
@@ -797,7 +739,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA
/* arbitrary extended width by type */
type= RNA_property_type(prop);
subtype= RNA_property_subtype(prop);
- len= RNA_property_array_length(ptr, prop);
+ len= RNA_property_array_length(prop);
if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0])
name= "non-empty text";
@@ -812,7 +754,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA
if(!name[0] && icon == 0)
h= 0;
- if(ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER))
+ if(type == PROP_BOOLEAN && len == 20)
h += 2*UI_UNIT_Y;
else if(subtype == PROP_MATRIX)
h += ceil(sqrt(len))*UI_UNIT_Y;
@@ -821,24 +763,24 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PointerRNA
}
else if(ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
if(type == PROP_BOOLEAN && strcmp(name, "") != 0)
- w += UI_UNIT_X/5;
+ w += UI_UNIT_X;
else if(type == PROP_ENUM)
w += UI_UNIT_X/2;
else if(type == PROP_FLOAT || type == PROP_INT)
- w += UI_UNIT_X*3;
+ w += UI_UNIT_X*2;
}
*r_w= w;
*r_h= h;
}
-void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag)
+void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int expand, int slider, int toggle)
{
uiBlock *block= layout->root->block;
uiBut *but;
PropertyType type;
char namestr[UI_MAX_NAME_STR];
- int len, w, h, slider, toggle, expand;
+ int len, w, h;
if(!ptr->data || !prop)
return;
@@ -847,7 +789,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
/* retrieve info */
type= RNA_property_type(prop);
- len= RNA_property_array_length(ptr, prop);
+ len= RNA_property_array_length(prop);
/* set name and icon */
if(!name)
@@ -869,12 +811,8 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
}
- slider= (flag & UI_ITEM_R_SLIDER);
- toggle= (flag & UI_ITEM_R_TOGGLE);
- expand= (flag & UI_ITEM_R_EXPAND);
-
/* get size */
- ui_item_rna_size(layout, name, icon, ptr, prop, index, &w, &h);
+ ui_item_rna_size(layout, name, icon, prop, index, &w, &h);
/* array property */
if(index == RNA_NO_INDEX && len > 0)
@@ -910,7 +848,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
}
}
-void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int flag)
+void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand, int slider, int toggle)
{
PropertyRNA *prop;
@@ -925,7 +863,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop
return;
}
- uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, flag);
+ uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, 0, expand, slider, toggle);
}
void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value)
@@ -943,7 +881,7 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
return;
}
- uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0);
+ uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0);
}
void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value)
@@ -974,7 +912,7 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN
for(a=0; item[a].identifier; a++) {
if(item[a].value == ivalue) {
- uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0);
+ uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, 0, 0);
break;
}
}
@@ -986,8 +924,6 @@ void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRN
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
{
PropertyRNA *prop;
- uiBlock *block= layout->root->block;
- uiBut *bt;
prop= RNA_struct_find_property(ptr, propname);
@@ -999,31 +935,14 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
if(RNA_property_type(prop) == PROP_ENUM) {
EnumPropertyItem *item;
int totitem, i, free;
- uiLayout *split= uiLayoutSplit(layout, 0);
- uiLayout *column= uiLayoutColumn(split, 0);
-
- RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free);
- for(i=0; i<totitem; i++) {
- if(item[i].identifier[0]) {
- uiItemEnumR(column, (char*)item[i].name, 0, ptr, propname, item[i].value);
- }
- else {
- if(item[i].name) {
- if(i != 0) {
- column= uiLayoutColumn(split, 0);
- /* inconsistent, but menus with labels do not look good flipped */
- block->flag |= UI_BLOCK_NO_FLIP;
- }
+ RNA_property_enum_items(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free);
- uiItemL(column, (char*)item[i].name, 0);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
- }
- else
- uiItemS(column);
- }
- }
+ for(i=0; i<totitem; i++)
+ if(item[i].identifier[0])
+ uiItemEnumR(layout, (char*)item[i].name, 0, ptr, propname, item[i].value);
+ else
+ uiItemS(layout);
if(free)
MEM_freeN(item);
@@ -1160,7 +1079,7 @@ void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *p
/* create button */
block= uiLayoutGetBlock(layout);
- ui_item_rna_size(layout, name, icon, ptr, prop, 0, &w, &h);
+ ui_item_rna_size(layout, name, icon, prop, 0, &w, &h);
but= ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h);
ui_but_add_search(but, ptr, prop, searchptr, searchprop);
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 1d911fef418..bf921715524 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -38,7 +38,6 @@
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BLI_dynstr.h"
-#include "BLI_ghash.h"
#include "BKE_context.h"
#include "BKE_icons.h"
@@ -76,14 +75,13 @@
/*********************** Menu Data Parsing ********************* */
-typedef struct MenuEntry {
+typedef struct {
char *str;
int retval;
int icon;
- int sepr;
} MenuEntry;
-typedef struct MenuData {
+typedef struct {
char *instr;
char *title;
int titleicon;
@@ -113,7 +111,7 @@ static void menudata_set_title(MenuData *md, char *title, int titleicon)
md->titleicon= titleicon;
}
-static void menudata_add_item(MenuData *md, char *str, int retval, int icon, int sepr)
+static void menudata_add_item(MenuData *md, char *str, int retval, int icon)
{
if (md->nitems==md->itemssize) {
int nsize= md->itemssize?(md->itemssize<<1):1;
@@ -131,7 +129,6 @@ static void menudata_add_item(MenuData *md, char *str, int retval, int icon, int
md->items[md->nitems].str= str;
md->items[md->nitems].retval= retval;
md->items[md->nitems].icon= icon;
- md->items[md->nitems].sepr= sepr;
md->nitems++;
}
@@ -145,13 +142,12 @@ void menudata_free(MenuData *md)
/**
* Parse menu description strings, string is of the
- * form "[sss%t|]{(sss[%xNN]|), (%l|), (sss%l|)}", ssss%t indicates the
+ * form "[sss%t|]{(sss[%xNN]|), (%l|)}", ssss%t indicates the
* menu title, sss or sss%xNN indicates an option,
* if %xNN is given then NN is the return value if
* that option is selected otherwise the return value
* is the index of the option (starting with 1). %l
- * indicates a seperator, sss%l indicates a label and
- * new column.
+ * indicates a seperator.
*
* @param str String to be parsed.
* @retval new menudata structure, free with menudata_free()
@@ -161,7 +157,7 @@ MenuData *decompose_menu_string(char *str)
char *instr= BLI_strdup(str);
MenuData *md= menudata_new(instr);
char *nitem= NULL, *s= instr;
- int nicon=0, nretval= 1, nitem_is_title= 0, nitem_is_sepr= 0;
+ int nicon=0, nretval= 1, nitem_is_title= 0;
while (1) {
char c= *s;
@@ -178,10 +174,7 @@ MenuData *decompose_menu_string(char *str)
*s= '\0';
s++;
} else if (s[1]=='l') {
- nitem_is_sepr= 1;
- if(!nitem) nitem= "";
-
- *s= '\0';
+ nitem= "%l";
s++;
} else if (s[1]=='i') {
nicon= atoi(s+2);
@@ -193,18 +186,15 @@ MenuData *decompose_menu_string(char *str)
if (nitem) {
*s= '\0';
- if(nitem_is_title) {
+ if (nitem_is_title) {
menudata_set_title(md, nitem, nicon);
nitem_is_title= 0;
- }
- else if(nitem_is_sepr) {
+ } else {
/* prevent separator to get a value */
- menudata_add_item(md, nitem, -1, nicon, 1);
- nretval= md->nitems+1;
- nitem_is_sepr= 0;
- }
- else {
- menudata_add_item(md, nitem, nretval, nicon, 0);
+ if(nitem[0]=='%' && nitem[1]=='l')
+ menudata_add_item(md, nitem, -1, nicon);
+ else
+ menudata_add_item(md, nitem, nretval, nicon);
nretval= md->nitems+1;
}
@@ -837,8 +827,6 @@ static void ui_searchbox_region_free(ARegion *ar)
ar->regiondata= NULL;
}
-static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, uiBlock *block);
-
ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
{
uiStyle *style= U.uistyles.first; // XXX pass on as arg
@@ -859,7 +847,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* create searchbox data */
data= MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData");
-
+
/* set font, get bb */
data->fstyle= style->widget; /* copy struct */
data->fstyle.align= UI_STYLE_TEXT_CENTER;
@@ -941,14 +929,10 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
}
}
if(y1 < 0) {
- int newy1;
- UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, 0, &newy1);
- newy1 += butregion->winrct.ymin;
-
- y2= y2-y1 + newy1;
- y1= newy1;
+ y1 += 36;
+ y2 += 36;
}
-
+
/* widget rect, in region coords */
data->bbox.xmin= MENU_SHADOW_SIDE;
data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE;
@@ -1326,21 +1310,24 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
/***************************** Menu Button ***************************/
-static void ui_block_func_MENUSTR(bContext *C, uiLayout *layout, void *arg_str)
+uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_but)
{
- uiBlock *block= uiLayoutGetBlock(layout);
- uiPopupBlockHandle *handle= block->handle;
- uiLayout *split, *column=NULL;
+ uiBut *but= arg_but;
+ uiBlock *block;
uiBut *bt;
MenuData *md;
- MenuEntry *entry;
- char *instr= arg_str;
- int columns, rows, a, b;
+ ListBase lb;
+ float aspect;
+ int width, height, boxh, columns, rows, startx, starty, x1, y1, xmax, a;
+
+ /* create the block */
+ block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP);
+ block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
/* compute menu data */
- md= decompose_menu_string(instr);
+ md= decompose_menu_string(but->str);
- /* columns and row estimation */
+ /* columns and row calculation */
columns= (md->nitems+20)/20;
if(columns<1)
columns= 1;
@@ -1352,114 +1339,180 @@ static void ui_block_func_MENUSTR(bContext *C, uiLayout *layout, void *arg_str)
rows= 1;
while(rows*columns<md->nitems)
rows++;
+
+ /* prevent scaling up of pupmenu */
+ aspect= but->block->aspect;
+ if(aspect < 1.0f)
+ aspect = 1.0f;
+
+ /* size and location */
+ if(md->title)
+ width= 1.5*aspect*strlen(md->title)+UI_GetStringWidth(md->title);
+ else
+ width= 0;
- /* create title */
- if(md->title) {
- if(md->titleicon) {
- uiItemL(layout, md->title, md->titleicon);
- }
- else {
- uiItemL(layout, md->title, 0);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
- }
+ for(a=0; a<md->nitems; a++) {
+ xmax= aspect*UI_GetStringWidth(md->items[a].str);
+ if(md->items[a].icon)
+ xmax += 20*aspect;
+ if(xmax>width)
+ width= xmax;
}
- /* inconsistent, but menus with labels do not look good flipped */
- for(a=0, b=0; a<md->nitems; a++, b++) {
- entry= &md->items[a];
+ width+= 10;
+ if(width < (but->x2 - but->x1))
+ width = (but->x2 - but->x1);
+ if(width<50)
+ width=50;
+
+ boxh= MENU_BUTTON_HEIGHT;
+
+ height= rows*boxh;
+ if(md->title)
+ height+= boxh;
- if(entry->sepr && entry->str[0])
- block->flag |= UI_BLOCK_NO_FLIP;
- }
+ /* here we go! */
+ startx= but->x1;
+ starty= but->y1;
+
+ if(md->title) {
+ uiBut *bt;
- /* create items */
- split= uiLayoutSplit(layout, 0);
+ if (md->titleicon) {
+ bt= uiDefIconTextBut(block, LABEL, 0, md->titleicon, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, "");
+ } else {
+ bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*boxh), (short)width, (short)boxh, NULL, 0.0, 0.0, 0, 0, "");
+ bt->flag= UI_TEXT_LEFT;
+ }
+ }
- for(a=0, b=0; a<md->nitems; a++, b++) {
- if(block->flag & UI_BLOCK_NO_FLIP)
- entry= &md->items[a];
- else
- entry= &md->items[md->nitems-a-1];
+ for(a=0; a<md->nitems; a++) {
- /* new column on N rows or on separation label */
- if((b % rows == 0) || (entry->sepr && entry->str[0])) {
- column= uiLayoutColumn(split, 0);
- b= 0;
- }
+ x1= startx + width*((int)(md->nitems-a-1)/rows);
+ y1= starty - boxh*(rows - ((md->nitems - a - 1)%rows)) + (rows*boxh);
- if(entry->sepr) {
- uiItemL(column, entry->str, entry->icon);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
+ if (strcmp(md->items[md->nitems-a-1].str, "%l")==0) {
+ bt= uiDefBut(block, SEPR, B_NOP, "", x1, y1,(short)(width-(rows>1)), (short)(boxh-1), NULL, 0.0, 0.0, 0, 0, "");
}
- else if(entry->icon) {
- uiDefIconTextButF(block, BUTM|FLO, B_NOP, entry->icon, entry->str, 0, 0,
- UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
+ else if(md->items[md->nitems-a-1].icon) {
+ bt= uiDefIconTextButF(block, BUTM|FLO, B_NOP, md->items[md->nitems-a-1].icon ,md->items[md->nitems-a-1].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), &handle->retvalue, (float) md->items[md->nitems-a-1].retval, 0.0, 0, 0, "");
}
else {
- uiDefButF(block, BUTM|FLO, B_NOP, entry->str, 0, 0,
- UI_UNIT_X*5, UI_UNIT_X, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
+ bt= uiDefButF(block, BUTM|FLO, B_NOP, md->items[md->nitems-a-1].str, x1, y1,(short)(width-(rows>1)), (short)(boxh-1), &handle->retvalue, (float) md->items[md->nitems-a-1].retval, 0.0, 0, 0, "");
}
}
menudata_free(md);
+
+ /* the code up here has flipped locations, because of change of preferred order */
+ /* thats why we have to switch list order too, to make arrowkeys work */
+
+ lb.first= lb.last= NULL;
+ bt= block->buttons.first;
+ while(bt) {
+ uiBut *next= bt->next;
+ BLI_remlink(&block->buttons, bt);
+ BLI_addhead(&lb, bt);
+ bt= next;
+ }
+ block->buttons= lb;
+
+ block->direction= UI_TOP;
+ uiEndBlock(C, block);
+
+ return block;
}
-void ui_block_func_ICONROW(bContext *C, uiLayout *layout, void *arg_but)
+uiBlock *ui_block_func_ICONROW(bContext *C, uiPopupBlockHandle *handle, void *arg_but)
{
- uiBlock *block= uiLayoutGetBlock(layout);
- uiPopupBlockHandle *handle= block->handle;
uiBut *but= arg_but;
+ uiBlock *block;
int a;
- for(a=(int)but->hardmin; a<=(int)but->hardmax; a++)
- uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, 0, UI_UNIT_X*5, UI_UNIT_Y,
- &handle->retvalue, (float)a, 0.0, 0, 0, "");
+ block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP);
+ block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
+
+ for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) {
+ uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, (short)(18*a), (short)(but->x2-but->x1-4), 18, &handle->retvalue, (float)a, 0.0, 0, 0, "");
+ }
+
+ block->direction= UI_TOP;
+
+ uiEndBlock(C, block);
+
+ return block;
}
-void ui_block_func_ICONTEXTROW(bContext *C, uiLayout *layout, void *arg_but)
+uiBlock *ui_block_func_ICONTEXTROW(bContext *C, uiPopupBlockHandle *handle, void *arg_but)
{
- uiBlock *block= uiLayoutGetBlock(layout);
- uiPopupBlockHandle *handle= block->handle;
- uiBut *but= arg_but, *bt;
+ uiBut *but= arg_but;
+ uiBlock *block;
MenuData *md;
- MenuEntry *entry;
- int a;
+ int width, xmax, ypos, a;
+
+ block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP);
+ block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT;
md= decompose_menu_string(but->str);
- /* title */
- if(md->title) {
- bt= uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X*5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- bt->flag= UI_TEXT_LEFT;
+ /* size and location */
+ /* expand menu width to fit labels */
+ if(md->title)
+ width= 2*strlen(md->title)+UI_GetStringWidth(md->title);
+ else
+ width= 0;
+
+ for(a=0; a<md->nitems; a++) {
+ xmax= UI_GetStringWidth(md->items[a].str);
+ if(xmax>width) width= xmax;
}
+ width+= 30;
+ if (width<50) width=50;
+
+ ypos = 1;
+
/* loop through the menu options and draw them out with icons & text labels */
for(a=0; a<md->nitems; a++) {
- entry= &md->items[md->nitems-a-1];
- if(entry->sepr)
- uiItemS(layout);
- else
- uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(entry->retval-but->hardmin)), entry->str,
- 0, 0, UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
+ /* add a space if there's a separator (%l) */
+ if (strcmp(md->items[a].str, "%l")==0) {
+ ypos +=3;
+ }
+ else {
+ uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(md->items[a].retval-but->hardmin)), md->items[a].str, 0, ypos,(short)width, 19, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, "");
+ ypos += 20;
+ }
}
+
+ if(md->title) {
+ uiBut *bt;
+ bt= uiDefBut(block, LABEL, 0, md->title, 0, ypos, (short)width, 19, NULL, 0.0, 0.0, 0, 0, "");
+ bt->flag= UI_TEXT_LEFT;
+ }
+
menudata_free(md);
+
+ block->direction= UI_TOP;
+
+ uiBoundsBlock(block, 3);
+ uiEndBlock(C, block);
+
+ return block;
}
-#if 0
static void ui_warp_pointer(short x, short y)
{
/* XXX 2.50 which function to use for this? */
+#if 0
/* OSX has very poor mousewarp support, it sends events;
this causes a menu being pressed immediately ... */
#ifndef __APPLE__
warp_pointer(x, y);
#endif
-}
#endif
+}
/********************* Color Button ****************/
@@ -2105,115 +2158,406 @@ void uiBlockColorbandButtons(uiBlock *block, ColorBand *coba, rctf *butr, int ev
}
-/************************ Popup Menu Memory ****************************/
+/* ******************** PUPmenu ****************** */
+
+static int pupmenu_set= 0;
-static int ui_popup_menu_hash(char *str)
+void uiPupMenuSetActive(int val)
{
- return BLI_ghashutil_strhash(str);
+ pupmenu_set= val;
}
-/* but == NULL read, otherwise set */
-uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but)
+/* value== -1 read, otherwise set */
+static int pupmenu_memory(char *str, int value)
{
static char mem[256], first=1;
- int hash= block->puphash;
+ int val=0, nr=0;
if(first) {
- /* init */
- memset(mem, -1, sizeof(mem));
+ memset(mem, 0, 256);
first= 0;
}
-
- if(but) {
- /* set */
- mem[hash & 255 ]= BLI_findindex(&block->buttons, but);
- return NULL;
- }
- else {
- /* get */
- return BLI_findlink(&block->buttons, mem[hash & 255]);
+ while(str[nr]) {
+ val+= str[nr];
+ nr++;
}
+
+ if(value >= 0) mem[ val & 255 ]= value;
+ else return mem[ val & 255 ];
+
+ return 0;
}
-/******************** Popup Menu with callback or string **********************/
+#define PUP_LABELH 6
-struct uiPopupMenu {
+typedef struct uiPupMenuInfo {
+ char *instr;
+ int mx, my;
+ int startx, starty;
+ int maxrow;
+} uiPupMenuInfo;
+
+uiBlock *ui_block_func_PUPMENU(bContext *C, uiPopupBlockHandle *handle, void *arg_info)
+{
uiBlock *block;
- uiLayout *layout;
- uiBut *but;
+ uiPupMenuInfo *info;
+ int columns, rows, mousemove[2]= {0, 0}, mousewarp= 0;
+ int width, height, xmax, ymax, maxrow;
+ int a, startx, starty, endx, endy, x1, y1;
+ int lastselected;
+ MenuData *md;
- int mx, my, popup, slideout;
- int startx, starty, maxrow;
+ info= arg_info;
+ maxrow= info->maxrow;
+ height= 0;
- uiMenuCreateFunc menu_func;
- void *menu_arg;
-};
+ /* block stuff first, need to know the font */
+ block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT);
+ block->direction= UI_DOWN;
+
+ md= decompose_menu_string(info->instr);
-static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, void *arg_pup)
-{
- uiBlock *block;
- uiBut *bt;
- ScrArea *sa;
- ARegion *ar;
- uiPopupMenu *pup= arg_pup;
- int offset, direction, minwidth, flip;
+ rows= md->nitems;
+ if(rows<1)
+ rows= 1;
+
+ columns= 1;
+
+ /* size and location, title slightly bigger for bold */
+ if(md->title) {
+ width= 2*strlen(md->title)+UI_GetStringWidth(md->title);
+ width /= columns;
+ }
+ else width= 0;
+
+ for(a=0; a<md->nitems; a++) {
+ xmax= UI_GetStringWidth(md->items[a].str);
+ if(xmax>width) width= xmax;
+
+ if(strcmp(md->items[a].str, "%l")==0) height+= PUP_LABELH;
+ else height+= MENU_BUTTON_HEIGHT;
+ }
+
+ width+= 10;
+ if (width<50) width=50;
+
+ wm_window_get_size(CTX_wm_window(C), &xmax, &ymax);
+
+ /* set first item */
+ lastselected= 0;
+ if(pupmenu_set) {
+ lastselected= pupmenu_set-1;
+ pupmenu_set= 0;
+ }
+ else if(md->nitems>1) {
+ lastselected= pupmenu_memory(info->instr, -1);
+ }
+
+ startx= info->mx-(0.8*(width));
+ starty= info->my-height+MENU_BUTTON_HEIGHT/2;
+ if(lastselected>=0 && lastselected<md->nitems) {
+ for(a=0; a<md->nitems; a++) {
+ if(a==lastselected) break;
+ if( strcmp(md->items[a].str, "%l")==0) starty+= PUP_LABELH;
+ else starty+=MENU_BUTTON_HEIGHT;
+ }
+
+ //starty= info->my-height+MENU_BUTTON_HEIGHT/2+lastselected*MENU_BUTTON_HEIGHT;
+ }
+
+ if(startx<10) {
+ startx= 10;
+ }
+ if(starty<10) {
+ mousemove[1]= 10-starty;
+ starty= 10;
+ }
+
+ endx= startx+width*columns;
+ endy= starty+height;
+
+ if(endx>xmax) {
+ endx= xmax-10;
+ startx= endx-width*columns;
+ }
+ if(endy>ymax-20) {
+ mousemove[1]= ymax-endy-20;
+ endy= ymax-20;
+ starty= endy-height;
+ }
- if(pup->menu_func) {
- pup->block->handle= handle;
- pup->menu_func(C, pup->layout, pup->menu_arg);
- pup->block->handle= NULL;
+ if(mousemove[0] || mousemove[1]) {
+ ui_warp_pointer(info->mx+mousemove[0], info->my+mousemove[1]);
+ mousemove[0]= info->mx;
+ mousemove[1]= info->my;
+ mousewarp= 1;
}
- if(pup->but) {
- /* minimum width to enforece */
- minwidth= pup->but->x2 - pup->but->x1;
+ /* here we go! */
+ if(md->title) {
+ uiBut *bt;
+ char titlestr[256];
- if(pup->but->type == PULLDOWN || pup->but->menu_create_func) {
- direction= UI_DOWN;
- flip= 1;
+ if(md->titleicon) {
+ width+= 20;
+ sprintf(titlestr, " %s", md->title);
+ uiDefIconTextBut(block, LABEL, 0, md->titleicon, titlestr, startx, (short)(starty+height), width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
}
else {
- direction= UI_TOP;
- flip= 0;
+ bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+height), columns*width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
+ bt->flag= UI_TEXT_LEFT;
}
+
+ //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
}
- else {
- minwidth= 50;
- direction= UI_DOWN;
- flip= 1;
+
+ x1= startx + width*((int)a/rows);
+ y1= starty + height - MENU_BUTTON_HEIGHT; // - MENU_SEPR_HEIGHT;
+
+ for(a=0; a<md->nitems; a++) {
+ char *name= md->items[a].str;
+ int icon = md->items[a].icon;
+
+ if(strcmp(name, "%l")==0) {
+ uiDefBut(block, SEPR, B_NOP, "", x1, y1, width, PUP_LABELH, NULL, 0, 0.0, 0, 0, "");
+ y1 -= PUP_LABELH;
+ }
+ else if (icon) {
+ uiDefIconButF(block, BUTM, B_NOP, icon, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, "");
+ y1 -= MENU_BUTTON_HEIGHT;
+ }
+ else {
+ uiDefButF(block, BUTM, B_NOP, name, x1, y1, width, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, "");
+ y1 -= MENU_BUTTON_HEIGHT;
+ }
}
+
+ uiBoundsBlock(block, 1);
+ uiEndBlock(C, block);
- block= pup->block;
+ menudata_free(md);
+
+ /* XXX 2.5 need to store last selected */
+#if 0
+ /* calculate last selected */
+ if(event & ui_return_ok) {
+ lastselected= 0;
+ for(a=0; a<md->nitems; a++) {
+ if(val==md->items[a].retval) lastselected= a;
+ }
+
+ pupmenu_memory(info->instr, lastselected);
+ }
+#endif
- /* in some cases we create the block before the region,
- so we set it delayed here if necessary */
- if(BLI_findindex(&handle->region->uiblocks, block) == -1)
- uiBlockSetRegion(block, handle->region);
+ /* XXX 2.5 need to warp back */
+#if 0
+ if(mousemove[1] && (event & ui_return_out)==0)
+ ui_warp_pointer(mousemove[0], mousemove[1]);
+ return val;
+#endif
- block->direction= direction;
+ return block;
+}
- uiBlockLayoutResolve(C, block, NULL, NULL);
+uiBlock *ui_block_func_PUPMENUCOL(bContext *C, uiPopupBlockHandle *handle, void *arg_info)
+{
+ uiBlock *block;
+ uiPupMenuInfo *info;
+ int columns, rows, mousemove[2]= {0, 0}, mousewarp;
+ int width, height, xmax, ymax, maxrow;
+ int a, startx, starty, endx, endy, x1, y1;
+ float fvalue;
+ MenuData *md;
- if(pup->popup) {
- uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1);
- uiBlockSetDirection(block, direction);
+ info= arg_info;
+ maxrow= info->maxrow;
+ height= 0;
- /* offset the mouse position, possibly based on earlier selection */
- offset= 1.5*MENU_BUTTON_HEIGHT;
+ /* block stuff first, need to know the font */
+ block= uiBeginBlock(C, handle->region, "menu", UI_EMBOSSP);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_NUMSELECT);
+ block->direction= UI_DOWN;
+
+ md= decompose_menu_string(info->instr);
- if(block->flag & UI_BLOCK_POPUP_MEMORY) {
- bt= ui_popup_menu_memory(block, NULL);
+ /* columns and row calculation */
+ columns= (md->nitems+maxrow)/maxrow;
+ if (columns<1) columns= 1;
+
+ if(columns > 8) {
+ maxrow += 5;
+ columns= (md->nitems+maxrow)/maxrow;
+ }
+
+ rows= (int) md->nitems/columns;
+ if (rows<1) rows= 1;
+
+ while (rows*columns<(md->nitems+columns) ) rows++;
- if(bt)
- offset= -bt->y1 - 0.5f*MENU_BUTTON_HEIGHT;
+ /* size and location, title slightly bigger for bold */
+ if(md->title) {
+ width= 2*strlen(md->title)+UI_GetStringWidth(md->title);
+ width /= columns;
+ }
+ else width= 0;
+
+ for(a=0; a<md->nitems; a++) {
+ xmax= UI_GetStringWidth(md->items[a].str);
+ if(xmax>width) width= xmax;
+ }
+
+ width+= 10;
+ if (width<50) width=50;
+
+ height= rows*MENU_BUTTON_HEIGHT;
+ if (md->title) height+= MENU_BUTTON_HEIGHT;
+
+ wm_window_get_size(CTX_wm_window(C), &xmax, &ymax);
+
+ /* find active item */
+ fvalue= handle->retvalue;
+ for(a=0; a<md->nitems; a++) {
+ if( md->items[a].retval== (int)fvalue ) break;
+ }
+
+ /* no active item? */
+ if(a==md->nitems) {
+ if(md->title) a= -1;
+ else a= 0;
+ }
+
+ if(a>0)
+ startx = info->mx-width/2 - ((int)(a)/rows)*width;
+ else
+ startx= info->mx-width/2;
+ starty = info->my-height + MENU_BUTTON_HEIGHT/2 + ((a)%rows)*MENU_BUTTON_HEIGHT;
+
+ if (md->title) starty+= MENU_BUTTON_HEIGHT;
+
+ if(startx<10) {
+ mousemove[0]= 10-startx;
+ startx= 10;
+ }
+ if(starty<10) {
+ mousemove[1]= 10-starty;
+ starty= 10;
+ }
+
+ endx= startx+width*columns;
+ endy= starty+height;
+
+ if(endx>xmax) {
+ mousemove[0]= xmax-endx-10;
+ endx= xmax-10;
+ startx= endx-width*columns;
+ }
+ if(endy>ymax) {
+ mousemove[1]= ymax-endy-10;
+ endy= ymax-10;
+ starty= endy-height;
+ }
+
+ if(mousemove[0] || mousemove[1]) {
+ ui_warp_pointer(info->mx+mousemove[0], info->my+mousemove[1]);
+ mousemove[0]= info->mx;
+ mousemove[1]= info->my;
+ mousewarp= 1;
+ }
+
+ /* here we go! */
+ if(md->title) {
+ uiBut *bt;
+
+ if(md->titleicon) {
}
+ else {
+ bt= uiDefBut(block, LABEL, 0, md->title, startx, (short)(starty+rows*MENU_BUTTON_HEIGHT), columns*width, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
+ bt->flag= UI_TEXT_LEFT;
+ }
+ }
+
+ for(a=0; a<md->nitems; a++) {
+ char *name= md->items[a].str;
+ int icon = md->items[a].icon;
- block->minbounds= minwidth;
- uiMenuPopupBoundsBlock(block, 1, 20, offset);
+ x1= startx + width*((int)a/rows);
+ y1= starty - MENU_BUTTON_HEIGHT*(a%rows) + (rows-1)*MENU_BUTTON_HEIGHT;
+
+ if(strcmp(name, "%l")==0) {
+ uiDefBut(block, SEPR, B_NOP, "", x1, y1, width, PUP_LABELH, NULL, 0, 0.0, 0, 0, "");
+ y1 -= PUP_LABELH;
+ }
+ else if (icon) {
+ uiDefIconButF(block, BUTM, B_NOP, icon, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, "");
+ y1 -= MENU_BUTTON_HEIGHT;
+ }
+ else {
+ uiDefButF(block, BUTM, B_NOP, name, x1, y1, width, MENU_BUTTON_HEIGHT-1, &handle->retvalue, (float) md->items[a].retval, 0.0, 0, 0, "");
+ y1 -= MENU_BUTTON_HEIGHT;
+ }
+ }
+
+ uiBoundsBlock(block, 1);
+ uiEndBlock(C, block);
+
+ menudata_free(md);
+
+ /* XXX 2.5 need to warp back */
+#if 0
+ if((event & UI_RETURN_OUT)==0)
+ ui_warp_pointer(mousemove[0], mousemove[1]);
+#endif
+
+ return block;
+}
+
+/************************** Menu Definitions ***************************/
+
+/* prototype */
+static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info);
+
+struct uiPopupMenu {
+ uiBlock *block;
+ uiLayout *layout;
+};
+
+typedef struct uiMenuInfo {
+ uiPopupMenu *pup;
+ int mx, my, popup, slideout;
+ int startx, starty;
+} uiMenuInfo;
+
+/************************ Menu Definitions to uiBlocks ***********************/
+
+static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, void *arg_info)
+{
+ uiBlock *block;
+ uiMenuInfo *info= arg_info;
+ uiPopupMenu *pup;
+ ScrArea *sa;
+ ARegion *ar;
+
+ pup= info->pup;
+ block= pup->block;
+
+ /* block stuff first, need to know the font */
+ uiBlockSetRegion(block, handle->region);
+ block->direction= UI_DOWN;
+
+ uiBlockLayoutResolve(C, block, NULL, NULL);
+
+ if(info->popup) {
+ uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1);
+ uiBlockSetDirection(block, UI_DOWN);
+
+ /* here we set an offset for the mouse position */
+ uiMenuPopupBoundsBlock(block, 1, 0, 1.5*MENU_BUTTON_HEIGHT);
}
else {
/* for a header menu we set the direction automatic */
- if(!pup->slideout && flip) {
+ if(!info->slideout) {
sa= CTX_wm_area(C);
ar= CTX_wm_region(C);
@@ -2225,77 +2569,59 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
}
}
- block->minbounds= minwidth;
- uiTextBoundsBlock(block, 40);
+ uiTextBoundsBlock(block, 50);
}
/* if menu slides out of other menu, override direction */
- if(pup->slideout)
+ if(info->slideout)
uiBlockSetDirection(block, UI_RIGHT);
uiEndBlock(C, block);
-
- return pup->block;
+
+ return block;
}
-uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg, char *str)
+uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg)
{
- wmWindow *window= CTX_wm_window(C);
uiStyle *style= U.uistyles.first;
uiPopupBlockHandle *handle;
uiPopupMenu *pup;
+ uiMenuInfo info;
pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy");
- pup->block= uiBeginBlock(C, NULL, "ui_button_menu_create", UI_EMBOSSP);
+ pup->block= uiBeginBlock(C, NULL, "ui_popup_menu_create", UI_EMBOSSP);
pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
- pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP));
- pup->but= but;
uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN);
- if(!but) {
- /* no button to start from, means we are a popup */
- pup->mx= window->eventstate->x;
- pup->my= window->eventstate->y;
- pup->popup= 1;
- }
+ /* create in advance so we can let buttons point to retval already */
+ pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
- if(str) {
- /* menu is created from a string */
- pup->menu_func= ui_block_func_MENUSTR;
- pup->menu_arg= str;
- }
- else {
- /* menu is created from a callback */
- pup->menu_func= menu_func;
- pup->menu_arg= arg;
- }
+ menu_func(C, pup->layout, arg);
- handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup);
-
- if(!but) {
- handle->popup= 1;
-
- UI_add_popup_handlers(C, &window->handlers, handle);
- WM_event_add_mousemove(C);
- }
+ memset(&info, 0, sizeof(info));
+ info.pup= pup;
+ info.slideout= (but && (but->block->flag & UI_BLOCK_LOOP));
+
+ handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_MENU_ITEM, &info);
MEM_freeN(pup);
return handle;
}
-/******************** Popup Menu API with begin and end ***********************/
+/*************************** Menu Creating API **************************/
+
+
+/*************************** Popup Menu API **************************/
/* only return handler, and set optional title */
uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
{
uiStyle *style= U.uistyles.first;
- uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu");
+ uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "menu start");
uiBut *but;
pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP);
- pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
- pup->block->puphash= ui_popup_menu_hash((char*)title);
pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);
@@ -2314,6 +2640,8 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
but= uiDefBut(pup->block, LABEL, 0, (char*)title, 0, 0, 200, MENU_BUTTON_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
but->flag= UI_TEXT_LEFT;
}
+
+ //uiDefBut(block, SEPR, 0, "", startx, (short)(starty+height)-MENU_SEPR_HEIGHT, width, MENU_SEPR_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
}
return pup;
@@ -2323,13 +2651,16 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
void uiPupMenuEnd(bContext *C, uiPopupMenu *pup)
{
wmWindow *window= CTX_wm_window(C);
+ uiMenuInfo info;
uiPopupBlockHandle *menu;
- pup->popup= 1;
- pup->mx= window->eventstate->x;
- pup->my= window->eventstate->y;
+ memset(&info, 0, sizeof(info));
+ info.popup= 1;
+ info.mx= window->eventstate->x;
+ info.my= window->eventstate->y;
+ info.pup= pup;
- menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup);
+ menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_MENU_ITEM, &info);
menu->popup= 1;
UI_add_popup_handlers(C, &window->handlers, menu);
@@ -2343,7 +2674,32 @@ uiLayout *uiPupMenuLayout(uiPopupMenu *pup)
return pup->layout;
}
-/*************************** Standard Popup Menus ****************************/
+/* ************** standard pupmenus *************** */
+
+/* this one can called with operatortype name and operators */
+static uiPopupBlockHandle *ui_pup_menu(bContext *C, int maxrow, uiMenuHandleFunc func, void *arg, char *str, ...)
+{
+ wmWindow *window= CTX_wm_window(C);
+ uiPupMenuInfo info;
+ uiPopupBlockHandle *menu;
+
+ memset(&info, 0, sizeof(info));
+ info.mx= window->eventstate->x;
+ info.my= window->eventstate->y;
+ info.maxrow= maxrow;
+ info.instr= str;
+
+ menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PUPMENU, &info);
+ menu->popup= 1;
+
+ UI_add_popup_handlers(C, &window->handlers, menu);
+ WM_event_add_mousemove(C);
+
+ menu->popup_func= func;
+ menu->popup_arg= arg;
+
+ return menu;
+}
static void operator_name_cb(bContext *C, void *arg, int retval)
{
@@ -2353,6 +2709,17 @@ static void operator_name_cb(bContext *C, void *arg, int retval)
WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL);
}
+static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap)
+{
+ char *s, buf[512];
+
+ s= buf;
+ if (title) s+= sprintf(s, "%s%%t|", title);
+ vsprintf(s, itemfmt, ap);
+
+ ui_pup_menu(C, 0, operator_name_cb, opname, buf);
+}
+
static void operator_cb(bContext *C, void *arg, int retval)
{
wmOperator *op= arg;
@@ -2368,21 +2735,6 @@ static void confirm_cancel_operator(void *opv)
WM_operator_free(opv);
}
-static void vconfirm_opname(bContext *C, char *opname, char *title, char *itemfmt, va_list ap)
-{
- uiPopupBlockHandle *handle;
- char *s, buf[512];
-
- s= buf;
- if (title) s+= sprintf(s, "%s%%t|", title);
- vsprintf(s, itemfmt, ap);
-
- handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
-
- handle->popup_func= operator_name_cb;
- handle->popup_arg= opname;
-}
-
static void confirm_operator(bContext *C, wmOperator *op, char *title, char *item)
{
uiPopupBlockHandle *handle;
@@ -2391,13 +2743,11 @@ static void confirm_operator(bContext *C, wmOperator *op, char *title, char *ite
s= buf;
if (title) s+= sprintf(s, "%s%%t|%s", title, item);
- handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
-
- handle->popup_func= operator_cb;
- handle->popup_arg= op;
+ handle= ui_pup_menu(C, 0, operator_cb, op, buf);
handle->cancel_func= confirm_cancel_operator;
}
+
void uiPupMenuOkee(bContext *C, char *opname, char *str, ...)
{
va_list ap;
@@ -2410,6 +2760,7 @@ void uiPupMenuOkee(bContext *C, char *opname, char *str, ...)
va_end(ap);
}
+
void uiPupMenuSaveOver(bContext *C, wmOperator *op, char *filename)
{
size_t len= strlen(filename);
@@ -2425,7 +2776,7 @@ void uiPupMenuSaveOver(bContext *C, wmOperator *op, char *filename)
if(BLI_exists(filename)==0)
operator_cb(C, op, 1);
else
- confirm_operator(C, op, "Save Over", filename);
+ confirm_operator(C, op, "Save over", filename);
}
void uiPupMenuNotice(bContext *C, char *str, ...)
@@ -2475,7 +2826,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
}
str= BLI_dynstr_get_cstring(ds);
- ui_popup_menu_create(C, NULL, NULL, NULL, NULL, str);
+ ui_pup_menu(C, 0, NULL, NULL, str);
MEM_freeN(str);
BLI_dynstr_free(ds);
@@ -2519,4 +2870,3 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int
UI_add_popup_handlers(C, &window->handlers, handle);
WM_event_add_mousemove(C);
}
-
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 2b7d6f383bf..0557512cc2a 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -157,7 +157,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
{
TemplateID *template= (TemplateID*)arg_litem;
PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop);
- ID *id= idptr.data, *newid;
+ ID *id= idptr.data;
int event= GET_INT_FROM_POINTER(arg_event);
switch(event) {
@@ -185,48 +185,28 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
}
else return;
break;
- case UI_ID_LOCAL:
- if(id) {
- if(id_make_local(id, 0)) {
- /* reassign to get get proper updates/notifiers */
- idptr= RNA_property_pointer_get(&template->ptr, template->prop);
- RNA_property_pointer_set(&template->ptr, template->prop, idptr);
- RNA_property_update(C, &template->ptr, template->prop);
- }
- }
- break;
+#if 0
case UI_ID_ALONE:
- if(id) {
- /* make copy */
- if(id_copy(id, &newid, 0) && newid) {
- /* 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(!id || id->us < 1)
+ return;
+ break;
+ case UI_ID_LOCAL:
+ if(!id || id->us < 1)
+ return;
break;
-#if 0
case UI_ID_AUTO_NAME:
break;
#endif
}
}
-static void template_ID(bContext *C, uiBlock *block, TemplateID *template, StructRNA *type, int flag, char *newop, char *openop, char *unlinkop)
+static void template_ID(bContext *C, uiBlock *block, TemplateID *template, StructRNA *type, int flag, char *newop, char *unlinkop)
{
uiBut *but;
PointerRNA idptr;
ListBase *lb;
- ID *id, *idfrom;
idptr= RNA_property_pointer_get(&template->ptr, template->prop);
- id= idptr.data;
- idfrom= template->ptr.id.data;
lb= template->idlb;
uiBlockBeginAlign(block);
@@ -241,86 +221,33 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc
but->flag|= UI_HAS_ICON;
but->flag|= UI_ICON_LEFT;
}
-
- if((idfrom && idfrom->lib))
- uiButSetFlag(but, UI_BUT_DISABLED);
}
/* text button with name */
- if(id) {
+ if(idptr.data) {
char name[64];
- //text_idbutton(id, name);
+ //text_idbutton(idptr.data, name);
name[0]= '\0';
but= uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X*6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME));
-
- if(id->lib) {
- if(id->flag & LIB_INDIRECT) {
- but= uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0,0,UI_UNIT_X,UI_UNIT_Y, 0, 0, 0, 0, 0,
- "Indirect library datablock, cannot change.");
- uiButSetFlag(but, UI_BUT_DISABLED);
- }
- else {
- but= uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0,0,UI_UNIT_X,UI_UNIT_Y, 0, 0, 0, 0, 0,
- "Direct linked library datablock, click to make local.");
- if(!id_make_local(id, 1 /* test */) || (idfrom && idfrom->lib))
- uiButSetFlag(but, UI_BUT_DISABLED);
- }
-
- uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_LOCAL));
- }
-
- if(id->us > 1) {
- char str[32];
-
- sprintf(str, "%d", id->us);
-
- if(id->us<10)
- but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X,UI_UNIT_Y, 0, 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, 0, 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))
- uiButSetFlag(but, UI_BUT_DISABLED);
- }
}
if(flag & UI_ID_ADD_NEW) {
- int w= id?UI_UNIT_X: (flag & UI_ID_OPEN)? UI_UNIT_X*3: UI_UNIT_X*6;
+ int w= idptr.data?UI_UNIT_X:UI_UNIT_X*6;
if(newop) {
- but= uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, (id)? "": "New", 0, 0, w, UI_UNIT_Y, NULL);
+ but= uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_REGION_WIN, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
else {
- but= uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (id)? "": "New", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ but= uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
-
- if((idfrom && idfrom->lib))
- uiButSetFlag(but, UI_BUT_DISABLED);
- }
-
- if(flag & UI_ID_OPEN) {
- int w= id?UI_UNIT_X: (flag & UI_ID_ADD_NEW)? UI_UNIT_X*3: UI_UNIT_X*6;
-
- if(openop) {
- but= uiDefIconTextButO(block, BUT, openop, WM_OP_INVOKE_REGION_WIN, ICON_FILESEL, (id)? "": "Open", 0, 0, w, UI_UNIT_Y, NULL);
- uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN));
- }
- else {
- but= uiDefIconTextBut(block, BUT, 0, ICON_FILESEL, (id)? "": "Open", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
- uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN));
- }
-
- if((idfrom && idfrom->lib))
- uiButSetFlag(but, UI_BUT_DISABLED);
}
/* delete button */
- if(id && (flag & UI_ID_DELETE)) {
+ if(idptr.data && (flag & UI_ID_DELETE)) {
if(unlinkop) {
but= uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
}
@@ -328,15 +255,12 @@ static void template_ID(bContext *C, uiBlock *block, TemplateID *template, Struc
but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE));
}
-
- if((idfrom && idfrom->lib))
- uiButSetFlag(but, UI_BUT_DISABLED);
}
uiBlockEndAlign(block);
}
-void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *openop, char *unlinkop)
+void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *newop, char *unlinkop)
{
TemplateID *template;
uiBlock *block;
@@ -362,8 +286,6 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname
if(newop)
flag |= UI_ID_ADD_NEW;
- if(openop)
- flag |= UI_ID_OPEN;
type= RNA_property_pointer_type(ptr, prop);
template->idlb= wich_libbase(CTX_data_main(C), RNA_type_to_ID_code(type));
@@ -371,7 +293,7 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname
if(template->idlb) {
uiLayoutRow(layout, 1);
block= uiLayoutGetBlock(layout);
- template_ID(C, block, template, type, flag, newop, openop, unlinkop);
+ template_ID(C, block, template, type, flag, newop, unlinkop);
}
MEM_freeN(template);
@@ -406,6 +328,7 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname
static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
{
+ Scene *scene= CTX_data_scene(C);
Object *ob = ob_v;
ModifierData *md;
@@ -420,11 +343,12 @@ static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
}
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
}
static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
{
+ Scene *scene= CTX_data_scene(C);
Object *ob = ob_v;
ModifierData *md = md_v;
ModifierData *nmd = modifier_new(md->type);
@@ -437,7 +361,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
ob->partype = PAROBJECT;
WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
ED_undo_push(C, "Modifier convert to real");
}
@@ -504,15 +428,15 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
else {
/* real modifier */
uiBlockBeginAlign(block);
- uiItemR(row, "", 0, &ptr, "name", 0);
+ uiItemR(row, "", 0, &ptr, "name", 0, 0, 0);
/* Softbody not allowed in this situation, enforce! */
if(((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
- uiItemR(row, "", ICON_SCENE, &ptr, "render", 0);
- uiItemR(row, "", ICON_RESTRICT_VIEW_OFF, &ptr, "realtime", 0);
+ uiItemR(row, "", ICON_SCENE, &ptr, "render", 0, 0, 0);
+ uiItemR(row, "", ICON_RESTRICT_VIEW_OFF, &ptr, "realtime", 0, 0, 0);
if(mti->flags & eModifierTypeFlag_SupportsEditmode)
- uiItemR(row, "", ICON_EDITMODE_HLT, &ptr, "editmode", 0);
+ uiItemR(row, "", ICON_EDITMODE_HLT, &ptr, "editmode", 0, 0, 0);
}
@@ -673,8 +597,8 @@ void do_constraint_panels(bContext *C, void *arg, int event)
if(ob->pose) update_pose_constraint_flags(ob->pose);
- if(ob->type==OB_ARMATURE) DAG_id_flush_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB);
- else DAG_id_flush_update(&ob->id, OB_RECALC_OB);
+ if(ob->type==OB_ARMATURE) DAG_object_flush_update(scene, ob, OB_RECALC_DATA|OB_RECALC_OB);
+ else DAG_object_flush_update(scene, ob, OB_RECALC_OB);
// XXX allqueue(REDRAWVIEW3D, 0);
// XXX allqueue(REDRAWBUTSOBJECT, 0);
@@ -1300,9 +1224,9 @@ void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname)
/* nselected, selected, active color swatches */
csPtr= RNA_property_pointer_get(ptr, prop);
- uiItemR(row, "", 0, &csPtr, "normal", 0);
- uiItemR(row, "", 0, &csPtr, "selected", 0);
- uiItemR(row, "", 0, &csPtr, "active", 0);
+ uiItemR(row, "", 0, &csPtr, "normal", 0, 0, 0);
+ uiItemR(row, "", 0, &csPtr, "selected", 0, 0, 0);
+ uiItemR(row, "", 0, &csPtr, "active", 0, 0, 0);
}
/********************* Layer Buttons Template ************************/
@@ -1334,7 +1258,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname)
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
* - for now, only split into groups if if group will have at least 5 items
*/
- layers= RNA_property_array_length(ptr, prop);
+ layers= RNA_property_array_length(prop);
cols= (layers / 2) + (layers % 2);
groups= ((cols / 2) < 5) ? (1) : (cols / 2);
@@ -1354,7 +1278,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname)
/* add layers as toggle buts */
for (col= 0; (col < cols) && (layer < layers); col++, layer++) {
int icon=0; // XXX - add some way of setting this...
- uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, UI_ITEM_R_TOGGLE);
+ uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, 0, 0, 1);
}
}
}
@@ -1394,7 +1318,7 @@ ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *pr
Panel *pa;
ListBase lb, *itemlb;
char *name, str[32];
- int icon=0, i= 0, activei= 0, len= 0, items, found, min, max;
+ int icon=0, i= 0, activei= 0, len, items, found, min, max;
lb.first= lb.last= NULL;
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 5b44f6544d1..4201850f5e4 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -72,7 +72,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
{
uiBut *but=NULL;
const char *propname= RNA_property_identifier(prop);
- int arraylen= RNA_property_array_length(ptr, prop);
+ int arraylen= RNA_property_array_length(prop);
switch(RNA_property_type(prop)) {
case PROP_BOOLEAN: {
@@ -81,7 +81,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
if(arraylen && index == -1)
return NULL;
- length= RNA_property_array_length(ptr, prop);
+ length= RNA_property_array_length(prop);
if(length)
value= RNA_property_boolean_get_index(ptr, prop, index);
@@ -175,7 +175,7 @@ void uiDefAutoButsRNA(const bContext *C, uiLayout *layout, PointerRNA *ptr, int
if(strcmp(name, "Axis")==0) {
uiDefButR(uiLayoutGetBlock(col), BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL);
}
- else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0);
+ else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0, 0, 0);
}
RNA_STRUCT_END;
}
@@ -444,20 +444,6 @@ int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code,
uiBlockClearButLock(block);
}
- /* add button */
- if(events & UI_ID_ADD_NEW) {
- uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't unlink pinned data");
- if(parid && parid->lib);
- else {
- dup_params= MEM_dupallocN(params);
- but= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, x,y,DEF_ICON_BUT_WIDTH,DEF_BUT_HEIGHT, &dup_params->browsenr, params->browsenr, 32767.0, 0, 0, "Add new data block");
- uiButSetNFunc(but, idpoin_cb, MEM_dupallocN(params), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
- x+= DEF_ICON_BUT_WIDTH;
- }
-
- uiBlockClearButLock(block);
- }
-
/* delete button */
if(events & UI_ID_DELETE) {
uiBlockSetButLock(block, (events & UI_ID_PIN) && *pin_p, "Can't unlink pinned data");
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index f0085f71373..a70fbab1aa4 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -835,11 +835,9 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
// else transopts= ui_translate_buttons();
/* cut string in 2 parts - only for menu entries */
- if((but->block->flag & UI_BLOCK_LOOP)) {
- if(ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) {
- cpoin= strchr(but->drawstr, '|');
- if(cpoin) *cpoin= 0;
- }
+ if(ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) {
+ cpoin= strchr(but->drawstr, '|');
+ if(cpoin) *cpoin= 0;
}
glColor3ubv((unsigned char*)wcol->text);
@@ -1085,7 +1083,7 @@ static struct uiWidgetColors wcol_tool= {
{255, 255, 255, 255},
1,
- 15, -15
+ 25, -25
};
static struct uiWidgetColors wcol_box= {
@@ -1897,7 +1895,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
widget_init(&wtb);
/* half rounded */
- round_box_edges(&wtb, roundboxalign, rect, 5.0f);
+ round_box_edges(&wtb, roundboxalign, rect, 4.0f);
ui_get_but_vectorf(but, col);
wcol->inner[0]= FTOCHAR(col[0]);
@@ -1916,7 +1914,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
widget_init(&wtb);
/* half rounded */
- round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+ round_box_edges(&wtb, roundboxalign, rect, 5.0f);
widgetbase_draw(&wtb, wcol);
@@ -1946,11 +1944,11 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
{
if(state & UI_ACTIVE) {
uiWidgetBase wtb;
- float rad= 0.5f*(rect->ymax - rect->ymin); // 4.0f
+ float rad= 0.5f*(rect->ymax - rect->ymin);
widget_init(&wtb);
- /* half rounded */
+ /* fully rounded */
round_box_edges(&wtb, 15, rect, rad);
widgetbase_draw(&wtb, wcol);
@@ -2045,11 +2043,11 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int state, int roundbox
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb;
- float rad= 5.0f; //0.5f*(rect->ymax - rect->ymin);
+ float rad= 0.5f*(rect->ymax - rect->ymin);
widget_init(&wtb);
- /* half rounded */
+ /* fully rounded */
round_box_edges(&wtb, roundboxalign, rect, rad);
widgetbase_draw(&wtb, wcol);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index c54e09b2b40..5b51d898235 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -445,7 +445,6 @@ void ui_theme_init_userdef(void)
SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255);
SETCOLF(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0);
- SETCOLF(btheme->tv3d.button, 0.45, 0.45, 0.45, 1.0);
SETCOL(btheme->tv3d.panel, 165, 165, 165, 127);
SETCOL(btheme->tv3d.shade1, 160, 160, 160, 100);
@@ -1245,18 +1244,6 @@ void init_userdef_do_versions(void)
SETCOLF(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
}
}
-
- if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 3)) {
- /* new audio system */
- if(U.audiochannels == 0)
- U.audiochannels = 2;
- if(U.audiodevice == 0)
- U.audiodevice = 2;
- if(U.audioformat == 0)
- U.audioformat = 0x24;
- if(U.audiorate == 0)
- U.audiorate = 44100;
- }
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 3e009884dee..1e8cda68e6d 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -235,7 +235,6 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
}
break;
- case LEFTMOUSE:
case MIDDLEMOUSE:
if (event->val==0) {
/* calculate overall delta mouse-movement for redo */
@@ -257,7 +256,6 @@ void VIEW2D_OT_pan(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Pan View";
- ot->description= "Pan the view.";
ot->idname= "VIEW2D_OT_pan";
/* api callbacks */
@@ -306,7 +304,6 @@ void VIEW2D_OT_scroll_right(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Scroll Right";
- ot->description= "Scroll the view right.";
ot->idname= "VIEW2D_OT_scroll_right";
/* api callbacks */
@@ -353,7 +350,6 @@ void VIEW2D_OT_scroll_left(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Scroll Left";
- ot->description= "Scroll the view left.";
ot->idname= "VIEW2D_OT_scroll_left";
/* api callbacks */
@@ -399,7 +395,6 @@ void VIEW2D_OT_scroll_down(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Scroll Down";
- ot->description= "Scroll the view down.";
ot->idname= "VIEW2D_OT_scroll_down";
/* api callbacks */
@@ -446,7 +441,6 @@ void VIEW2D_OT_scroll_up(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Scroll Up";
- ot->description= "Scroll the view up.";
ot->idname= "VIEW2D_OT_scroll_up";
/* api callbacks */
@@ -580,7 +574,6 @@ void VIEW2D_OT_zoom_in(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Zoom In";
- ot->description= "Zoom in the view.";
ot->idname= "VIEW2D_OT_zoom_in";
/* api callbacks */
@@ -617,7 +610,6 @@ void VIEW2D_OT_zoom_out(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Zoom Out";
- ot->description= "Zoom out the view.";
ot->idname= "VIEW2D_OT_zoom_out";
/* api callbacks */
@@ -834,7 +826,6 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
}
break;
- case LEFTMOUSE:
case MIDDLEMOUSE:
if (event->val==0) {
/* for redo, store the overall deltas - need to respect zoom-locks here... */
@@ -864,7 +855,6 @@ void VIEW2D_OT_zoom(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Zoom View";
- ot->description= "Zoom in/out the view.";
ot->idname= "VIEW2D_OT_zoom";
/* api callbacks */
@@ -966,7 +956,6 @@ void VIEW2D_OT_zoom_border(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Zoom to Border";
- ot->description= "Zoom in the view to the nearest item contained in the border.";
ot->idname= "VIEW2D_OT_zoom_border";
/* api callbacks */
@@ -1306,7 +1295,6 @@ void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Scroller Activate";
- ot->description= "Scroll view by mouse click and drag.";
ot->idname= "VIEW2D_OT_scroller_activate";
/* flags */
@@ -1373,7 +1361,6 @@ void VIEW2D_OT_reset(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Reset View";
- ot->description= "Reset the view.";
ot->idname= "VIEW2D_OT_reset";
/* api callbacks */