UI:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 16 Apr 2009 12:17:58 +0000 (12:17 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 16 Apr 2009 12:17:58 +0000 (12:17 +0000)
* Don't call generic layout hints templates anymore, i.e.
  TemplateRow becomes Row, etc.
* Added more general layout nesting, using uiLayoutSplit()
  and uiLayoutBox() functions, for which the sublayouts
  can then be accessed using uiLayoutSub(), to put items
  in those sublayouts.
* Some steps to make the layout decisions, like which items
  to put in which columns, independent of the width of the
  window or the text in the buttons. We want the layout to
  be stable under resizes and translations.
* Added an "expand" parameter to uiItemR, used now to expand
  enums into a row instead of using a menu.

release/ui/buttons_objects.py
release/ui/buttons_scene.py
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_api.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_utils.c
source/blender/editors/space_text/text_header.c

index e760247b0c58246a3cf81386423768086bbf41e4..a8cfa40f2531c1244f128b8a13b130a76d1c75ba 100644 (file)
@@ -11,7 +11,7 @@ class OBJECT_PT_transform(bpy.types.Panel):
                if not ob:
                        return
 
-               layout.template_row()
+               layout.row()
                layout.itemR(ob, "location")
                layout.itemR(ob, "rotation")
                layout.itemR(ob, "scale")
@@ -27,24 +27,24 @@ class OBJECT_PT_groups(bpy.types.Panel):
                if not ob:
                        return
 
-               layout.template_row()
+               layout.row()
                layout.itemR(ob, "pass_index")
                layout.itemR(ob, "parent")
 
-               # layout.template_left_right()
+               # layout.left_right()
                # layout.itemO("OBJECT_OT_add_group");
 
                for group in bpy.data.groups:
                        if ob in group.objects:
-                               sublayout = layout.template_stack()
+                               sub = layout.box()
 
-                               sublayout.template_left_right()
-                               sublayout.itemR(group, "name")
-                               # sublayout.itemO("OBJECT_OT_remove_group")
+                               sub.split(number=2, lr=True)
+                               sub.sub(0).itemR(group, "name")
+                               # sub.sub(1).itemO("OBJECT_OT_remove_group")
 
-                               sublayout.template_row()
-                               sublayout.itemR(group, "layer")
-                               sublayout.itemR(group, "dupli_offset")
+                               sub.row()
+                               sub.itemR(group, "layer")
+                               sub.itemR(group, "dupli_offset")
 
 class OBJECT_PT_display(bpy.types.Panel):
        __label__ = "Display"
@@ -57,11 +57,11 @@ class OBJECT_PT_display(bpy.types.Panel):
                if not ob:
                        return
 
-               layout.template_row()
+               layout.row()
                layout.itemR(ob, "max_draw_type", text="Type")
                layout.itemR(ob, "draw_bounds_type", text="Bounds")
 
-               layout.template_column_flow(2)
+               layout.column_flow()
                layout.itemR(ob, "draw_name", text="Name")
                layout.itemR(ob, "draw_axis", text="Axis")
                layout.itemR(ob, "draw_wire", text="Wire")
@@ -80,11 +80,11 @@ class OBJECT_PT_duplication(bpy.types.Panel):
                if not ob:
                        return
 
-               layout.template_column()
-               layout.itemR(ob, "dupli_type", text="")
+               layout.column()
+               layout.itemR(ob, "dupli_type", text="", expand=True)
 
                if ob.dupli_type == "FRAMES":
-                       layout.template_column_flow(2)
+                       layout.column_flow()
                        layout.itemR(ob, "dupli_frames_start", text="Start:")
                        layout.itemR(ob, "dupli_frames_end", text="End:")
                        layout.itemR(ob, "dupli_frames_on", text="On:")
@@ -101,21 +101,23 @@ class OBJECT_PT_animation(bpy.types.Panel):
                if not ob:
                        return
 
-               layout.template_column()
+               layout.split(number=2)
                
-               layout.template_slot("COLUMN_1")
-               layout.itemL(text="Time Offset:")
-               layout.itemR(ob, "time_offset_edit", text="Edit")
-               layout.itemR(ob, "time_offset_particle", text="Particle")
-               layout.itemR(ob, "time_offset_parent", text="Parent")
-               layout.itemR(ob, "slow_parent")
-               layout.itemR(ob, "time_offset", text="Offset:")
+               sub = layout.sub(0)
+               sub.column()
+               sub.itemL(text="Time Offset:")
+               sub.itemR(ob, "time_offset_edit", text="Edit")
+               sub.itemR(ob, "time_offset_particle", text="Particle")
+               sub.itemR(ob, "time_offset_parent", text="Parent")
+               sub.itemR(ob, "slow_parent")
+               sub.itemR(ob, "time_offset", text="Offset:")
                
-               layout.template_slot("COLUMN_2")
-               layout.itemL(text="Tracking:")
-               layout.itemR(ob, "track_axis", text="Axis")
-               layout.itemR(ob, "up_axis", text="Up Axis")
-               layout.itemR(ob, "track_rotation", text="Rotation")
+               sub = layout.sub(1)
+               sub.column()
+               sub.itemL(text="Tracking:")
+               sub.itemR(ob, "track_axis", text="Axis")
+               sub.itemR(ob, "up_axis", text="Up Axis")
+               sub.itemR(ob, "track_rotation", text="Rotation")
 
 bpy.ui.addPanel(OBJECT_PT_transform, "BUTTONS_WINDOW", "WINDOW")
 bpy.ui.addPanel(OBJECT_PT_groups, "BUTTONS_WINDOW", "WINDOW")
index 4ccd8d0da485836e80079594ec3beb1b2011441b..5279aa10843c1c1176da0f9d02fb2f78042878ac 100644 (file)
@@ -14,7 +14,7 @@ class RENDER_PT_shading(bpy.types.Panel):
 
                rd = scene.render_data
 
-               layout.template_column_flow(2)
+               layout.column_flow()
                layout.itemR(rd, "render_shadows", text="Shadows")
                layout.itemR(rd, "render_sss", text="SSS")
                layout.itemR(rd, "render_envmaps", text="EnvMap")
@@ -22,7 +22,7 @@ class RENDER_PT_shading(bpy.types.Panel):
                layout.itemR(rd, "render_raytracing", text="Ray Tracing")
                layout.itemR(rd, "octree_resolution")
 
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "alpha_mode")
 
 class RENDER_PT_image(bpy.types.Panel):
@@ -38,13 +38,13 @@ class RENDER_PT_image(bpy.types.Panel):
 
                rd = scene.render_data
 
-               layout.template_column_flow(2)
+               layout.column_flow()
                layout.itemR(rd, "resolution_x", text="SizeX")
                layout.itemR(rd, "resolution_x", text="SizeY")
                layout.itemR(rd, "pixel_aspect_x", text="AspX")
                layout.itemR(rd, "pixel_aspect_y", text="AspY")
 
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "crop_to_border")
 
 class RENDER_PT_antialiasing(bpy.types.Panel):
@@ -60,7 +60,7 @@ class RENDER_PT_antialiasing(bpy.types.Panel):
 
                rd = scene.render_data
 
-               layout.template_column_flow(2)
+               layout.column_flow()
                layout.itemR(rd, "antialiasing", text="Enable")
                layout.itemR(rd, "antialiasing_samples", text="Samples")
                layout.itemR(rd, "pixel_filter")
@@ -79,42 +79,42 @@ class RENDER_PT_render(bpy.types.Panel):
 
                rd = scene.render_data
 
-               layout.template_row()
+               layout.row()
                layout.itemO("SCREEN_OT_render", text="RENDER", icon=0) # ICON_SCENE
                #layout.itemO("SCREEN_OT_render", text="ANIM", icon=0) # "anim", 1
 
-               layout.template_row()
+               layout.row()
                layout.itemR(scene, "start_frame", text="Start")
                layout.itemR(scene, "end_frame", text="End")
                layout.itemR(scene, "current_frame", text="Frame")
 
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "do_composite")
                layout.itemR(rd, "do_sequence")
 
-               layout.template_row()
+               layout.row()
                layout.itemL(text="General")
 
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "resolution_percentage", text="Size ")
                layout.itemR(rd, "dither_intensity")
 
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "parts_x")
                layout.itemR(rd, "parts_y")
 
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "threads")
                layout.itemR(rd, "threads_mode")
 
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "fields", text="Fields")
                layout.itemR(rd, "field_order", text="Order")
                layout.itemR(rd, "fields_still", text="Still")
 
-               layout.template_row()
+               layout.row()
                layout.itemL(text="Extra:")
-               layout.template_row()
+               layout.row()
                layout.itemR(rd, "border", text="Border Render")
                layout.itemR(rd, "panorama")
 
index 52041666679ce536981e73250a754dc86a1d3a56..f3da97a801e17e2537bc4df475d22888bb4531ef 100644 (file)
@@ -557,37 +557,24 @@ uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, cha
 
 typedef struct uiLayout uiLayout;
 
-uiLayout *uiLayoutBegin(int dir, int x, int y, int w, int h);
+uiLayout *uiLayoutBegin(int dir, int x, int y, int size, int em);
 void uiLayoutContext(uiLayout *layout, int opcontext);
 void uiLayoutEnd(const struct bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y);
 
-/* vertical button templates */
-#define UI_TSLOT_COLUMN_1      0
-#define UI_TSLOT_COLUMN_2      1
-#define UI_TSLOT_COLUMN_3      2
-#define UI_TSLOT_COLUMN_4      3
-#define UI_TSLOT_COLUMN_5      4
-#define UI_TSLOT_COLUMN_MAX    5
-
-#define UI_TSLOT_LR_LEFT       0
-#define UI_TSLOT_LR_RIGHT      1
-
-void uiTemplateLeftRight(uiLayout *layout);
-void uiTemplateRow(uiLayout *layout);
-void uiTemplateColumn(uiLayout *layout);
-void uiTemplateColumnFlow(uiLayout *layout, int columns);
-uiLayout *uiTemplateStack(uiLayout *layout);
-
-/* horizontal header templates */
-#define UI_TSLOT_HEADER                0
+/* layout specifiers */
+void uiLayoutRow(uiLayout *layout);
+void uiLayoutColumn(uiLayout *layout);
+void uiLayoutColumnFlow(uiLayout *layout, int number);
+void uiLayoutSplit(uiLayout *layout, int number, int lr);
+uiLayout *uiLayoutBox(uiLayout *layout);
+uiLayout *uiLayoutSub(uiLayout *layout, int n);
 
+/* templates */
 void uiTemplateHeaderMenus(uiLayout *layout);
 void uiTemplateHeaderButtons(uiLayout *layout);
 void uiTemplateHeaderID(uiLayout *layout, struct PointerRNA *ptr, char *propname, int flag, uiIDPoinFunc func);
 void uiTemplateSetColor(uiLayout *layout, int color);
 
-void uiTemplateSlot(uiLayout *layout, int slot);
-
 /* items */
 void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
 void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
@@ -598,8 +585,8 @@ void uiItemFloatO(uiLayout *layout, char *name, int icon, char *opname, char *pr
 void uiItemStringO(uiLayout *layout, char *name, int icon, char *opname, char *propname, char *value);
 void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct IDProperty *properties, int context);
 
-void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname);
-void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index);
+void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand);
+void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int expand);
 
 void uiItemL(uiLayout *layout, char *name, int icon);
 
index 95793c0c149cbc700fca86c4e701b63d11cf1020..a184655df83d9c3070dca3955cbbbff99ff5720f 100644 (file)
@@ -45,39 +45,32 @@ void RNA_api_ui_layout(StructRNA *srna)
        FunctionRNA *func;
        PropertyRNA *parm;
 
-       static EnumPropertyItem slot_items[]= {
-               {0, "DEFAULT", "Default", ""},
-               {UI_TSLOT_COLUMN_1, "COLUMN_1", "Column 1", ""},
-               {UI_TSLOT_COLUMN_2, "COLUMN_2", "Column 2", ""},
-               {UI_TSLOT_COLUMN_3, "COLUMN_3", "Column 3", ""},
-               {UI_TSLOT_COLUMN_4, "COLUMN_4", "Column 4", ""},
-               {UI_TSLOT_COLUMN_5, "COLUMN_5", "Column 5", ""},
-               {UI_TSLOT_LR_LEFT, "LEFT", "Left", ""},
-               {UI_TSLOT_LR_RIGHT, "RIGHT", "Right", ""},
-               {0, NULL, NULL, NULL}
-       };
+       /* simple layout specifiers */
+       func= RNA_def_function(srna, "row", "uiLayoutRow");
+       func= RNA_def_function(srna, "column", "uiLayoutColumn");
+       func= RNA_def_function(srna, "column_flow", "uiLayoutColumnFlow");
+       parm= RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic.", 0, INT_MAX);
 
-       /* templates */
-       func= RNA_def_function(srna, "template_row", "uiTemplateRow");
-       func= RNA_def_function(srna, "template_column", "uiTemplateColumn");
-       func= RNA_def_function(srna, "template_left_right", "uiTemplateLeftRight");
+       /* box layout */
+       func= RNA_def_function(srna, "box", "uiLayoutBox");
+       parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
+       RNA_def_function_return(func, parm);
 
-       func= RNA_def_function(srna, "template_column_flow", "uiTemplateColumnFlow");
-       parm= RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns.", 0, INT_MAX);
-       RNA_def_property_flag(parm, PROP_REQUIRED);
+       /* split layout */
+       func= RNA_def_function(srna, "split", "uiLayoutSplit");
+       parm= RNA_def_int(func, "number", 2, 0, INT_MAX, "", "Number of splits.", 0, INT_MAX);
+       parm= RNA_def_boolean(func, "lr", 0, "", "LR.");
 
-       func= RNA_def_function(srna, "template_stack", "uiTemplateStack");
-       parm= RNA_def_pointer(func, "sub_layout", "UILayout", "", "Sub-layout to put stack items in.");
+       /* sub layout */
+       func= RNA_def_function(srna, "sub", "uiLayoutSub");
+       parm= RNA_def_int(func, "n", 0, 0, INT_MAX, "", "Index of sub-layout.", 0, INT_MAX);
+       RNA_def_property_flag(parm, PROP_REQUIRED);
+       parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
        RNA_def_function_return(func, parm);
 
        func= RNA_def_function(srna, "template_header_menus", "uiTemplateHeaderMenus");
-       func= RNA_def_function(srna, "template_header_buttons", "uiTemplateHeaderButtons");
        //func= RNA_def_function(srna, "template_header_ID", "uiTemplateHeaderID");
 
-       func= RNA_def_function(srna, "template_slot", "uiTemplateSlot");
-       parm= RNA_def_enum(func, "slot", slot_items, 0, "", "Where in the template to put the following items.");
-       RNA_def_property_flag(parm, PROP_REQUIRED);
-
        /* items */
        func= RNA_def_function(srna, "itemR", "uiItemR");
        api_ui_item_common(func);
@@ -85,6 +78,7 @@ void RNA_api_ui_layout(StructRNA *srna)
        RNA_def_property_flag(parm, PROP_REQUIRED);
        parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
        RNA_def_property_flag(parm, PROP_REQUIRED);
+       RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
 
        func= RNA_def_function(srna, "itemO", "uiItemO");
        api_ui_item_common(func);
index e6d55e37cfe8a7fc8bacd0e4d52b3fe4ad1b6842..b3216412b68439ae0ac606ec5d9febf9820a905e 100644 (file)
 
 #define COLUMN_SPACE   5
 #define TEMPLATE_SPACE 5
-#define STACK_SPACE            5
+#define BOX_SPACE              5
 #define BUTTON_SPACE_X 5
 #define BUTTON_SPACE_Y 2
 
 #define RNA_NO_INDEX   -1
 
+#define EM_UNIT_X              XIC
+#define EM_UNIT_Y              YIC
+
 /* Item */
 
 typedef enum uiItemType {
@@ -75,6 +78,7 @@ typedef struct uiItemRNA {
        PointerRNA ptr;
        PropertyRNA *prop;
        int index;
+       int expand;
 } uiItemRNA;
 
 typedef struct uiItemOp {
@@ -97,8 +101,8 @@ typedef enum uiTemplateType {
        TEMPLATE_ROW,
        TEMPLATE_COLUMN,
        TEMPLATE_COLUMN_FLOW,
-       TEMPLATE_LR,
-       TEMPLATE_STACK,
+       TEMPLATE_SPLIT,
+       TEMPLATE_BOX,
 
        TEMPLATE_HEADER_MENUS,
        TEMPLATE_HEADER_BUTTONS,
@@ -115,13 +119,20 @@ typedef struct uiTemplate {
 
 typedef struct uiTemplateFlow {
        uiTemplate template;
-       int columns;
+       int number;
 } uiTemplateFlow;
 
-typedef struct uiTemplateStck {
+typedef struct uiTemplateSplt {
+       uiTemplate template;
+       int number;
+       int lr;
+       uiLayout **sublayout;
+} uiTemplateSplt;
+
+typedef struct uiTemplateBx {
        uiTemplate template;
        uiLayout *sublayout;
-} uiTemplateStck;
+} uiTemplateBx;
 
 typedef struct uiTemplateHeadID {
        uiTemplate template;
@@ -139,6 +150,7 @@ struct uiLayout {
        int opcontext;
        int dir;
        int x, y, w, h;
+       int emw, emh;
 };
 
 void ui_layout_free(uiLayout *layout);
@@ -146,12 +158,28 @@ void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x,
 
 /************************** Item ***************************/
 
-static int ui_item_fit(int item, int all, int available)
+#define UI_FIT_EXPAND 1
+
+static int ui_item_fit(int item, int pos, int all, int available, int last, int flag)
 {
-       if(all > available)
-               return (item*available)/all;
-       
-       return all;
+       if(all > available) {
+               /* contents is bigger than available space */
+               if(last)
+                       return available-pos;
+               else
+                       return (item*available)/all;
+       }
+       else {
+               /* contents is smaller or equal to available space */
+               if(flag & UI_FIT_EXPAND) {
+                       if(last)
+                               return available-pos;
+                       else
+                               return (item*available)/all;
+               }
+               else
+                       return item;
+       }
 }
 
 /* create buttons for an item with an RNA array */
@@ -173,7 +201,7 @@ static void ui_item_array(uiBlock *block, uiItemRNA *rnaitem, int len, int x, in
                name= (char*)RNA_property_ui_name(&rnaitem->ptr, rnaitem->prop);
 
        if(strcmp(name, "") != 0)
-               uiDefBut(block, LABEL, 0, name, x, y + h - YIC, w, YIC, NULL, 0.0, 0.0, 0, 0, "");
+               uiDefBut(block, LABEL, 0, name, x, y + h - EM_UNIT_Y, w, EM_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
 
        /* create buttons */
        uiBlockBeginAlign(block);
@@ -182,10 +210,10 @@ static void ui_item_array(uiBlock *block, uiItemRNA *rnaitem, int len, int x, in
                /* special check for layer layout */
                int butw, buth;
 
-               butw= ui_item_fit(XIC, XIC*10 + BUTTON_SPACE_X, w);
-               buth= MIN2(YIC, butw);
+               butw= ui_item_fit(EM_UNIT_X, 0, EM_UNIT_X*10 + BUTTON_SPACE_X, w, 0, UI_FIT_EXPAND);
+               buth= MIN2(EM_UNIT_Y, butw);
 
-               y += 2*(YIC - buth);
+               y += 2*(EM_UNIT_Y - buth);
 
                uiBlockBeginAlign(block);
                for(a=0; a<5; a++)
@@ -217,7 +245,7 @@ static void ui_item_array(uiBlock *block, uiItemRNA *rnaitem, int len, int x, in
                        col= a%len;
                        row= a/len;
 
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, "", 0, x + w*col, y+(row-a-1)*YIC, w, YIC);
+                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, "", 0, x + w*col, y+(row-a-1)*EM_UNIT_Y, w, EM_UNIT_Y);
                }
        }
        else if(len <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) {
@@ -243,18 +271,37 @@ static void ui_item_array(uiBlock *block, uiItemRNA *rnaitem, int len, int x, in
                                str[2]= '\0';
                        }
 
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, str, 0, x, y+(len-a-1)*YIC, w, YIC);
+                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, str, 0, x, y+(len-a-1)*EM_UNIT_Y, w, EM_UNIT_Y);
                }
        }
        else {
                /* default array layout */
                for(a=0; a<len; a++)
-                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, "", 0, x, y+(len-a-1)*YIC, w, YIC);
+                       uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, "", 0, x, y+(len-a-1)*EM_UNIT_Y, w, EM_UNIT_Y);
        }
 
        uiBlockEndAlign(block);
 }
 
+static void ui_item_enum_row(uiBlock *block, uiItemRNA *rnaitem, int x, int y, int w, int h)
+{
+       const EnumPropertyItem *item;
+       int a, totitem, pos, itemw;
+       const char *propname;
+       
+       propname= RNA_property_identifier(&rnaitem->ptr, rnaitem->prop);
+       RNA_property_enum_items(&rnaitem->ptr, rnaitem->prop, &item, &totitem);
+
+       uiBlockBeginAlign(block);
+       pos= 0;
+       for(a=0; a<totitem; a++) {
+               itemw= ui_item_fit(1, pos, totitem, w, a == totitem-1, UI_FIT_EXPAND);
+               uiDefButR(block, ROW, 0, NULL, x+pos, y, itemw, h, &rnaitem->ptr, propname, -1, 0, item[a].value, -1, -1, NULL);
+               pos += itemw;
+       }
+       uiBlockEndAlign(block);
+}
+
 /* create label + button for RNA property */
 static void ui_item_with_label(uiBlock *block, uiItemRNA *rnaitem, int x, int y, int w, int h)
 {
@@ -290,6 +337,9 @@ static void ui_item_buts(uiBlock *block, uiItem *item, int x, int y, int w, int
                /* array property */
                if(rnaitem->index == RNA_NO_INDEX && len > 0)
                        ui_item_array(block, rnaitem, len, x, y, w, h);
+               /* expanded enum */
+               else if(type == PROP_ENUM && rnaitem->expand)
+                       ui_item_enum_row(block, rnaitem, x, y, w, h);
                /* property with separate label */
                else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER)
                        ui_item_with_label(block, rnaitem, x, y, w, h);
@@ -343,19 +393,16 @@ static void ui_item_buts(uiBlock *block, uiItem *item, int x, int y, int w, int
 static int ui_text_icon_width(char *name, int icon)
 {
        if(icon && name && strcmp(name, "") == 0)
-               return XIC; /* icon only */
-       else if(icon && name)
-               return XIC + GetButStringLength((char*)name); /* icon + text */
-       else if(name)
-               return GetButStringLength((char*)name); /* text only */
+               return EM_UNIT_X; /* icon only */
+       else if(icon)
+               return 10*EM_UNIT_X; /* icon + text */
        else
-               return 0;
+               return 10*EM_UNIT_X; /* text only */
 }
 
 /* estimated size of an item */
 static void ui_item_size(uiItem *item, int *r_w, int *r_h)
 {
-       char *name;
        int w, h;
 
        if(item->type == ITEM_RNA_PROPERTY) {
@@ -365,53 +412,34 @@ static void ui_item_size(uiItem *item, int *r_w, int *r_h)
                PropertySubType subtype;
                int len;
 
-               name= item->name;
-               if(!name)
-                       name= (char*)RNA_property_ui_name(&rnaitem->ptr, rnaitem->prop);
-
-               w= ui_text_icon_width(name, item->icon);
-               h= YIC;
+               w= ui_text_icon_width(item->name, item->icon);
+               h= EM_UNIT_Y;
 
                /* arbitrary extended width by type */
                type= RNA_property_type(&rnaitem->ptr, rnaitem->prop);
                subtype= RNA_property_subtype(&rnaitem->ptr, rnaitem->prop);
                len= RNA_property_array_length(&rnaitem->ptr, rnaitem->prop);
 
-               if(type == PROP_BOOLEAN && !item->icon)
-                       w += XIC;
-               else if(type == PROP_INT || type == PROP_FLOAT)
-                       w += 2*XIC;
-               else if(type == PROP_STRING)
-                       w += 8*XIC;
+               if(type == PROP_STRING)
+                       w += 10*EM_UNIT_X;
 
                /* increase height for arrays */
                if(rnaitem->index == RNA_NO_INDEX && len > 0) {
-                       if(name && strcmp(name, "") == 0 && item->icon == 0)
+                       if(item->name && strcmp(item->name, "") == 0 && item->icon == 0)
                                h= 0;
 
                        if(type == PROP_BOOLEAN && len == 20)
-                               h += 2*YIC;
+                               h += 2*EM_UNIT_Y;
                        else if(subtype == PROP_MATRIX)
-                               h += ceil(sqrt(len))*YIC;
+                               h += ceil(sqrt(len))*EM_UNIT_Y;
                        else
-                               h += len*YIC;
+                               h += len*EM_UNIT_Y;
                }
        }
-       else if(item->type == ITEM_OPERATOR) {
-               /* operator */
-               uiItemOp *opitem= (uiItemOp*)item;
-
-               name= item->name;
-               if(!name)
-                       name= opitem->ot->name;
-
-               w= ui_text_icon_width(name, item->icon);
-               h= YIC;
-       }
        else {
                /* other */
                w= ui_text_icon_width(item->name, item->icon);
-               h= YIC;
+               h= EM_UNIT_Y;
        }
 
        if(r_w) *r_w= w;
@@ -535,7 +563,7 @@ void uiItemO(uiLayout *layout, char *name, int icon, char *opname)
 }
 
 /* RNA property items */
-void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index)
+void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int expand)
 {
        uiTemplate *template= layout->templates.last;
        uiItemRNA *rnaitem;
@@ -555,11 +583,12 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
        rnaitem->ptr= *ptr;
        rnaitem->prop= prop;
        rnaitem->index= index;
+       rnaitem->expand= expand;
 
        BLI_addtail(&template->items, rnaitem);
 }
 
-void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname)
+void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *propname, int expand)
 {
        PropertyRNA *prop;
 
@@ -572,7 +601,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop
                return;
        }
        
-       uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX);
+       uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, expand);
 }
 
 /* menu item */
@@ -617,11 +646,43 @@ void uiItemL(uiLayout *layout, char *name, int icon)
 
 /**************************** Template ***************************/
 
+/* single row layout */
+static void ui_layout_row(uiLayout *layout, uiBlock *block, uiTemplate *template)
+{
+       uiItem *item;
+       int tot=0, totw= 0, maxh= 0, itemw, itemh, x, w;
+
+       /* estimate total width of buttons */
+       for(item=template->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
+               totw += itemw;
+               maxh= MAX2(maxh, itemh);
+               tot++;
+       }
+
+       if(totw == 0)
+               return;
+       
+       /* create buttons starting from left */
+       x= 0;
+       w= layout->w - (tot-1)*BUTTON_SPACE_X;
+
+       for(item=template->items.first; item; item=item->next) {
+               ui_item_size(item, &itemw, &itemh);
+               itemw= ui_item_fit(itemw, x, totw, w, !item->next, UI_FIT_EXPAND);
+
+               ui_item_buts(block, item, layout->x+x, layout->y-itemh, itemw, itemh);
+               x += itemw+BUTTON_SPACE_X;
+       }
+
+       layout->y -= maxh;
+}
+
 /* multi-column layout */
-static void ui_layout_column(uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
+static void ui_layout_column(uiLayout *layout, uiBlock *block, uiTemplate *template)
 {
        uiItem *item;
-       int col, totcol= 0, colx, coly, colw, miny, itemw, itemh;
+       int col, totcol= 0, x, y, miny, itemw, itemh, w;
 
        /* compute number of columns */
        for(item=template->items.first; item; item=item->next)
@@ -630,69 +691,40 @@ static void ui_layout_column(uiLayout *layout, uiBlock *block, uiTemplate *templ
        if(totcol == 0)
                return;
        
-       colx= *x;
-       colw= (w - (totcol-1)*COLUMN_SPACE)/totcol;
-       miny= *y;
+       x= 0;
+       miny= 0;
+       w= layout->w - (totcol-1)*COLUMN_SPACE;
 
        /* create column per column */
        for(col=0; col<totcol; col++) {
-               coly= *y;
+               y= 0;
+
+               itemw= ui_item_fit(1, x, totcol, w, col == totcol-1, UI_FIT_EXPAND);
 
                for(item=template->items.first; item; item=item->next) {
                        if(item->slot != col)
                                continue;
 
-                       ui_item_size(item, &itemw, &itemh);
+                       ui_item_size(item, NULL, &itemh);
 
-                       coly -= itemh + BUTTON_SPACE_Y;
-                       ui_item_buts(block, item, colx, coly, colw, itemh);
+                       y -= itemh;
+                       ui_item_buts(block, item, layout->x+x, layout->y+y, itemw, itemh);
+                       y -= BUTTON_SPACE_Y;
                }
 
-               colx += colw + COLUMN_SPACE;
-               miny= MIN2(miny, coly);
-       }
-
-       *y= miny;
-}
-
-/* single row layout */
-static void ui_layout_row(uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
-{
-       uiItem *item;
-       int totw= 0, maxh= 0, itemw, itemh, leftx;
-
-       /* estimate total width of buttons */
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh);
-               totw += itemw;
-               maxh= MAX2(maxh, itemh);
-       }
-
-       if(totw == 0)
-               return;
-       
-       /* create buttons starting from left */
-       leftx= *x;
-
-       for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh);
-               if(totw < w)
-                       itemw= (itemw*w)/totw;
-               itemw= ui_item_fit(itemw, MAX2(totw, w), w);
-
-               ui_item_buts(block, item, leftx, *y-itemh, itemw, itemh);
-               leftx += itemw+BUTTON_SPACE_X;
+               x += itemw + COLUMN_SPACE;
+               miny= MIN2(miny, y);
        }
 
-       *y -= maxh;
+       layout->y += miny;
 }
 
 /* multi-column layout, automatically flowing to the next */
-static void ui_layout_column_flow(uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
+static void ui_layout_column_flow(uiLayout *layout, uiBlock *block, uiTemplate *template)
 {
        uiTemplateFlow *flow= (uiTemplateFlow*)template;
        uiItem *item;
-       int col, colx, coly, colw, colh, miny, itemw, itemh, maxw=0;
+       int col, x, y, w, emh, emy, miny, itemw, itemh, maxw=0;
        int toth, totcol, totitem;
 
        /* compute max needed width and total height */
@@ -701,108 +733,154 @@ static void ui_layout_column_flow(uiLayout *layout, uiBlock *block, uiTemplate *
        for(item=template->items.first; item; item=item->next) {
                ui_item_size(item, &itemw, &itemh);
                maxw= MAX2(maxw, itemw);
-               toth += itemh + BUTTON_SPACE_Y;
+               toth += itemh;
                totitem++;
        }
 
-       if(flow->columns <= 0) {
+       if(flow->number <= 0) {
                /* auto compute number of columns, not very good */
                if(maxw == 0)
                        return;
 
-               totcol= MIN2(w/maxw, 1);
-               totcol= MAX2(totcol, totitem);
+               totcol= MAX2(layout->emw/maxw, 1);
+               totcol= MIN2(totcol, totitem);
        }
        else
-               totcol= flow->columns;
+               totcol= flow->number;
 
        /* compute sizes */
-       colx= *x;
-       coly= *y;
-       colw= (w - (totcol-1)*COLUMN_SPACE)/totcol;
-       colh= toth/totcol;
-       miny= *y;
+       x= 0;
+       y= 0;
+       emy= 0;
+       miny= 0;
+
+       w= layout->w - totcol*(COLUMN_SPACE);
+       emh= toth/totcol;
 
        /* create column per column */
        col= 0;
        for(item=template->items.first; item; item=item->next) {
-               ui_item_size(item, &itemw, &itemh);
+               ui_item_size(item, NULL, &itemh);
+               itemw= ui_item_fit(1, x, totcol, w, col == totcol-1, UI_FIT_EXPAND);
        
-               coly -= itemh + BUTTON_SPACE_Y;
-               ui_item_buts(block, item, colx, coly, colw, itemh);
-
-               miny= MIN2(miny, coly);
-
-               if(coly <= *y - colh && col < totcol) {
-                       colx += colw + COLUMN_SPACE;
-                       coly= *y;
+               y -= itemh;
+               emy -= itemh;
+               ui_item_buts(block, item, layout->x+x, layout->y+y, itemw, itemh);
+               y -= BUTTON_SPACE_Y;
+               miny= MIN2(miny, y);
+
+               /* decide to go to next one */
+               if(col < totcol-1 && emy <= -emh) {
+                       x += itemw + COLUMN_SPACE;
+                       y= 0;
                        col++;
                }
        }
 
-       *y= miny;
+       layout->y += miny;
 }
 
+#if 0
 /* left-right layout, with buttons aligned on both sides */
-static void ui_layout_lr(uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
+static void ui_layout_split(uiLayout *layout, uiBlock *block, uiTemplate *template)
 {
        uiItem *item;
-       int totw= 0, maxh= 0, itemw, itemh, leftx, rightx;
+       int tot=0, totw= 0, maxh= 0, itemw, itemh, lx, rx, w;
 
        /* estimate total width of buttons */
        for(item=template->items.first; item; item=item->next) {
                ui_item_size(item, &itemw, &itemh);
                totw += itemw;
                maxh= MAX2(maxh, itemh);
+               tot++;
        }
 
        if(totw == 0)
                return;
        
        /* create buttons starting from left and right */
-       leftx= *x;
-       rightx= *x + w;
+       lx= 0;
+       rx= 0;
+       w= layout->w - BUTTON_SPACE_X*(tot-1) + BUTTON_SPACE_X;
 
        for(item=template->items.first; item; item=item->next) {
                ui_item_size(item, &itemw, &itemh);
-               itemw= ui_item_fit(itemw, totw+BUTTON_SPACE_X, w);
 
                if(item->slot == UI_TSLOT_LR_LEFT) {
-                       ui_item_buts(block, item, leftx, *y-itemh, itemw, itemh);
-                       leftx += itemw;
+                       itemw= ui_item_fit(itemw, lx, totw, w, 0, 0);
+                       ui_item_buts(block, item, layout->x+lx, layout->y-itemh, itemw, itemh);
+                       lx += itemw + BUTTON_SPACE_X;
                }
                else {
-                       rightx -= itemw;
-                       ui_item_buts(block, item, rightx, *y-itemh, itemw, itemh);
+                       itemw= ui_item_fit(itemw, totw + rx, totw, w, 0, 0);
+                       rx -= itemw + BUTTON_SPACE_X;
+                       ui_item_buts(block, item, layout->x+layout->w+rx, layout->y-itemh, itemw, itemh);
                }
        }
 
-       *y -= maxh;
+       layout->y -= maxh;
 }
+#endif
 
-/* element in a stack layout */
-static void ui_layout_stack(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
+/* split in columns */
+static void ui_layout_split(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
 {
-       uiTemplateStck *stack= (uiTemplateStck*)template;
-       int starty, startx;
+       uiTemplateSplt *split= (uiTemplateSplt*)template;
+       uiLayout *sublayout;
+       int a, x, y, miny, w= layout->w, h= layout->h, splitw;
+
+       x= 0;
+       y= 0;
+       miny= layout->y;
+
+       for(a=0; a<split->number; a++) {
+               sublayout= split->sublayout[a];
+
+               splitw= ui_item_fit(1, x, split->number, w, a == split->number-1, UI_FIT_EXPAND);
+               sublayout->x= layout->x + x;
+               sublayout->w= splitw;
+               sublayout->y= layout->y;
+               sublayout->h= h;
 
-       startx= *x;
-       starty= *y;
+               sublayout->emw= layout->emw/split->number;
+               sublayout->emh= layout->emh;
+
+               /* do layout for elements in sublayout */
+               ui_layout_end(C, block, sublayout, NULL, &y);
+               miny= MIN2(y, miny);
+
+               x += splitw + COLUMN_SPACE;
+       }
+
+       layout->y= miny;
+}
+
+/* element in a box layout */
+static void ui_layout_box(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
+{
+       uiTemplateBx *box= (uiTemplateBx*)template;
+       int starty, startx, w= layout->w, h= layout->h;
+
+       startx= layout->x;
+       starty= layout->y;
 
        /* some extra padding */
-       stack->sublayout->x= *x + STACK_SPACE;
-       stack->sublayout->w= w - 2*STACK_SPACE;
-       stack->sublayout->y= *y - STACK_SPACE;
-       stack->sublayout->h= h;
+       box->sublayout->x= layout->x + BOX_SPACE;
+       box->sublayout->w= w - 2*BOX_SPACE;
+       box->sublayout->y= layout->y - BOX_SPACE;
+       box->sublayout->h= h;
+
+       box->sublayout->emw= layout->emw;
+       box->sublayout->emh= layout->emh;
 
        /* do layout for elements in sublayout */
-       ui_layout_end(C, block, stack->sublayout, NULL, y);
+       ui_layout_end(C, block, box->sublayout, NULL, &layout->y);
 
        /* roundbox around the sublayout */
-       uiDefBut(block, ROUNDBOX, 0, "", startx, *y, w, starty - *y, NULL, 7.0, 0.0, 3, 20, "");
+       uiDefBut(block, ROUNDBOX, 0, "", startx, layout->y, w, starty - layout->y, NULL, 7.0, 0.0, 3, 20, "");
 }
 
-static void ui_layout_header_buttons(uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
+static void ui_layout_header_buttons(uiLayout *layout, uiBlock *block, uiTemplate *template)
 {
        uiItem *item;
        int itemw, itemh;
@@ -811,45 +889,54 @@ static void ui_layout_header_buttons(uiLayout *layout, uiBlock *block, uiTemplat
 
        for(item=template->items.first; item; item=item->next) {
                ui_item_size(item, &itemw, &itemh);
-               ui_item_buts(block, item, *x, *y, itemw, itemh);
-               *x += itemw;
+               ui_item_buts(block, item, layout->x, layout->y, itemw, itemh);
+               layout->x += itemw;
        }
 
        uiBlockEndAlign(block);
 }
 
-static void ui_layout_header_menus(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
+static void ui_layout_header_menus(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
 {
        ScrArea *sa= CTX_wm_area(C);
 
-       *x= ED_area_header_standardbuttons(C, block, *y);
+       layout->x= ED_area_header_standardbuttons(C, block, layout->y);
 
        if((sa->flag & HEADER_NO_PULLDOWN)==0) {
                uiBlockSetEmboss(block, UI_EMBOSSP);
-               ui_layout_header_buttons(layout, block, template, x, y, w, h);
+               ui_layout_header_buttons(layout, block, template);
        }
 
        uiBlockSetEmboss(block, UI_EMBOSS);
 }
 
-static void ui_layout_header_id(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
+static void ui_layout_header_id(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
 {
        uiTemplateHeadID *idtemplate= (uiTemplateHeadID*)template;
        PointerRNA idptr;
 
        idptr= RNA_pointer_get(&idtemplate->ptr, idtemplate->propname);
 
-       *x= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)idptr.data, ID_TXT, NULL, *x, *y,
-               idtemplate->func, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE);
+       layout->x= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)idptr.data, ID_TXT, NULL,
+               layout->x, layout->y, idtemplate->func,
+               UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE);
 }
 
 void ui_template_free(uiTemplate *template)
 {
        uiItem *item;
+       int a;
+
+       if(template->type == TEMPLATE_BOX) {
+               uiTemplateBx *box= (uiTemplateBx*)template;
+               ui_layout_free(box->sublayout);
+       }
+       if(template->type == TEMPLATE_SPLIT) {
+               uiTemplateSplt *split= (uiTemplateSplt*)template;
 
-       if(template->type == TEMPLATE_STACK) {
-               uiTemplateStck *stack= (uiTemplateStck*)template;
-               ui_layout_free(stack->sublayout);
+               for(a=0; a<split->number; a++)
+                       ui_layout_free(split->sublayout[a]);
+               MEM_freeN(split->sublayout);
        }
 
        for(item=template->items.first; item; item=item->next)
@@ -859,7 +946,7 @@ void ui_template_free(uiTemplate *template)
 }
 
 /* template create functions */
-void uiTemplateRow(uiLayout *layout)
+void uiLayoutRow(uiLayout *layout)
 {
        uiTemplate *template;
 
@@ -869,7 +956,7 @@ void uiTemplateRow(uiLayout *layout)
        BLI_addtail(&layout->templates, template);
 }
 
-void uiTemplateColumn(uiLayout *layout)
+void uiLayoutColumn(uiLayout *layout)
 {
        uiTemplate *template;
 
@@ -879,36 +966,64 @@ void uiTemplateColumn(uiLayout *layout)
        BLI_addtail(&layout->templates, template);
 }
 
-void uiTemplateColumnFlow(uiLayout *layout, int columns)
+void uiLayoutColumnFlow(uiLayout *layout, int number)
 {
        uiTemplateFlow *flow;
 
        flow= MEM_callocN(sizeof(uiTemplateFlow), "uiTemplateFlow");
        flow->template.type= TEMPLATE_COLUMN_FLOW;
-       flow->columns= columns;
+       flow->number= number;
        BLI_addtail(&layout->templates, flow);
 }
 
-void uiTemplateLeftRight(uiLayout *layout)
+uiLayout *uiLayoutBox(uiLayout *layout)
 {
-       uiTemplate *template;
+       uiTemplateBx *box;
 
-       template= MEM_callocN(sizeof(uiTemplate), "uiTemplate");
-       template->type= TEMPLATE_LR;
+       box= MEM_callocN(sizeof(uiTemplateBx), "uiTemplateBx");
+       box->template.type= TEMPLATE_BOX;
+       box->sublayout= uiLayoutBegin(layout->dir, 0, 0, 0, 0);
+       BLI_addtail(&layout->templates, box);
 
-       BLI_addtail(&layout->templates, template);
+       return box->sublayout;
+}
+
+void uiLayoutSplit(uiLayout *layout, int number, int lr)
+{
+       uiTemplateSplt *split;
+       int a;
+
+       split= MEM_callocN(sizeof(uiTemplateSplt), "uiTemplateSplt");
+       split->template.type= TEMPLATE_SPLIT;
+       split->number= number;
+       split->lr= lr;
+       split->sublayout= MEM_callocN(sizeof(uiLayout*)*number, "uiTemplateSpltSub");
+
+       for(a=0; a<number; a++)
+               split->sublayout[a]= uiLayoutBegin(layout->dir, 0, 0, 0, 0);
+
+       BLI_addtail(&layout->templates, split);
 }
 
-uiLayout *uiTemplateStack(uiLayout *layout)
+uiLayout *uiLayoutSub(uiLayout *layout, int n)
 {
-       uiTemplateStck *stack;
+       uiTemplate *template= layout->templates.last;
 
-       stack= MEM_callocN(sizeof(uiTemplateStck), "uiTemplateStck");
-       stack->template.type= TEMPLATE_STACK;
-       stack->sublayout= uiLayoutBegin(layout->dir, 0, 0, 0, 0);
-       BLI_addtail(&layout->templates, stack);
+       if(template) {
+               switch(template->type) {
+                       case TEMPLATE_SPLIT:
+                               if(n >= 0 && n < ((uiTemplateSplt*)template)->number)
+                                       return ((uiTemplateSplt*)template)->sublayout[n];
+                               break;
+                       case TEMPLATE_BOX:
+                               return ((uiTemplateBx*)template)->sublayout;
+                               break;
+                       default:
+                               break;
+               }
+       }
 
-       return stack->sublayout;
+       return NULL;
 }
 
 void uiTemplateHeaderMenus(uiLayout *layout)
@@ -967,46 +1082,55 @@ static void ui_layout_templates(const bContext *C, uiBlock *block, uiLayout *lay
 {
        uiTemplate *template;
 
-       for(template=layout->templates.first; template; template=template->next) {
-               if(template->color) {
-                       // XXX oldcolor= uiBlockGetCol(block);
-                       // XXX uiBlockSetCol(block, template->color);
+       if(layout->dir == UI_LAYOUT_HORIZONTAL) {
+               for(template=layout->templates.first; template; template=template->next) {
+                       switch(template->type) {
+                               case TEMPLATE_HEADER_MENUS:
+                                       ui_layout_header_menus(C, layout, block, template);
+                                       break;
+                               case TEMPLATE_HEADER_ID:
+                                       ui_layout_header_id(C, layout, block, template);
+                                       break;
+                               case TEMPLATE_HEADER_BUTTONS:
+                               default:
+                                       ui_layout_header_buttons(layout, block, template);
+                                       break;
+                       }
                }
 
-               switch(template->type) {
-                       case TEMPLATE_ROW:
-                               ui_layout_row(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-                       case TEMPLATE_COLUMN:
-                               ui_layout_column(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-                       case TEMPLATE_COLUMN_FLOW:
-                               ui_layout_column_flow(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-                       case TEMPLATE_LR:
-                               ui_layout_lr(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-                       case TEMPLATE_STACK:
-                               ui_layout_stack(C, layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-                       case TEMPLATE_HEADER_MENUS:
-                               ui_layout_header_menus(C, layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-                       case TEMPLATE_HEADER_BUTTONS:
-                               ui_layout_header_buttons(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-                       case TEMPLATE_HEADER_ID:
-                               ui_layout_header_id(C, layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
-                               break;
-               }
+               layout->x += TEMPLATE_SPACE;
+       }
+       else {
+               for(template=layout->templates.first; template; template=template->next) {
+                       if(template->color) {
+                               // XXX oldcolor= uiBlockGetCol(block);
+                               // XXX uiBlockSetCol(block, template->color);
+                       }
 
-// XXX                 if(template->color)
-// XXX                         uiBlockSetCol(block, oldcolor);
+                       switch(template->type) {
+                               case TEMPLATE_ROW:
+                                       ui_layout_row(layout, block, template);
+                                       break;
+                               case TEMPLATE_COLUMN_FLOW:
+                                       ui_layout_column_flow(layout, block, template);
+                                       break;
+                               case TEMPLATE_SPLIT:
+                                       ui_layout_split(C, layout, block, template);
+                                       break;
+                               case TEMPLATE_BOX:
+                                       ui_layout_box(C, layout, block, template);
+                                       break;
+                               case TEMPLATE_COLUMN:
+                               default:
+                                       ui_layout_column(layout, block, template);
+                                       break;
+                       }
+
+       // XXX  if(template->color)
+       // XXX          uiBlockSetCol(block, oldcolor);
 
-               if(layout->dir == UI_LAYOUT_HORIZONTAL)
-                       layout->x += TEMPLATE_SPACE;
-               else
                        layout->y -= TEMPLATE_SPACE;
+               }
        }
 }
 
@@ -1030,7 +1154,7 @@ void ui_layout_free(uiLayout *layout)
        MEM_freeN(layout);
 }
 
-uiLayout *uiLayoutBegin(int dir, int x, int y, int w, int h)
+uiLayout *uiLayoutBegin(int dir, int x, int y, int size, int em)
 {
        uiLayout *layout;
 
@@ -1039,8 +1163,15 @@ uiLayout *uiLayoutBegin(int dir, int x, int y, int w, int h)
        layout->dir= dir;
        layout->x= x;
        layout->y= y;
-       layout->w= w;
-       layout->h= h;
+
+       if(dir == UI_LAYOUT_HORIZONTAL) {
+               layout->h= size;
+               layout->emh= em*EM_UNIT_Y;
+       }
+       else {
+               layout->w= size;
+               layout->emw= em*EM_UNIT_X;
+       }
 
        return layout;
 }
@@ -1064,7 +1195,7 @@ void uiRegionPanelLayout(const bContext *C, ARegion *ar, int vertical, char *con
        PanelType *pt;
        Panel *panel;
        float col[3];
-       int xco, yco, x=PNL_DIST, y=-PNL_HEADER-PNL_DIST, w;
+       int xco, yco, x=PNL_DIST, y=-PNL_HEADER-PNL_DIST, w, em;
 
        // XXX this only hides cruft
 
@@ -1086,21 +1217,25 @@ void uiRegionPanelLayout(const bContext *C, ARegion *ar, int vertical, char *con
                if(pt->draw && (!pt->poll || pt->poll(C))) {
                        block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS);
                        
-                       if(vertical)
+                       if(vertical) {
                                w= (ar->type->minsizex)? ar->type->minsizex-12: block->aspect*ar->winx-12;
-                       else
+                               em= (ar->type->minsizex)? 10: 20;
+                       }
+                       else {
                                w= (ar->type->minsizex)? ar->type->minsizex-12: UI_PANEL_WIDTH-12;
+                               em= (ar->type->minsizex)? 10: 20;
+                       }
 
                        if(uiNewPanel(C, ar, block, pt->name, pt->name, x, y, w, 0)) {
                                panel= uiPanelFromBlock(block);
                                panel->type= pt;
-                               panel->layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, x, y, w, 0);
+                               panel->layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, x, y, w, em);
 
                                pt->draw(C, panel);
 
                                uiLayoutEnd(C, block, panel->layout, &xco, &yco);
                                panel->layout= NULL;
-                               uiNewPanelHeight(block, y - yco + 6);
+                               uiNewPanelHeight(block, y - yco + 12);
                        }
                        else {
                                w= PNL_HEADER;
@@ -1150,7 +1285,7 @@ void uiRegionHeaderLayout(const bContext *C, ARegion *ar)
        /* draw all headers types */
        for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
                block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
-               layout= uiLayoutBegin(UI_LAYOUT_HORIZONTAL, xco, yco, 0, 24);
+               layout= uiLayoutBegin(UI_LAYOUT_HORIZONTAL, xco, yco, 24, 1);
 
                if(ht->draw)
                        ht->draw(C, layout);
index d91dadf58f788db4b301990994f02983d7f2129b..fdda139ff9b6b7dd8b1f75f51e0ce6117455b6a8 100644 (file)
@@ -299,7 +299,7 @@ int uiDefAutoButsRNA(const bContext *C, uiBlock *block, PointerRNA *ptr)
 
        layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, x, y, DEF_BUT_WIDTH*2, 0);
 
-       uiTemplateColumn(layout);
+       uiLayoutColumn(layout);
        uiItemL(layout, (char*)RNA_struct_ui_name(ptr), 0);
 
        iterprop= RNA_struct_iterator_property(ptr);
@@ -311,13 +311,11 @@ int uiDefAutoButsRNA(const bContext *C, uiBlock *block, PointerRNA *ptr)
                if(strcmp(RNA_property_identifier(ptr, prop), "rna_type") == 0)
                        continue;
 
-               uiTemplateColumn(layout);
+               uiLayoutSplit(layout, 2, 0);
 
                name= (char*)RNA_property_ui_name(ptr, prop);
-               uiTemplateSlot(layout, UI_TSLOT_COLUMN_1);
-               uiItemL(layout, name, 0);
-               uiTemplateSlot(layout, UI_TSLOT_COLUMN_2);
-               uiItemR(layout, "", 0, ptr, (char*)RNA_property_identifier(ptr, prop));
+               uiItemL(uiLayoutSub(layout, 0), name, 0);
+               uiItemFullR(uiLayoutSub(layout, 1), "", 0, ptr, prop, -1, 0);
        }
 
        RNA_property_collection_end(&iter);
index 0a8f5e9be3c8e3e500e9514e4c0a30d8a1b38728..be3a57afbf5b3e49d334355391bedaa25a2c9c60 100644 (file)
@@ -381,10 +381,10 @@ static void text_header_draw(const bContext *C, uiLayout *layout)
        }
 
        uiTemplateHeaderButtons(layout);
-       uiItemR(layout, "", ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers");
-       uiItemR(layout, "", ICON_WORDWRAP_OFF, &spaceptr, "word_wrap");
-       uiItemR(layout, "", ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight");
-       // XXX uiItemR(layout, "", ICON_SCRIPTPLUGINS, &spaceptr, "do_python_plugins");
+       uiItemR(layout, "", ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers", 0);
+       uiItemR(layout, "", ICON_WORDWRAP_OFF, &spaceptr, "word_wrap", 0);
+       uiItemR(layout, "", ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight", 0);
+       // XXX uiItemR(layout, "", ICON_SCRIPTPLUGINS, &spaceptr, "do_python_plugins", 0);
 
        uiTemplateHeaderID(layout, &spaceptr, "text",
                UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE,
@@ -438,14 +438,14 @@ static void text_properties_panel_draw(const bContext *C, Panel *panel)
        
        RNA_pointer_create(&sc->id, &RNA_SpaceTextEditor, st, &spaceptr);
 
-       uiTemplateColumn(layout);
-       uiItemR(layout, NULL, ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers");
-       uiItemR(layout, NULL, ICON_WORDWRAP_OFF, &spaceptr, "word_wrap");
-       uiItemR(layout, NULL, ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight");
+       uiLayoutColumn(layout);
+       uiItemR(layout, NULL, ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers", 0);
+       uiItemR(layout, NULL, ICON_WORDWRAP_OFF, &spaceptr, "word_wrap", 0);
+       uiItemR(layout, NULL, ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight", 0);
 
-       uiTemplateColumn(layout);
-       uiItemR(layout, NULL, 0, &spaceptr, "font_size");
-       uiItemR(layout, NULL, 0, &spaceptr, "tab_width");
+       uiLayoutColumn(layout);
+       uiItemR(layout, NULL, 0, &spaceptr, "font_size", 0);
+       uiItemR(layout, NULL, 0, &spaceptr, "tab_width", 0);
 }
 
 static void text_find_panel_draw(const bContext *C, Panel *panel)
@@ -458,31 +458,27 @@ static void text_find_panel_draw(const bContext *C, Panel *panel)
        RNA_pointer_create(&sc->id, &RNA_SpaceTextEditor, st, &spaceptr);
 
        /* find */
-       uiTemplateLeftRight(layout);
-       uiTemplateSlot(layout, UI_TSLOT_LR_LEFT);
-       uiItemR(layout, "", 0, &spaceptr, "find_text");
-       uiTemplateSlot(layout, UI_TSLOT_LR_RIGHT);
+       uiLayoutRow(layout);
+       uiItemR(layout, "", 0, &spaceptr, "find_text", 0);
        uiItemO(layout, "", ICON_TEXT, "TEXT_OT_find_set_selected");
-       uiTemplateColumn(layout);
+       uiLayoutColumn(layout);
        uiItemO(layout, NULL, 0, "TEXT_OT_find");
 
        /* replace */
-       uiTemplateLeftRight(layout);
-       uiTemplateSlot(layout, UI_TSLOT_LR_LEFT);
-       uiItemR(layout, "", 0, &spaceptr, "replace_text");
-       uiTemplateSlot(layout, UI_TSLOT_LR_RIGHT);
+       uiLayoutRow(layout);
+       uiItemR(layout, "", 0, &spaceptr, "replace_text", 0);
        uiItemO(layout, "", ICON_TEXT, "TEXT_OT_replace_set_selected");
-       uiTemplateColumn(layout);
+       uiLayoutColumn(layout);
        uiItemO(layout, NULL, 0, "TEXT_OT_replace");
 
        /* mark */
-       uiTemplateColumn(layout);
+       uiLayoutColumn(layout);
        uiItemO(layout, NULL, 0, "TEXT_OT_mark_all");
 
        /* settings */
-       uiTemplateColumnFlow(layout, 2);
-       uiItemR(layout, "Wrap", 0, &spaceptr, "find_wrap");
-       uiItemR(layout, "All", 0, &spaceptr, "find_all");
+       uiLayoutColumnFlow(layout, 0);
+       uiItemR(layout, "Wrap", 0, &spaceptr, "find_wrap", 0);
+       uiItemR(layout, "All", 0, &spaceptr, "find_all", 0);
 }
 
 void text_properties_register(ARegionType *art)