[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20707] branches/blender2.5/blender: UI:
Brecht Van Lommel
brecht at blender.org
Sun Jun 7 15:20:41 CEST 2009
Revision: 20707
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20707
Author: blendix
Date: 2009-06-07 15:20:41 +0200 (Sun, 07 Jun 2009)
Log Message:
-----------
UI:
* layout.split() now takes a percentage argument to control
the split position.
* ID template now works for more than just the Text ID type,
includes and icon, and some other fixes.
Modified Paths:
--------------
branches/blender2.5/blender/release/ui/space_text.py
branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
branches/blender2.5/blender/source/blender/editors/interface/interface_api.c
branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
branches/blender2.5/blender/source/blender/editors/interface/interface_utils.c
Modified: branches/blender2.5/blender/release/ui/space_text.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_text.py 2009-06-07 13:16:31 UTC (rev 20706)
+++ branches/blender2.5/blender/release/ui/space_text.py 2009-06-07 13:20:41 UTC (rev 20707)
@@ -38,7 +38,7 @@
row.itemR(st, "syntax_highlight", text="", icon=ICON_SYNTAX_OFF)
# row.itemR(st, "do_python_plugins", text="", icon=ICON_SCRIPTPLUGINS)
- layout.template_header_ID(context, st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink")
+ layout.template_ID(context, st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink")
if text:
row = layout.row()
Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-06-07 13:16:31 UTC (rev 20706)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h 2009-06-07 13:20:41 UTC (rev 20707)
@@ -594,13 +594,13 @@
uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
uiLayout *uiLayoutBox(uiLayout *layout);
uiLayout *uiLayoutFree(uiLayout *layout, int align);
-uiLayout *uiLayoutSplit(uiLayout *layout);
+uiLayout *uiLayoutSplit(uiLayout *layout, float percentage);
uiBlock *uiLayoutFreeBlock(uiLayout *layout);
/* templates */
void uiTemplateHeader(uiLayout *layout, struct bContext *C);
-void uiTemplateHeaderID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname,
+void uiTemplateID(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname,
char *newop, char *openop, char *unlinkop);
uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
Modified: branches/blender2.5/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_resources.h 2009-06-07 13:16:31 UTC (rev 20706)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_resources.h 2009-06-07 13:20:41 UTC (rev 20707)
@@ -83,8 +83,8 @@
ICON_CHECKBOX_HLT,
ICON_UNLOCKED,
ICON_LOCKED,
- ICON_BLANK013,
- ICON_BLANK014,
+ ICON_PINNED,
+ ICON_UNPINNED,
ICON_BLANK015,
ICON_RIGHTARROW,
ICON_DOWNARROW_HLT,
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_api.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_api.c 2009-06-07 13:16:31 UTC (rev 20706)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_api.c 2009-06-07 13:20:41 UTC (rev 20707)
@@ -86,6 +86,7 @@
func= RNA_def_function(srna, "split", "uiLayoutSplit");
parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
RNA_def_function_return(func, parm);
+ RNA_def_float(func, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f);
/* items */
func= RNA_def_function(srna, "itemR", "uiItemR");
@@ -193,7 +194,7 @@
parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
RNA_def_property_flag(parm, PROP_REQUIRED);
- func= RNA_def_function(srna, "template_header_ID", "uiTemplateHeaderID");
+ func= RNA_def_function(srna, "template_ID", "uiTemplateID");
parm= RNA_def_pointer(func, "context", "Context", "", "Current context.");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property.");
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-06-07 13:16:31 UTC (rev 20706)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_layout.c 2009-06-07 13:20:41 UTC (rev 20707)
@@ -147,17 +147,16 @@
int totcol;
} uiLayoutItemFlow;
-typedef struct uiLayoutItemSplt {
- uiLayout litem;
- int number;
- int lr;
-} uiLayoutItemSplt;
-
typedef struct uiLayoutItemBx {
uiLayout litem;
uiBut *roundbox;
} uiLayoutItemBx;
+typedef struct uiLayoutItemSplt {
+ uiLayout litem;
+ float percentage;
+} uiLayoutItemSplt;
+
typedef struct uiLayoutItemRoot {
uiLayout litem;
} uiLayoutItemRoot;
@@ -1084,7 +1083,7 @@
x += neww;
- if(neww < minw && w != 0) {
+ if((neww < minw || itemw == minw) && w != 0) {
/* fixed size */
item->flag= 1;
fixedw += minw;
@@ -1450,12 +1449,12 @@
static void ui_litem_layout_split(uiLayout *litem)
{
+ uiLayoutItemSplt *split= (uiLayoutItemSplt*)litem;
uiItem *item;
int itemh, x, y, w, tot=0, colw=0;
x= litem->x;
y= litem->y;
- w= litem->w;
for(item=litem->items.first; item; item=item->next)
tot++;
@@ -1463,7 +1462,8 @@
if(tot == 0)
return;
- colw= (litem->w - (tot-1)*litem->space)/tot;
+ w= (litem->w - (tot-1)*litem->space);
+ colw= w*split->percentage;
colw= MAX2(colw, 0);
for(item=litem->items.first; item; item=item->next) {
@@ -1472,8 +1472,12 @@
ui_item_position(item, x, y-itemh, colw, itemh);
x += colw;
- if(item->next)
+ if(item->next) {
+ colw= (w - (w*split->percentage))/(tot-1);
+ colw= MAX2(colw, 0);
+
x += litem->space;
+ }
}
litem->w= x - litem->x;
@@ -1589,18 +1593,23 @@
return block;
}
-uiLayout *uiLayoutSplit(uiLayout *layout)
+uiLayout *uiLayoutSplit(uiLayout *layout, float percentage)
{
- uiLayout *litem;
+ uiLayoutItemSplt *split;
- litem= uiLayoutRow(layout, 0);
- litem->item.type = ITEM_LAYOUT_SPLIT;
- litem->root= layout->root;
- litem->space= layout->root->style->columnspace;
+ split= MEM_callocN(sizeof(uiLayoutItemSplt), "uiLayoutItemSplt");
+ split->litem.item.type= ITEM_LAYOUT_SPLIT;
+ split->litem.root= layout->root;
+ split->litem.active= 1;
+ split->litem.enabled= 1;
+ split->litem.context= layout->context;
+ split->litem.space= layout->root->style->columnspace;
+ split->percentage= (percentage == 0.0f)? 0.5f: percentage;
+ BLI_addtail(&layout->items, split);
- uiBlockSetCurLayout(layout->root->block, litem);
+ uiBlockSetCurLayout(layout->root->block, &split->litem);
- return litem;
+ return &split->litem;
}
void uiLayoutSetActive(uiLayout *layout, int active)
Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c 2009-06-07 13:16:31 UTC (rev 20706)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c 2009-06-07 13:20:41 UTC (rev 20707)
@@ -23,6 +23,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include "MEM_guardedalloc.h"
@@ -59,7 +60,7 @@
/******************* Header ID Template ************************/
-typedef struct TemplateHeaderID {
+typedef struct TemplateID {
PointerRNA ptr;
PropertyRNA *prop;
@@ -69,14 +70,16 @@
char newop[256];
char openop[256];
char unlinkop[256];
-} TemplateHeaderID;
+
+ short idtype;
+} TemplateID;
-static void template_header_id_cb(bContext *C, void *arg_litem, void *arg_event)
+static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
{
- TemplateHeaderID *template= (TemplateHeaderID*)arg_litem;
+ TemplateID *template= (TemplateID*)arg_litem;
PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop);
ID *idtest, *id= idptr.data;
- ListBase *lb= wich_libbase(CTX_data_main(C), ID_TXT);
+ ListBase *lb= wich_libbase(CTX_data_main(C), template->idtype);
int nr, event= GET_INT_FROM_POINTER(arg_event);
if(event == UI_ID_BROWSE && template->browse == 32767)
@@ -110,9 +113,10 @@
}
break;
}
-#if 0
case UI_ID_DELETE:
- id= NULL;
+ memset(&idptr, 0, sizeof(idptr));
+ RNA_property_pointer_set(&template->ptr, template->prop, idptr);
+ RNA_property_update(C, &template->ptr, template->prop);
break;
case UI_ID_FAKE_USER:
if(id) {
@@ -121,7 +125,6 @@
}
else return;
break;
-#endif
case UI_ID_PIN:
break;
case UI_ID_ADD_NEW:
@@ -145,22 +148,26 @@
}
}
-static void template_header_ID(bContext *C, uiBlock *block, TemplateHeaderID *template)
+static void template_header_ID(bContext *C, uiBlock *block, TemplateID *template, StructRNA *type)
{
uiBut *but;
- TemplateHeaderID *duptemplate;
+ TemplateID *duptemplate;
PointerRNA idptr;
ListBase *lb;
- int x= 0, y= 0;
idptr= RNA_property_pointer_get(&template->ptr, template->prop);
- lb= wich_libbase(CTX_data_main(C), ID_TXT);
+ lb= wich_libbase(CTX_data_main(C), template->idtype);
+ if(idptr.type)
+ type= idptr.type;
+ if(type)
+ uiDefIconBut(block, LABEL, 0, RNA_struct_ui_icon(type), 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+
uiBlockBeginAlign(block);
if(template->flag & UI_ID_BROWSE) {
char *extrastr, *str;
- if((template->flag & UI_ID_ADD_NEW) && (template->flag && UI_ID_OPEN))
+ if((template->flag & UI_ID_ADD_NEW) && (template->flag & UI_ID_OPEN))
extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767";
else if(template->flag & UI_ID_ADD_NEW)
extrastr= "ADD NEW %x 32767";
@@ -172,9 +179,8 @@
duptemplate= MEM_dupallocN(template);
IDnames_to_pupstring(&str, NULL, extrastr, lb, idptr.data, &duptemplate->browse);
- but= uiDefButS(block, MENU, 0, str, x, y, UI_UNIT_X, UI_UNIT_Y, &duptemplate->browse, 0, 0, 0, 0, "Browse existing choices, or add new");
- uiButSetNFunc(but, template_header_id_cb, duptemplate, SET_INT_IN_POINTER(UI_ID_BROWSE));
- x+= UI_UNIT_X;
+ but= uiDefButS(block, MENU, 0, str, 0, 0, UI_UNIT_X, UI_UNIT_Y, &duptemplate->browse, 0, 0, 0, 0, "Browse existing choices, or add new");
+ uiButSetNFunc(but, template_id_cb, duptemplate, SET_INT_IN_POINTER(UI_ID_BROWSE));
MEM_freeN(str);
}
@@ -183,40 +189,46 @@
if(idptr.data) {
char name[64];
- text_idbutton(idptr.data, name);
- but= uiDefButR(block, TEX, 0, name, x, y, UI_UNIT_X*6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
- uiButSetNFunc(but, template_header_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME));
- x += UI_UNIT_X*6;
+ //text_idbutton(idptr.data, name);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list