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/interface_layout.c')
-rw-r--r--source/blender/editors/interface/interface_layout.c119
1 files changed, 93 insertions, 26 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 233d3b214ae..41a0ad7d4b0 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -98,6 +98,7 @@ typedef enum uiItemType {
ITEM_LAYOUT_BOX,
ITEM_LAYOUT_ABSOLUTE,
ITEM_LAYOUT_SPLIT,
+ ITEM_LAYOUT_OVERLAP,
ITEM_LAYOUT_ROOT
#if 0
@@ -148,7 +149,6 @@ typedef struct uiLayoutItemFlow {
typedef struct uiLayoutItemBx {
uiLayout litem;
uiBut *roundbox;
- ListBase items;
} uiLayoutItemBx;
typedef struct uiLayoutItemSplt {
@@ -286,6 +286,7 @@ static int ui_layout_local_dir(uiLayout *layout)
switch(layout->item.type) {
case ITEM_LAYOUT_ROW:
case ITEM_LAYOUT_ROOT:
+ case ITEM_LAYOUT_OVERLAP:
return UI_LAYOUT_HORIZONTAL;
case ITEM_LAYOUT_COLUMN:
case ITEM_LAYOUT_COLUMN_FLOW:
@@ -362,7 +363,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
int cols= (len >= 20)? 2: 1;
int colbuts= len/(2*cols);
- uiBlockSetCurLayout(block, uiLayoutFree(layout, 0));
+ uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 0));
unit= UI_UNIT_X*0.75;
butw= unit;
@@ -390,7 +391,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
/* matrix layout */
int row, col;
- uiBlockSetCurLayout(block, uiLayoutFree(layout, 1));
+ uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 1));
len= ceil(sqrt(len));
@@ -892,10 +893,13 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
name= ui_item_name_add_colon(name, namestr);
if(layout->root->type == UI_LAYOUT_MENU) {
- if(type == PROP_BOOLEAN)
- icon= (RNA_property_boolean_get(ptr, prop))? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
- else if(type == PROP_ENUM && index == RNA_ENUM_VALUE)
- icon= (RNA_property_enum_get(ptr, prop) == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
+ /* whether the property is actually enabled doesn't matter,
+ * since the widget code for drawing toggles takes care of the
+ * rest (i.e. given the deactivated icon, it finds the active one
+ * based on the state of the setting)
+ */
+ if ( (type == PROP_BOOLEAN) || (type==PROP_ENUM && index==RNA_ENUM_VALUE) )
+ icon= ICON_CHECKBOX_DEHLT; /* ICON_CHECKBOX_HLT when on... */
}
slider= (flag & UI_ITEM_R_SLIDER);
@@ -1051,10 +1055,14 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui
{
uiBut *but= arg_but;
char *name;
- int i, iconid;
+ int i, iconid, flag= RNA_property_flag(but->rnaprop);
i = 0;
RNA_PROP_BEGIN(&but->rnasearchpoin, itemptr, but->rnasearchprop) {
+ if(flag & PROP_ID_SELF_CHECK)
+ if(itemptr.data == but->rnapoin.id.data)
+ continue;
+
iconid= 0;
if(RNA_struct_is_ID(itemptr.type))
iconid= ui_id_icon_get((bContext*)C, itemptr.data);
@@ -1495,11 +1503,11 @@ static void ui_litem_layout_row(uiLayout *litem)
/* align right/center */
offset= 0;
if(litem->alignment == UI_LAYOUT_ALIGN_RIGHT) {
- if(fixedw == 0 && freew < w-fixedw)
+ if(freew > 0 && freew < w-fixedw)
offset= (w - fixedw) - freew;
}
else if(litem->alignment == UI_LAYOUT_ALIGN_CENTER) {
- if(fixedw == 0 && freew < w-fixedw)
+ if(freew > 0 && freew < w-fixedw)
offset= ((w - fixedw) - freew)/2;
}
@@ -1862,6 +1870,42 @@ static void ui_litem_layout_split(uiLayout *litem)
litem->y= y;
}
+/* overlap layout */
+static void ui_litem_estimate_overlap(uiLayout *litem)
+{
+ uiItem *item;
+ int itemw, itemh;
+
+ litem->w= 0;
+ litem->h= 0;
+
+ for(item=litem->items.first; item; item=item->next) {
+ ui_item_size(item, &itemw, &itemh);
+
+ litem->w= MAX2(itemw, litem->w);
+ litem->h= MAX2(itemh, litem->h);
+ }
+}
+
+static void ui_litem_layout_overlap(uiLayout *litem)
+{
+ uiItem *item;
+ int itemw, itemh, x, y;
+
+ x= litem->x;
+ y= litem->y;
+
+ for(item=litem->items.first; item; item=item->next) {
+ ui_item_size(item, &itemw, &itemh);
+ ui_item_position(item, x, y-itemh, litem->w, itemh);
+
+ litem->h= MAX2(litem->h, itemh);
+ }
+
+ litem->x= x;
+ litem->y= y - litem->h;
+}
+
/* layout create functions */
uiLayout *uiLayoutRow(uiLayout *layout, int align)
{
@@ -1921,7 +1965,7 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align)
return &flow->litem;
}
-static uiLayout *ui_layout_box(uiLayout *layout, int type)
+static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
{
uiLayoutItemBx *box;
@@ -1938,30 +1982,32 @@ static uiLayout *ui_layout_box(uiLayout *layout, int type)
box->roundbox= uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, "");
- return &box->litem;
+ return box;
}
uiLayout *uiLayoutBox(uiLayout *layout)
{
- return ui_layout_box(layout, ROUNDBOX);
+ return (uiLayout*)ui_layout_box(layout, ROUNDBOX);
}
-uiLayout *uiLayoutListBox(uiLayout *layout)
+uiLayout *uiLayoutListBox(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *actptr, PropertyRNA *actprop)
{
- return ui_layout_box(layout, LISTBOX);
-}
+ uiLayoutItemBx *box= ui_layout_box(layout, LISTBOX);
+ uiBut *but= box->roundbox;
-ListBase *uiLayoutBoxGetList(uiLayout *layout)
-{
- uiLayoutItemBx *box= (uiLayoutItemBx*)layout;
- return &box->items;
+ but->rnasearchpoin= *ptr;
+ but->rnasearchprop= prop;
+ but->rnapoin= *actptr;
+ but->rnaprop= actprop;
+
+ return (uiLayout*)box;
}
-uiLayout *uiLayoutFree(uiLayout *layout, int align)
+uiLayout *uiLayoutAbsolute(uiLayout *layout, int align)
{
uiLayout *litem;
- litem= MEM_callocN(sizeof(uiLayout), "uiLayoutFree");
+ litem= MEM_callocN(sizeof(uiLayout), "uiLayoutAbsolute");
litem->item.type= ITEM_LAYOUT_ABSOLUTE;
litem->root= layout->root;
litem->align= align;
@@ -1980,11 +2026,28 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout)
uiBlock *block;
block= uiLayoutGetBlock(layout);
- uiLayoutFree(layout, 0);
+ uiLayoutAbsolute(layout, 0);
return block;
}
+uiLayout *uiLayoutOverlap(uiLayout *layout)
+{
+ uiLayout *litem;
+
+ litem= MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
+ litem->item.type= ITEM_LAYOUT_OVERLAP;
+ litem->root= layout->root;
+ litem->active= 1;
+ litem->enabled= 1;
+ litem->context= layout->context;
+ BLI_addtail(&layout->items, litem);
+
+ uiBlockSetCurLayout(layout->root->block, litem);
+
+ return litem;
+}
+
uiLayout *uiLayoutSplit(uiLayout *layout, float percentage)
{
uiLayoutItemSplt *split;
@@ -2142,6 +2205,9 @@ static void ui_item_estimate(uiItem *item)
case ITEM_LAYOUT_SPLIT:
ui_litem_estimate_split(litem);
break;
+ case ITEM_LAYOUT_OVERLAP:
+ ui_litem_estimate_overlap(litem);
+ break;
default:
break;
}
@@ -2162,6 +2228,7 @@ static void ui_item_align(uiLayout *litem, int nr)
bitem->but->alignnr= nr;
}
else if(item->type == ITEM_LAYOUT_ABSOLUTE);
+ else if(item->type == ITEM_LAYOUT_OVERLAP);
else if(item->type == ITEM_LAYOUT_BOX) {
box= (uiLayoutItemBx*)item;
box->roundbox->alignnr= nr;
@@ -2227,6 +2294,9 @@ static void ui_item_layout(uiItem *item)
case ITEM_LAYOUT_SPLIT:
ui_litem_layout_split(litem);
break;
+ case ITEM_LAYOUT_OVERLAP:
+ ui_litem_layout_overlap(litem);
+ break;
default:
break;
}
@@ -2261,9 +2331,6 @@ static void ui_layout_free(uiLayout *layout)
ui_layout_free((uiLayout*)item);
}
- if(layout->item.type == ITEM_LAYOUT_BOX)
- BLI_freelistN(&((uiLayoutItemBx*)layout)->items);
-
MEM_freeN(layout);
}