[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20481] branches/blender2.5/blender/source /blender: UI:
Brecht Van Lommel
brecht at blender.org
Fri May 29 01:37:55 CEST 2009
Revision: 20481
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20481
Author: blendix
Date: 2009-05-29 01:37:55 +0200 (Fri, 29 May 2009)
Log Message:
-----------
UI:
* Added some properties of uiLayout that can be set. I've added
some API code for more than the two I've implementeds, so
ignore those for now.
* layout.active = False will gray out buttons inside a layout.
* layout.enabled = False will gray out and completely disable
the buttons inside a layout.
* Also some function renames.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/editors/armature/poselib.c
branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
branches/blender2.5/blender/source/blender/editors/object/object_edit.c
branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
branches/blender2.5/blender/source/blender/editors/space_info/info_header.c
branches/blender2.5/blender/source/blender/editors/space_sequencer/sequencer_header.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_toolbar.c
branches/blender2.5/blender/source/blender/makesrna/intern/rna_ui.c
Modified: branches/blender2.5/blender/source/blender/editors/armature/poselib.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/poselib.c 2009-05-28 23:23:47 UTC (rev 20480)
+++ branches/blender2.5/blender/source/blender/editors/armature/poselib.c 2009-05-28 23:37:55 UTC (rev 20481)
@@ -328,7 +328,7 @@
/* start building */
pup= uiPupMenuBegin(C, op->type->name, 0);
layout= uiPupMenuLayout(pup);
- uiLayoutContext(layout, WM_OP_EXEC_DEFAULT);
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
/* add new (adds to the first unoccupied frame) */
uiItemIntO(layout, "Add New", 0, "POSELIB_OT_pose_add", "frame", poselib_get_free_index(ob->poselib));
@@ -462,7 +462,7 @@
/* start building */
pup= uiPupMenuBegin(C, op->type->name, 0);
layout= uiPupMenuLayout(pup);
- uiLayoutContext(layout, WM_OP_EXEC_DEFAULT);
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
/* add each marker to this menu */
for (marker=act->markers.first, i=0; marker; marker= marker->next, i++)
Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-05-28 23:23:47 UTC (rev 20480)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-05-28 23:37:55 UTC (rev 20481)
@@ -131,6 +131,7 @@
#define UI_BUT_ANIMATED (1<<20)
#define UI_BUT_ANIMATED_KEY (1<<21)
#define UI_BUT_DRIVEN (1<<22)
+#define UI_BUT_INACTIVE (1<<23)
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
@@ -534,20 +535,38 @@
#define UI_LAYOUT_PANEL 0
#define UI_LAYOUT_HEADER 1
#define UI_LAYOUT_MENU 2
+
+#define UI_UNIT_X 20
+#define UI_UNIT_Y 20
-#define UI_UNIT_X 20
-#define UI_UNIT_Y 20
+#define UI_LAYOUT_ALIGN_LEFT 0
+#define UI_LAYOUT_ALIGN_CENTER 1
+#define UI_LAYOUT_ALIGN_RIGHT 2
uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int size, int em, struct uiStyle *style);
void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout);
void uiBlockLayoutResolve(const struct bContext *C, uiBlock *block, int *x, int *y);
-void uiLayoutContext(uiLayout *layout, int opcontext);
-void uiLayoutFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
-uiBlock *uiLayoutBlock(uiLayout *layout);
+uiBlock *uiLayoutGetBlock(uiLayout *layout);
+void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext);
+void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv);
void uiLayoutSetContextPointer(uiLayout *layout, char *name, struct PointerRNA *ptr);
+void uiLayoutSetActive(uiLayout *layout, int active);
+void uiLayoutSetEnabled(uiLayout *layout, int enabled);
+void uiLayoutSetRedAlert(uiLayout *layout, int redalert);
+void uiLayoutSetAlignment(uiLayout *layout, int alignment);
+void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect);
+void uiLayoutSetScale(uiLayout *layout, float scale);
+
+int uiLayoutGetActive(uiLayout *layout);
+int uiLayoutGetEnabled(uiLayout *layout);
+int uiLayoutGetRedAlert(uiLayout *layout);
+int uiLayoutGetAlignment(uiLayout *layout);
+int uiLayoutGetKeepAspect(uiLayout *layout);
+float uiLayoutGetScale(uiLayout *layout);
+
/* layout specifiers */
uiLayout *uiLayoutRow(uiLayout *layout, int align);
uiLayout *uiLayoutColumn(uiLayout *layout, int align);
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-05-28 23:23:47 UTC (rev 20480)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-05-28 23:37:55 UTC (rev 20481)
@@ -130,8 +130,14 @@
ListBase items;
int x, y, w, h;
- int space;
- int align;
+ float scale;
+ short space;
+ char align;
+ char active;
+ char enabled;
+ char redalert;
+ char keepaspect;
+ char alignment;
};
typedef struct uiLayoutItemFlow {
@@ -946,7 +952,7 @@
{
MenuItemLevel *lvl= (MenuItemLevel*)(((uiBut*)arg)->func_argN);
- uiLayoutContext(layout, WM_OP_EXEC_REGION_WIN);
+ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
uiItemsEnumO(layout, lvl->opname, lvl->propname);
}
@@ -977,7 +983,7 @@
{
MenuItemLevel *lvl= (MenuItemLevel*)(((uiBut*)arg)->func_argN);
- uiLayoutContext(layout, lvl->opcontext);
+ uiLayoutSetOperatorContext(layout, lvl->opcontext);
uiItemsEnumR(layout, &lvl->rnapoin, lvl->propname);
}
@@ -1435,6 +1441,9 @@
litem->item.type= ITEM_LAYOUT_ROW;
litem->root= layout->root;
litem->align= align;
+ litem->active= 1;
+ litem->enabled= 1;
+ litem->context= layout->context;
litem->space= (align)? 0: layout->root->style->buttonspacex;
BLI_addtail(&layout->items, litem);
@@ -1451,6 +1460,9 @@
litem->item.type= ITEM_LAYOUT_COLUMN;
litem->root= layout->root;
litem->align= align;
+ litem->active= 1;
+ litem->enabled= 1;
+ litem->context= layout->context;
litem->space= (litem->align)? 0: layout->root->style->buttonspacey;
BLI_addtail(&layout->items, litem);
@@ -1467,6 +1479,9 @@
flow->litem.item.type= ITEM_LAYOUT_COLUMN_FLOW;
flow->litem.root= layout->root;
flow->litem.align= align;
+ flow->litem.active= 1;
+ flow->litem.enabled= 1;
+ flow->litem.context= layout->context;
flow->litem.space= (flow->litem.align)? 0: layout->root->style->columnspace;
flow->number= number;
BLI_addtail(&layout->items, flow);
@@ -1483,6 +1498,9 @@
box= MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
box->litem.item.type= ITEM_LAYOUT_BOX;
box->litem.root= layout->root;
+ box->litem.active= 1;
+ box->litem.enabled= 1;
+ box->litem.context= layout->context;
box->litem.space= layout->root->style->columnspace;
BLI_addtail(&layout->items, box);
@@ -1501,6 +1519,9 @@
litem->item.type= ITEM_LAYOUT_FREE;
litem->root= layout->root;
litem->align= align;
+ litem->active= 1;
+ litem->enabled= 1;
+ litem->context= layout->context;
BLI_addtail(&layout->items, litem);
uiBlockSetCurLayout(layout->root->block, litem);
@@ -1512,7 +1533,7 @@
{
uiBlock *block;
- block= uiLayoutBlock(layout);
+ block= uiLayoutGetBlock(layout);
uiLayoutFree(layout, 0);
return block;
@@ -1532,6 +1553,66 @@
return litem;
}
+void uiLayoutSetActive(uiLayout *layout, int active)
+{
+ layout->active= active;
+}
+
+void uiLayoutSetEnabled(uiLayout *layout, int enabled)
+{
+ layout->enabled= enabled;
+}
+
+void uiLayoutSetRedAlert(uiLayout *layout, int redalert)
+{
+ layout->redalert= redalert;
+}
+
+void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect)
+{
+ layout->keepaspect= keepaspect;
+}
+
+void uiLayoutSetAlignment(uiLayout *layout, int alignment)
+{
+ layout->alignment= alignment;
+}
+
+void uiLayoutSetScale(uiLayout *layout, float scale)
+{
+ layout->scale= scale;
+}
+
+int uiLayoutGetActive(uiLayout *layout)
+{
+ return layout->active;
+}
+
+int uiLayoutGetEnabled(uiLayout *layout)
+{
+ return layout->enabled;
+}
+
+int uiLayoutGetRedAlert(uiLayout *layout)
+{
+ return layout->redalert;
+}
+
+int uiLayoutGetKeepAspect(uiLayout *layout)
+{
+ return layout->keepaspect;
+}
+
+int uiLayoutGetAlignment(uiLayout *layout)
+{
+ return layout->alignment;
+}
+
+float uiLayoutGetScale(uiLayout *layout)
+{
+ return layout->scale;
+}
+
/********************** Layout *******************/
static void ui_item_estimate(uiItem *item)
@@ -1585,7 +1666,8 @@
if(item->type == ITEM_BUTTON) {
bitem= (uiButtonItem*)item;
if(ui_but_can_align(bitem->but))
- bitem->but->alignnr= nr;
+ if(!bitem->but->alignnr)
+ bitem->but->alignnr= nr;
}
else if(item->type == ITEM_LAYOUT_FREE);
else if(item->type == ITEM_LAYOUT_BOX) {
@@ -1599,6 +1681,21 @@
}
}
+static void ui_item_flag(uiLayout *litem, int flag)
+{
+ uiItem *item;
+ uiButtonItem *bitem;
+
+ for(item=litem->items.last; item; item=item->prev) {
+ if(item->type == ITEM_BUTTON) {
+ bitem= (uiButtonItem*)item;
+ bitem->but->flag |= flag;
+ }
+ else
+ ui_item_flag((uiLayout*)item, flag);
+ }
+}
+
static void ui_item_layout(uiItem *item)
{
uiItem *subitem;
@@ -1611,6 +1708,10 @@
if(litem->align)
ui_item_align(litem, ++litem->root->block->alignnr);
+ if(!litem->active)
+ ui_item_flag(litem, UI_BUT_INACTIVE);
+ if(!litem->enabled)
+ ui_item_flag(litem, UI_BUT_DISABLED);
switch(litem->item.type) {
case ITEM_LAYOUT_COLUMN:
@@ -1694,6 +1795,9 @@
layout->y= y;
layout->root= root;
layout->space= style->templatespace;
+ layout->active= 1;
+ layout->enabled= 1;
+ layout->context= NULL;
if(type == UI_LAYOUT_MENU)
layout->space= 0;
@@ -1714,7 +1818,7 @@
return layout;
}
-uiBlock *uiLayoutBlock(uiLayout *layout)
+uiBlock *uiLayoutGetBlock(uiLayout *layout)
{
return layout->root->block;
}
@@ -1739,12 +1843,12 @@
}
}
-void uiLayoutContext(uiLayout *layout, int opcontext)
+void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext)
{
layout->root->opcontext= opcontext;
}
-void uiLayoutFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
+void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
{
layout->root->handlefunc= handlefunc;
layout->root->argv= argv;
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c 2009-05-28 23:23:47 UTC (rev 20480)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c 2009-05-28 23:37:55 UTC (rev 20481)
@@ -1819,7 +1819,7 @@
pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy");
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);
- uiLayoutContext(pup->layout, WM_OP_INVOKE_REGION_WIN);
+ uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN);
/* create in advance so we can let buttons point to retval already */
pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
@@ -1851,7 +1851,7 @@
pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP);
pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
- uiLayoutContext(pup->layout, WM_OP_EXEC_REGION_WIN);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list