UI:
* 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.
This commit is contained in:
@@ -11,7 +11,7 @@ class OBJECT_PT_transform(bpy.types.Panel):
|
|||||||
if not ob:
|
if not ob:
|
||||||
return
|
return
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(ob, "location")
|
layout.itemR(ob, "location")
|
||||||
layout.itemR(ob, "rotation")
|
layout.itemR(ob, "rotation")
|
||||||
layout.itemR(ob, "scale")
|
layout.itemR(ob, "scale")
|
||||||
@@ -27,24 +27,24 @@ class OBJECT_PT_groups(bpy.types.Panel):
|
|||||||
if not ob:
|
if not ob:
|
||||||
return
|
return
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(ob, "pass_index")
|
layout.itemR(ob, "pass_index")
|
||||||
layout.itemR(ob, "parent")
|
layout.itemR(ob, "parent")
|
||||||
|
|
||||||
# layout.template_left_right()
|
# layout.left_right()
|
||||||
# layout.itemO("OBJECT_OT_add_group");
|
# layout.itemO("OBJECT_OT_add_group");
|
||||||
|
|
||||||
for group in bpy.data.groups:
|
for group in bpy.data.groups:
|
||||||
if ob in group.objects:
|
if ob in group.objects:
|
||||||
sublayout = layout.template_stack()
|
sub = layout.box()
|
||||||
|
|
||||||
sublayout.template_left_right()
|
sub.split(number=2, lr=True)
|
||||||
sublayout.itemR(group, "name")
|
sub.sub(0).itemR(group, "name")
|
||||||
# sublayout.itemO("OBJECT_OT_remove_group")
|
# sub.sub(1).itemO("OBJECT_OT_remove_group")
|
||||||
|
|
||||||
sublayout.template_row()
|
sub.row()
|
||||||
sublayout.itemR(group, "layer")
|
sub.itemR(group, "layer")
|
||||||
sublayout.itemR(group, "dupli_offset")
|
sub.itemR(group, "dupli_offset")
|
||||||
|
|
||||||
class OBJECT_PT_display(bpy.types.Panel):
|
class OBJECT_PT_display(bpy.types.Panel):
|
||||||
__label__ = "Display"
|
__label__ = "Display"
|
||||||
@@ -57,11 +57,11 @@ class OBJECT_PT_display(bpy.types.Panel):
|
|||||||
if not ob:
|
if not ob:
|
||||||
return
|
return
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(ob, "max_draw_type", text="Type")
|
layout.itemR(ob, "max_draw_type", text="Type")
|
||||||
layout.itemR(ob, "draw_bounds_type", text="Bounds")
|
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_name", text="Name")
|
||||||
layout.itemR(ob, "draw_axis", text="Axis")
|
layout.itemR(ob, "draw_axis", text="Axis")
|
||||||
layout.itemR(ob, "draw_wire", text="Wire")
|
layout.itemR(ob, "draw_wire", text="Wire")
|
||||||
@@ -80,11 +80,11 @@ class OBJECT_PT_duplication(bpy.types.Panel):
|
|||||||
if not ob:
|
if not ob:
|
||||||
return
|
return
|
||||||
|
|
||||||
layout.template_column()
|
layout.column()
|
||||||
layout.itemR(ob, "dupli_type", text="")
|
layout.itemR(ob, "dupli_type", text="", expand=True)
|
||||||
|
|
||||||
if ob.dupli_type == "FRAMES":
|
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_start", text="Start:")
|
||||||
layout.itemR(ob, "dupli_frames_end", text="End:")
|
layout.itemR(ob, "dupli_frames_end", text="End:")
|
||||||
layout.itemR(ob, "dupli_frames_on", text="On:")
|
layout.itemR(ob, "dupli_frames_on", text="On:")
|
||||||
@@ -101,21 +101,23 @@ class OBJECT_PT_animation(bpy.types.Panel):
|
|||||||
if not ob:
|
if not ob:
|
||||||
return
|
return
|
||||||
|
|
||||||
layout.template_column()
|
layout.split(number=2)
|
||||||
|
|
||||||
layout.template_slot("COLUMN_1")
|
sub = layout.sub(0)
|
||||||
layout.itemL(text="Time Offset:")
|
sub.column()
|
||||||
layout.itemR(ob, "time_offset_edit", text="Edit")
|
sub.itemL(text="Time Offset:")
|
||||||
layout.itemR(ob, "time_offset_particle", text="Particle")
|
sub.itemR(ob, "time_offset_edit", text="Edit")
|
||||||
layout.itemR(ob, "time_offset_parent", text="Parent")
|
sub.itemR(ob, "time_offset_particle", text="Particle")
|
||||||
layout.itemR(ob, "slow_parent")
|
sub.itemR(ob, "time_offset_parent", text="Parent")
|
||||||
layout.itemR(ob, "time_offset", text="Offset:")
|
sub.itemR(ob, "slow_parent")
|
||||||
|
sub.itemR(ob, "time_offset", text="Offset:")
|
||||||
|
|
||||||
layout.template_slot("COLUMN_2")
|
sub = layout.sub(1)
|
||||||
layout.itemL(text="Tracking:")
|
sub.column()
|
||||||
layout.itemR(ob, "track_axis", text="Axis")
|
sub.itemL(text="Tracking:")
|
||||||
layout.itemR(ob, "up_axis", text="Up Axis")
|
sub.itemR(ob, "track_axis", text="Axis")
|
||||||
layout.itemR(ob, "track_rotation", text="Rotation")
|
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_transform, "BUTTONS_WINDOW", "WINDOW")
|
||||||
bpy.ui.addPanel(OBJECT_PT_groups, "BUTTONS_WINDOW", "WINDOW")
|
bpy.ui.addPanel(OBJECT_PT_groups, "BUTTONS_WINDOW", "WINDOW")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class RENDER_PT_shading(bpy.types.Panel):
|
|||||||
|
|
||||||
rd = scene.render_data
|
rd = scene.render_data
|
||||||
|
|
||||||
layout.template_column_flow(2)
|
layout.column_flow()
|
||||||
layout.itemR(rd, "render_shadows", text="Shadows")
|
layout.itemR(rd, "render_shadows", text="Shadows")
|
||||||
layout.itemR(rd, "render_sss", text="SSS")
|
layout.itemR(rd, "render_sss", text="SSS")
|
||||||
layout.itemR(rd, "render_envmaps", text="EnvMap")
|
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, "render_raytracing", text="Ray Tracing")
|
||||||
layout.itemR(rd, "octree_resolution")
|
layout.itemR(rd, "octree_resolution")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "alpha_mode")
|
layout.itemR(rd, "alpha_mode")
|
||||||
|
|
||||||
class RENDER_PT_image(bpy.types.Panel):
|
class RENDER_PT_image(bpy.types.Panel):
|
||||||
@@ -38,13 +38,13 @@ class RENDER_PT_image(bpy.types.Panel):
|
|||||||
|
|
||||||
rd = scene.render_data
|
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="SizeX")
|
||||||
layout.itemR(rd, "resolution_x", text="SizeY")
|
layout.itemR(rd, "resolution_x", text="SizeY")
|
||||||
layout.itemR(rd, "pixel_aspect_x", text="AspX")
|
layout.itemR(rd, "pixel_aspect_x", text="AspX")
|
||||||
layout.itemR(rd, "pixel_aspect_y", text="AspY")
|
layout.itemR(rd, "pixel_aspect_y", text="AspY")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "crop_to_border")
|
layout.itemR(rd, "crop_to_border")
|
||||||
|
|
||||||
class RENDER_PT_antialiasing(bpy.types.Panel):
|
class RENDER_PT_antialiasing(bpy.types.Panel):
|
||||||
@@ -60,7 +60,7 @@ class RENDER_PT_antialiasing(bpy.types.Panel):
|
|||||||
|
|
||||||
rd = scene.render_data
|
rd = scene.render_data
|
||||||
|
|
||||||
layout.template_column_flow(2)
|
layout.column_flow()
|
||||||
layout.itemR(rd, "antialiasing", text="Enable")
|
layout.itemR(rd, "antialiasing", text="Enable")
|
||||||
layout.itemR(rd, "antialiasing_samples", text="Samples")
|
layout.itemR(rd, "antialiasing_samples", text="Samples")
|
||||||
layout.itemR(rd, "pixel_filter")
|
layout.itemR(rd, "pixel_filter")
|
||||||
@@ -79,42 +79,42 @@ class RENDER_PT_render(bpy.types.Panel):
|
|||||||
|
|
||||||
rd = scene.render_data
|
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="RENDER", icon=0) # ICON_SCENE
|
||||||
#layout.itemO("SCREEN_OT_render", text="ANIM", icon=0) # "anim", 1
|
#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, "start_frame", text="Start")
|
||||||
layout.itemR(scene, "end_frame", text="End")
|
layout.itemR(scene, "end_frame", text="End")
|
||||||
layout.itemR(scene, "current_frame", text="Frame")
|
layout.itemR(scene, "current_frame", text="Frame")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "do_composite")
|
layout.itemR(rd, "do_composite")
|
||||||
layout.itemR(rd, "do_sequence")
|
layout.itemR(rd, "do_sequence")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemL(text="General")
|
layout.itemL(text="General")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "resolution_percentage", text="Size ")
|
layout.itemR(rd, "resolution_percentage", text="Size ")
|
||||||
layout.itemR(rd, "dither_intensity")
|
layout.itemR(rd, "dither_intensity")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "parts_x")
|
layout.itemR(rd, "parts_x")
|
||||||
layout.itemR(rd, "parts_y")
|
layout.itemR(rd, "parts_y")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "threads")
|
layout.itemR(rd, "threads")
|
||||||
layout.itemR(rd, "threads_mode")
|
layout.itemR(rd, "threads_mode")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "fields", text="Fields")
|
layout.itemR(rd, "fields", text="Fields")
|
||||||
layout.itemR(rd, "field_order", text="Order")
|
layout.itemR(rd, "field_order", text="Order")
|
||||||
layout.itemR(rd, "fields_still", text="Still")
|
layout.itemR(rd, "fields_still", text="Still")
|
||||||
|
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemL(text="Extra:")
|
layout.itemL(text="Extra:")
|
||||||
layout.template_row()
|
layout.row()
|
||||||
layout.itemR(rd, "border", text="Border Render")
|
layout.itemR(rd, "border", text="Border Render")
|
||||||
layout.itemR(rd, "panorama")
|
layout.itemR(rd, "panorama")
|
||||||
|
|
||||||
|
|||||||
@@ -557,37 +557,24 @@ uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, cha
|
|||||||
|
|
||||||
typedef struct uiLayout uiLayout;
|
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 uiLayoutContext(uiLayout *layout, int opcontext);
|
||||||
void uiLayoutEnd(const struct bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y);
|
void uiLayoutEnd(const struct bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y);
|
||||||
|
|
||||||
/* vertical button templates */
|
/* layout specifiers */
|
||||||
#define UI_TSLOT_COLUMN_1 0
|
void uiLayoutRow(uiLayout *layout);
|
||||||
#define UI_TSLOT_COLUMN_2 1
|
void uiLayoutColumn(uiLayout *layout);
|
||||||
#define UI_TSLOT_COLUMN_3 2
|
void uiLayoutColumnFlow(uiLayout *layout, int number);
|
||||||
#define UI_TSLOT_COLUMN_4 3
|
void uiLayoutSplit(uiLayout *layout, int number, int lr);
|
||||||
#define UI_TSLOT_COLUMN_5 4
|
uiLayout *uiLayoutBox(uiLayout *layout);
|
||||||
#define UI_TSLOT_COLUMN_MAX 5
|
uiLayout *uiLayoutSub(uiLayout *layout, int n);
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
|
/* templates */
|
||||||
void uiTemplateHeaderMenus(uiLayout *layout);
|
void uiTemplateHeaderMenus(uiLayout *layout);
|
||||||
void uiTemplateHeaderButtons(uiLayout *layout);
|
void uiTemplateHeaderButtons(uiLayout *layout);
|
||||||
void uiTemplateHeaderID(uiLayout *layout, struct PointerRNA *ptr, char *propname, int flag, uiIDPoinFunc func);
|
void uiTemplateHeaderID(uiLayout *layout, struct PointerRNA *ptr, char *propname, int flag, uiIDPoinFunc func);
|
||||||
void uiTemplateSetColor(uiLayout *layout, int color);
|
void uiTemplateSetColor(uiLayout *layout, int color);
|
||||||
|
|
||||||
void uiTemplateSlot(uiLayout *layout, int slot);
|
|
||||||
|
|
||||||
/* items */
|
/* items */
|
||||||
void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
|
void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
|
||||||
void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
|
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 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 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 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);
|
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);
|
void uiItemL(uiLayout *layout, char *name, int icon);
|
||||||
|
|
||||||
|
|||||||
@@ -45,39 +45,32 @@ void RNA_api_ui_layout(StructRNA *srna)
|
|||||||
FunctionRNA *func;
|
FunctionRNA *func;
|
||||||
PropertyRNA *parm;
|
PropertyRNA *parm;
|
||||||
|
|
||||||
static EnumPropertyItem slot_items[]= {
|
/* simple layout specifiers */
|
||||||
{0, "DEFAULT", "Default", ""},
|
func= RNA_def_function(srna, "row", "uiLayoutRow");
|
||||||
{UI_TSLOT_COLUMN_1, "COLUMN_1", "Column 1", ""},
|
func= RNA_def_function(srna, "column", "uiLayoutColumn");
|
||||||
{UI_TSLOT_COLUMN_2, "COLUMN_2", "Column 2", ""},
|
func= RNA_def_function(srna, "column_flow", "uiLayoutColumnFlow");
|
||||||
{UI_TSLOT_COLUMN_3, "COLUMN_3", "Column 3", ""},
|
parm= RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic.", 0, INT_MAX);
|
||||||
{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}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* templates */
|
/* box layout */
|
||||||
func= RNA_def_function(srna, "template_row", "uiTemplateRow");
|
func= RNA_def_function(srna, "box", "uiLayoutBox");
|
||||||
func= RNA_def_function(srna, "template_column", "uiTemplateColumn");
|
parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
|
||||||
func= RNA_def_function(srna, "template_left_right", "uiTemplateLeftRight");
|
RNA_def_function_return(func, parm);
|
||||||
|
|
||||||
func= RNA_def_function(srna, "template_column_flow", "uiTemplateColumnFlow");
|
/* split layout */
|
||||||
parm= RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns.", 0, INT_MAX);
|
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.");
|
||||||
|
|
||||||
|
/* 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);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
|
parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
|
||||||
func= RNA_def_function(srna, "template_stack", "uiTemplateStack");
|
|
||||||
parm= RNA_def_pointer(func, "sub_layout", "UILayout", "", "Sub-layout to put stack items in.");
|
|
||||||
RNA_def_function_return(func, parm);
|
RNA_def_function_return(func, parm);
|
||||||
|
|
||||||
func= RNA_def_function(srna, "template_header_menus", "uiTemplateHeaderMenus");
|
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_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 */
|
/* items */
|
||||||
func= RNA_def_function(srna, "itemR", "uiItemR");
|
func= RNA_def_function(srna, "itemR", "uiItemR");
|
||||||
api_ui_item_common(func);
|
api_ui_item_common(func);
|
||||||
@@ -85,6 +78,7 @@ void RNA_api_ui_layout(StructRNA *srna)
|
|||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||||
parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
|
parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
|
||||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
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");
|
func= RNA_def_function(srna, "itemO", "uiItemO");
|
||||||
api_ui_item_common(func);
|
api_ui_item_common(func);
|
||||||
|
|||||||
@@ -40,12 +40,15 @@
|
|||||||
|
|
||||||
#define COLUMN_SPACE 5
|
#define COLUMN_SPACE 5
|
||||||
#define TEMPLATE_SPACE 5
|
#define TEMPLATE_SPACE 5
|
||||||
#define STACK_SPACE 5
|
#define BOX_SPACE 5
|
||||||
#define BUTTON_SPACE_X 5
|
#define BUTTON_SPACE_X 5
|
||||||
#define BUTTON_SPACE_Y 2
|
#define BUTTON_SPACE_Y 2
|
||||||
|
|
||||||
#define RNA_NO_INDEX -1
|
#define RNA_NO_INDEX -1
|
||||||
|
|
||||||
|
#define EM_UNIT_X XIC
|
||||||
|
#define EM_UNIT_Y YIC
|
||||||
|
|
||||||
/* Item */
|
/* Item */
|
||||||
|
|
||||||
typedef enum uiItemType {
|
typedef enum uiItemType {
|
||||||
@@ -75,6 +78,7 @@ typedef struct uiItemRNA {
|
|||||||
PointerRNA ptr;
|
PointerRNA ptr;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
int index;
|
int index;
|
||||||
|
int expand;
|
||||||
} uiItemRNA;
|
} uiItemRNA;
|
||||||
|
|
||||||
typedef struct uiItemOp {
|
typedef struct uiItemOp {
|
||||||
@@ -97,8 +101,8 @@ typedef enum uiTemplateType {
|
|||||||
TEMPLATE_ROW,
|
TEMPLATE_ROW,
|
||||||
TEMPLATE_COLUMN,
|
TEMPLATE_COLUMN,
|
||||||
TEMPLATE_COLUMN_FLOW,
|
TEMPLATE_COLUMN_FLOW,
|
||||||
TEMPLATE_LR,
|
TEMPLATE_SPLIT,
|
||||||
TEMPLATE_STACK,
|
TEMPLATE_BOX,
|
||||||
|
|
||||||
TEMPLATE_HEADER_MENUS,
|
TEMPLATE_HEADER_MENUS,
|
||||||
TEMPLATE_HEADER_BUTTONS,
|
TEMPLATE_HEADER_BUTTONS,
|
||||||
@@ -115,13 +119,20 @@ typedef struct uiTemplate {
|
|||||||
|
|
||||||
typedef struct uiTemplateFlow {
|
typedef struct uiTemplateFlow {
|
||||||
uiTemplate template;
|
uiTemplate template;
|
||||||
int columns;
|
int number;
|
||||||
} uiTemplateFlow;
|
} uiTemplateFlow;
|
||||||
|
|
||||||
typedef struct uiTemplateStck {
|
typedef struct uiTemplateSplt {
|
||||||
|
uiTemplate template;
|
||||||
|
int number;
|
||||||
|
int lr;
|
||||||
|
uiLayout **sublayout;
|
||||||
|
} uiTemplateSplt;
|
||||||
|
|
||||||
|
typedef struct uiTemplateBx {
|
||||||
uiTemplate template;
|
uiTemplate template;
|
||||||
uiLayout *sublayout;
|
uiLayout *sublayout;
|
||||||
} uiTemplateStck;
|
} uiTemplateBx;
|
||||||
|
|
||||||
typedef struct uiTemplateHeadID {
|
typedef struct uiTemplateHeadID {
|
||||||
uiTemplate template;
|
uiTemplate template;
|
||||||
@@ -139,6 +150,7 @@ struct uiLayout {
|
|||||||
int opcontext;
|
int opcontext;
|
||||||
int dir;
|
int dir;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
|
int emw, emh;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ui_layout_free(uiLayout *layout);
|
void ui_layout_free(uiLayout *layout);
|
||||||
@@ -146,12 +158,28 @@ void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x,
|
|||||||
|
|
||||||
/************************** Item ***************************/
|
/************************** Item ***************************/
|
||||||
|
|
||||||
static int ui_item_fit(int item, int all, int available)
|
#define UI_FIT_EXPAND 1
|
||||||
{
|
|
||||||
if(all > available)
|
|
||||||
return (item*available)/all;
|
|
||||||
|
|
||||||
return all;
|
static int ui_item_fit(int item, int pos, int all, int available, int last, int flag)
|
||||||
|
{
|
||||||
|
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 */
|
/* 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);
|
name= (char*)RNA_property_ui_name(&rnaitem->ptr, rnaitem->prop);
|
||||||
|
|
||||||
if(strcmp(name, "") != 0)
|
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 */
|
/* create buttons */
|
||||||
uiBlockBeginAlign(block);
|
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 */
|
/* special check for layer layout */
|
||||||
int butw, buth;
|
int butw, buth;
|
||||||
|
|
||||||
butw= ui_item_fit(XIC, XIC*10 + BUTTON_SPACE_X, w);
|
butw= ui_item_fit(EM_UNIT_X, 0, EM_UNIT_X*10 + BUTTON_SPACE_X, w, 0, UI_FIT_EXPAND);
|
||||||
buth= MIN2(YIC, butw);
|
buth= MIN2(EM_UNIT_Y, butw);
|
||||||
|
|
||||||
y += 2*(YIC - buth);
|
y += 2*(EM_UNIT_Y - buth);
|
||||||
|
|
||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
for(a=0; a<5; a++)
|
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;
|
col= a%len;
|
||||||
row= 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)) {
|
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';
|
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 {
|
else {
|
||||||
/* default array layout */
|
/* default array layout */
|
||||||
for(a=0; a<len; a++)
|
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);
|
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 */
|
/* create label + button for RNA property */
|
||||||
static void ui_item_with_label(uiBlock *block, uiItemRNA *rnaitem, int x, int y, int w, int h)
|
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 */
|
/* array property */
|
||||||
if(rnaitem->index == RNA_NO_INDEX && len > 0)
|
if(rnaitem->index == RNA_NO_INDEX && len > 0)
|
||||||
ui_item_array(block, rnaitem, len, x, y, w, h);
|
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 */
|
/* property with separate label */
|
||||||
else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER)
|
else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER)
|
||||||
ui_item_with_label(block, rnaitem, x, y, w, h);
|
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)
|
static int ui_text_icon_width(char *name, int icon)
|
||||||
{
|
{
|
||||||
if(icon && name && strcmp(name, "") == 0)
|
if(icon && name && strcmp(name, "") == 0)
|
||||||
return XIC; /* icon only */
|
return EM_UNIT_X; /* icon only */
|
||||||
else if(icon && name)
|
else if(icon)
|
||||||
return XIC + GetButStringLength((char*)name); /* icon + text */
|
return 10*EM_UNIT_X; /* icon + text */
|
||||||
else if(name)
|
|
||||||
return GetButStringLength((char*)name); /* text only */
|
|
||||||
else
|
else
|
||||||
return 0;
|
return 10*EM_UNIT_X; /* text only */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* estimated size of an item */
|
/* estimated size of an item */
|
||||||
static void ui_item_size(uiItem *item, int *r_w, int *r_h)
|
static void ui_item_size(uiItem *item, int *r_w, int *r_h)
|
||||||
{
|
{
|
||||||
char *name;
|
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
if(item->type == ITEM_RNA_PROPERTY) {
|
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;
|
PropertySubType subtype;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
name= item->name;
|
w= ui_text_icon_width(item->name, item->icon);
|
||||||
if(!name)
|
h= EM_UNIT_Y;
|
||||||
name= (char*)RNA_property_ui_name(&rnaitem->ptr, rnaitem->prop);
|
|
||||||
|
|
||||||
w= ui_text_icon_width(name, item->icon);
|
|
||||||
h= YIC;
|
|
||||||
|
|
||||||
/* arbitrary extended width by type */
|
/* arbitrary extended width by type */
|
||||||
type= RNA_property_type(&rnaitem->ptr, rnaitem->prop);
|
type= RNA_property_type(&rnaitem->ptr, rnaitem->prop);
|
||||||
subtype= RNA_property_subtype(&rnaitem->ptr, rnaitem->prop);
|
subtype= RNA_property_subtype(&rnaitem->ptr, rnaitem->prop);
|
||||||
len= RNA_property_array_length(&rnaitem->ptr, rnaitem->prop);
|
len= RNA_property_array_length(&rnaitem->ptr, rnaitem->prop);
|
||||||
|
|
||||||
if(type == PROP_BOOLEAN && !item->icon)
|
if(type == PROP_STRING)
|
||||||
w += XIC;
|
w += 10*EM_UNIT_X;
|
||||||
else if(type == PROP_INT || type == PROP_FLOAT)
|
|
||||||
w += 2*XIC;
|
|
||||||
else if(type == PROP_STRING)
|
|
||||||
w += 8*XIC;
|
|
||||||
|
|
||||||
/* increase height for arrays */
|
/* increase height for arrays */
|
||||||
if(rnaitem->index == RNA_NO_INDEX && len > 0) {
|
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;
|
h= 0;
|
||||||
|
|
||||||
if(type == PROP_BOOLEAN && len == 20)
|
if(type == PROP_BOOLEAN && len == 20)
|
||||||
h += 2*YIC;
|
h += 2*EM_UNIT_Y;
|
||||||
else if(subtype == PROP_MATRIX)
|
else if(subtype == PROP_MATRIX)
|
||||||
h += ceil(sqrt(len))*YIC;
|
h += ceil(sqrt(len))*EM_UNIT_Y;
|
||||||
else
|
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 {
|
else {
|
||||||
/* other */
|
/* other */
|
||||||
w= ui_text_icon_width(item->name, item->icon);
|
w= ui_text_icon_width(item->name, item->icon);
|
||||||
h= YIC;
|
h= EM_UNIT_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(r_w) *r_w= w;
|
if(r_w) *r_w= w;
|
||||||
@@ -535,7 +563,7 @@ void uiItemO(uiLayout *layout, char *name, int icon, char *opname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* RNA property items */
|
/* 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;
|
uiTemplate *template= layout->templates.last;
|
||||||
uiItemRNA *rnaitem;
|
uiItemRNA *rnaitem;
|
||||||
@@ -555,11 +583,12 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
|
|||||||
rnaitem->ptr= *ptr;
|
rnaitem->ptr= *ptr;
|
||||||
rnaitem->prop= prop;
|
rnaitem->prop= prop;
|
||||||
rnaitem->index= index;
|
rnaitem->index= index;
|
||||||
|
rnaitem->expand= expand;
|
||||||
|
|
||||||
BLI_addtail(&template->items, rnaitem);
|
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;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
@@ -572,7 +601,7 @@ void uiItemR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, char *prop
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX);
|
uiItemFullR(layout, name, icon, ptr, prop, RNA_NO_INDEX, expand);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* menu item */
|
/* menu item */
|
||||||
@@ -617,11 +646,43 @@ void uiItemL(uiLayout *layout, char *name, int icon)
|
|||||||
|
|
||||||
/**************************** Template ***************************/
|
/**************************** Template ***************************/
|
||||||
|
|
||||||
/* multi-column layout */
|
/* single row layout */
|
||||||
static void ui_layout_column(uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
|
static void ui_layout_row(uiLayout *layout, uiBlock *block, uiTemplate *template)
|
||||||
{
|
{
|
||||||
uiItem *item;
|
uiItem *item;
|
||||||
int col, totcol= 0, colx, coly, colw, miny, itemw, itemh;
|
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)
|
||||||
|
{
|
||||||
|
uiItem *item;
|
||||||
|
int col, totcol= 0, x, y, miny, itemw, itemh, w;
|
||||||
|
|
||||||
/* compute number of columns */
|
/* compute number of columns */
|
||||||
for(item=template->items.first; item; item=item->next)
|
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)
|
if(totcol == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
colx= *x;
|
x= 0;
|
||||||
colw= (w - (totcol-1)*COLUMN_SPACE)/totcol;
|
miny= 0;
|
||||||
miny= *y;
|
w= layout->w - (totcol-1)*COLUMN_SPACE;
|
||||||
|
|
||||||
/* create column per column */
|
/* create column per column */
|
||||||
for(col=0; col<totcol; col++) {
|
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) {
|
for(item=template->items.first; item; item=item->next) {
|
||||||
if(item->slot != col)
|
if(item->slot != col)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ui_item_size(item, &itemw, &itemh);
|
ui_item_size(item, NULL, &itemh);
|
||||||
|
|
||||||
coly -= itemh + BUTTON_SPACE_Y;
|
y -= itemh;
|
||||||
ui_item_buts(block, item, colx, coly, colw, itemh);
|
ui_item_buts(block, item, layout->x+x, layout->y+y, itemw, itemh);
|
||||||
|
y -= BUTTON_SPACE_Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
colx += colw + COLUMN_SPACE;
|
x += itemw + COLUMN_SPACE;
|
||||||
miny= MIN2(miny, coly);
|
miny= MIN2(miny, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
*y= miny;
|
layout->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
*y -= maxh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* multi-column layout, automatically flowing to the next */
|
/* 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;
|
uiTemplateFlow *flow= (uiTemplateFlow*)template;
|
||||||
uiItem *item;
|
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;
|
int toth, totcol, totitem;
|
||||||
|
|
||||||
/* compute max needed width and total height */
|
/* 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) {
|
for(item=template->items.first; item; item=item->next) {
|
||||||
ui_item_size(item, &itemw, &itemh);
|
ui_item_size(item, &itemw, &itemh);
|
||||||
maxw= MAX2(maxw, itemw);
|
maxw= MAX2(maxw, itemw);
|
||||||
toth += itemh + BUTTON_SPACE_Y;
|
toth += itemh;
|
||||||
totitem++;
|
totitem++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flow->columns <= 0) {
|
if(flow->number <= 0) {
|
||||||
/* auto compute number of columns, not very good */
|
/* auto compute number of columns, not very good */
|
||||||
if(maxw == 0)
|
if(maxw == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
totcol= MIN2(w/maxw, 1);
|
totcol= MAX2(layout->emw/maxw, 1);
|
||||||
totcol= MAX2(totcol, totitem);
|
totcol= MIN2(totcol, totitem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
totcol= flow->columns;
|
totcol= flow->number;
|
||||||
|
|
||||||
/* compute sizes */
|
/* compute sizes */
|
||||||
colx= *x;
|
x= 0;
|
||||||
coly= *y;
|
y= 0;
|
||||||
colw= (w - (totcol-1)*COLUMN_SPACE)/totcol;
|
emy= 0;
|
||||||
colh= toth/totcol;
|
miny= 0;
|
||||||
miny= *y;
|
|
||||||
|
w= layout->w - totcol*(COLUMN_SPACE);
|
||||||
|
emh= toth/totcol;
|
||||||
|
|
||||||
/* create column per column */
|
/* create column per column */
|
||||||
col= 0;
|
col= 0;
|
||||||
for(item=template->items.first; item; item=item->next) {
|
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;
|
y -= itemh;
|
||||||
ui_item_buts(block, item, colx, coly, colw, itemh);
|
emy -= itemh;
|
||||||
|
ui_item_buts(block, item, layout->x+x, layout->y+y, itemw, itemh);
|
||||||
|
y -= BUTTON_SPACE_Y;
|
||||||
|
miny= MIN2(miny, y);
|
||||||
|
|
||||||
miny= MIN2(miny, coly);
|
/* decide to go to next one */
|
||||||
|
if(col < totcol-1 && emy <= -emh) {
|
||||||
if(coly <= *y - colh && col < totcol) {
|
x += itemw + COLUMN_SPACE;
|
||||||
colx += colw + COLUMN_SPACE;
|
y= 0;
|
||||||
coly= *y;
|
|
||||||
col++;
|
col++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*y= miny;
|
layout->y += miny;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* left-right layout, with buttons aligned on both sides */
|
/* 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;
|
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 */
|
/* estimate total width of buttons */
|
||||||
for(item=template->items.first; item; item=item->next) {
|
for(item=template->items.first; item; item=item->next) {
|
||||||
ui_item_size(item, &itemw, &itemh);
|
ui_item_size(item, &itemw, &itemh);
|
||||||
totw += itemw;
|
totw += itemw;
|
||||||
maxh= MAX2(maxh, itemh);
|
maxh= MAX2(maxh, itemh);
|
||||||
|
tot++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(totw == 0)
|
if(totw == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* create buttons starting from left and right */
|
/* create buttons starting from left and right */
|
||||||
leftx= *x;
|
lx= 0;
|
||||||
rightx= *x + w;
|
rx= 0;
|
||||||
|
w= layout->w - BUTTON_SPACE_X*(tot-1) + BUTTON_SPACE_X;
|
||||||
|
|
||||||
for(item=template->items.first; item; item=item->next) {
|
for(item=template->items.first; item; item=item->next) {
|
||||||
ui_item_size(item, &itemw, &itemh);
|
ui_item_size(item, &itemw, &itemh);
|
||||||
itemw= ui_item_fit(itemw, totw+BUTTON_SPACE_X, w);
|
|
||||||
|
|
||||||
if(item->slot == UI_TSLOT_LR_LEFT) {
|
if(item->slot == UI_TSLOT_LR_LEFT) {
|
||||||
ui_item_buts(block, item, leftx, *y-itemh, itemw, itemh);
|
itemw= ui_item_fit(itemw, lx, totw, w, 0, 0);
|
||||||
leftx += itemw;
|
ui_item_buts(block, item, layout->x+lx, layout->y-itemh, itemw, itemh);
|
||||||
|
lx += itemw + BUTTON_SPACE_X;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rightx -= itemw;
|
itemw= ui_item_fit(itemw, totw + rx, totw, w, 0, 0);
|
||||||
ui_item_buts(block, item, rightx, *y-itemh, itemw, itemh);
|
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 */
|
/* split in columns */
|
||||||
static void ui_layout_stack(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template, int *x, int *y, int w, int h)
|
static void ui_layout_split(const bContext *C, uiLayout *layout, uiBlock *block, uiTemplate *template)
|
||||||
{
|
{
|
||||||
uiTemplateStck *stack= (uiTemplateStck*)template;
|
uiTemplateSplt *split= (uiTemplateSplt*)template;
|
||||||
int starty, startx;
|
uiLayout *sublayout;
|
||||||
|
int a, x, y, miny, w= layout->w, h= layout->h, splitw;
|
||||||
|
|
||||||
startx= *x;
|
x= 0;
|
||||||
starty= *y;
|
y= 0;
|
||||||
|
miny= layout->y;
|
||||||
|
|
||||||
/* some extra padding */
|
for(a=0; a<split->number; a++) {
|
||||||
stack->sublayout->x= *x + STACK_SPACE;
|
sublayout= split->sublayout[a];
|
||||||
stack->sublayout->w= w - 2*STACK_SPACE;
|
|
||||||
stack->sublayout->y= *y - STACK_SPACE;
|
splitw= ui_item_fit(1, x, split->number, w, a == split->number-1, UI_FIT_EXPAND);
|
||||||
stack->sublayout->h= h;
|
sublayout->x= layout->x + x;
|
||||||
|
sublayout->w= splitw;
|
||||||
|
sublayout->y= layout->y;
|
||||||
|
sublayout->h= h;
|
||||||
|
|
||||||
|
sublayout->emw= layout->emw/split->number;
|
||||||
|
sublayout->emh= layout->emh;
|
||||||
|
|
||||||
/* do layout for elements in sublayout */
|
/* do layout for elements in sublayout */
|
||||||
ui_layout_end(C, block, stack->sublayout, NULL, y);
|
ui_layout_end(C, block, sublayout, NULL, &y);
|
||||||
|
miny= MIN2(y, miny);
|
||||||
|
|
||||||
/* roundbox around the sublayout */
|
x += splitw + COLUMN_SPACE;
|
||||||
uiDefBut(block, ROUNDBOX, 0, "", startx, *y, w, starty - *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)
|
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 */
|
||||||
|
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, box->sublayout, NULL, &layout->y);
|
||||||
|
|
||||||
|
/* roundbox around the sublayout */
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
uiItem *item;
|
uiItem *item;
|
||||||
int itemw, itemh;
|
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) {
|
for(item=template->items.first; item; item=item->next) {
|
||||||
ui_item_size(item, &itemw, &itemh);
|
ui_item_size(item, &itemw, &itemh);
|
||||||
ui_item_buts(block, item, *x, *y, itemw, itemh);
|
ui_item_buts(block, item, layout->x, layout->y, itemw, itemh);
|
||||||
*x += itemw;
|
layout->x += itemw;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiBlockEndAlign(block);
|
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);
|
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) {
|
if((sa->flag & HEADER_NO_PULLDOWN)==0) {
|
||||||
uiBlockSetEmboss(block, UI_EMBOSSP);
|
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);
|
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;
|
uiTemplateHeadID *idtemplate= (uiTemplateHeadID*)template;
|
||||||
PointerRNA idptr;
|
PointerRNA idptr;
|
||||||
|
|
||||||
idptr= RNA_pointer_get(&idtemplate->ptr, idtemplate->propname);
|
idptr= RNA_pointer_get(&idtemplate->ptr, idtemplate->propname);
|
||||||
|
|
||||||
*x= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)idptr.data, ID_TXT, NULL, *x, *y,
|
layout->x= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)idptr.data, ID_TXT, NULL,
|
||||||
idtemplate->func, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE);
|
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)
|
void ui_template_free(uiTemplate *template)
|
||||||
{
|
{
|
||||||
uiItem *item;
|
uiItem *item;
|
||||||
|
int a;
|
||||||
|
|
||||||
if(template->type == TEMPLATE_STACK) {
|
if(template->type == TEMPLATE_BOX) {
|
||||||
uiTemplateStck *stack= (uiTemplateStck*)template;
|
uiTemplateBx *box= (uiTemplateBx*)template;
|
||||||
ui_layout_free(stack->sublayout);
|
ui_layout_free(box->sublayout);
|
||||||
|
}
|
||||||
|
if(template->type == TEMPLATE_SPLIT) {
|
||||||
|
uiTemplateSplt *split= (uiTemplateSplt*)template;
|
||||||
|
|
||||||
|
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)
|
for(item=template->items.first; item; item=item->next)
|
||||||
@@ -859,7 +946,7 @@ void ui_template_free(uiTemplate *template)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* template create functions */
|
/* template create functions */
|
||||||
void uiTemplateRow(uiLayout *layout)
|
void uiLayoutRow(uiLayout *layout)
|
||||||
{
|
{
|
||||||
uiTemplate *template;
|
uiTemplate *template;
|
||||||
|
|
||||||
@@ -869,7 +956,7 @@ void uiTemplateRow(uiLayout *layout)
|
|||||||
BLI_addtail(&layout->templates, template);
|
BLI_addtail(&layout->templates, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTemplateColumn(uiLayout *layout)
|
void uiLayoutColumn(uiLayout *layout)
|
||||||
{
|
{
|
||||||
uiTemplate *template;
|
uiTemplate *template;
|
||||||
|
|
||||||
@@ -879,36 +966,64 @@ void uiTemplateColumn(uiLayout *layout)
|
|||||||
BLI_addtail(&layout->templates, template);
|
BLI_addtail(&layout->templates, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTemplateColumnFlow(uiLayout *layout, int columns)
|
void uiLayoutColumnFlow(uiLayout *layout, int number)
|
||||||
{
|
{
|
||||||
uiTemplateFlow *flow;
|
uiTemplateFlow *flow;
|
||||||
|
|
||||||
flow= MEM_callocN(sizeof(uiTemplateFlow), "uiTemplateFlow");
|
flow= MEM_callocN(sizeof(uiTemplateFlow), "uiTemplateFlow");
|
||||||
flow->template.type= TEMPLATE_COLUMN_FLOW;
|
flow->template.type= TEMPLATE_COLUMN_FLOW;
|
||||||
flow->columns= columns;
|
flow->number= number;
|
||||||
BLI_addtail(&layout->templates, flow);
|
BLI_addtail(&layout->templates, flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTemplateLeftRight(uiLayout *layout)
|
uiLayout *uiLayoutBox(uiLayout *layout)
|
||||||
{
|
{
|
||||||
uiTemplate *template;
|
uiTemplateBx *box;
|
||||||
|
|
||||||
template= MEM_callocN(sizeof(uiTemplate), "uiTemplate");
|
box= MEM_callocN(sizeof(uiTemplateBx), "uiTemplateBx");
|
||||||
template->type= TEMPLATE_LR;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiLayout *uiTemplateStack(uiLayout *layout)
|
void uiLayoutSplit(uiLayout *layout, int number, int lr)
|
||||||
{
|
{
|
||||||
uiTemplateStck *stack;
|
uiTemplateSplt *split;
|
||||||
|
int a;
|
||||||
|
|
||||||
stack= MEM_callocN(sizeof(uiTemplateStck), "uiTemplateStck");
|
split= MEM_callocN(sizeof(uiTemplateSplt), "uiTemplateSplt");
|
||||||
stack->template.type= TEMPLATE_STACK;
|
split->template.type= TEMPLATE_SPLIT;
|
||||||
stack->sublayout= uiLayoutBegin(layout->dir, 0, 0, 0, 0);
|
split->number= number;
|
||||||
BLI_addtail(&layout->templates, stack);
|
split->lr= lr;
|
||||||
|
split->sublayout= MEM_callocN(sizeof(uiLayout*)*number, "uiTemplateSpltSub");
|
||||||
|
|
||||||
return stack->sublayout;
|
for(a=0; a<number; a++)
|
||||||
|
split->sublayout[a]= uiLayoutBegin(layout->dir, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
BLI_addtail(&layout->templates, split);
|
||||||
|
}
|
||||||
|
|
||||||
|
uiLayout *uiLayoutSub(uiLayout *layout, int n)
|
||||||
|
{
|
||||||
|
uiTemplate *template= layout->templates.last;
|
||||||
|
|
||||||
|
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 NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiTemplateHeaderMenus(uiLayout *layout)
|
void uiTemplateHeaderMenus(uiLayout *layout)
|
||||||
@@ -967,6 +1082,25 @@ static void ui_layout_templates(const bContext *C, uiBlock *block, uiLayout *lay
|
|||||||
{
|
{
|
||||||
uiTemplate *template;
|
uiTemplate *template;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
layout->x += TEMPLATE_SPACE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
for(template=layout->templates.first; template; template=template->next) {
|
for(template=layout->templates.first; template; template=template->next) {
|
||||||
if(template->color) {
|
if(template->color) {
|
||||||
// XXX oldcolor= uiBlockGetCol(block);
|
// XXX oldcolor= uiBlockGetCol(block);
|
||||||
@@ -975,40 +1109,30 @@ static void ui_layout_templates(const bContext *C, uiBlock *block, uiLayout *lay
|
|||||||
|
|
||||||
switch(template->type) {
|
switch(template->type) {
|
||||||
case TEMPLATE_ROW:
|
case TEMPLATE_ROW:
|
||||||
ui_layout_row(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
|
ui_layout_row(layout, block, template);
|
||||||
break;
|
|
||||||
case TEMPLATE_COLUMN:
|
|
||||||
ui_layout_column(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
|
|
||||||
break;
|
break;
|
||||||
case TEMPLATE_COLUMN_FLOW:
|
case TEMPLATE_COLUMN_FLOW:
|
||||||
ui_layout_column_flow(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
|
ui_layout_column_flow(layout, block, template);
|
||||||
break;
|
break;
|
||||||
case TEMPLATE_LR:
|
case TEMPLATE_SPLIT:
|
||||||
ui_layout_lr(layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
|
ui_layout_split(C, layout, block, template);
|
||||||
break;
|
break;
|
||||||
case TEMPLATE_STACK:
|
case TEMPLATE_BOX:
|
||||||
ui_layout_stack(C, layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
|
ui_layout_box(C, layout, block, template);
|
||||||
break;
|
break;
|
||||||
case TEMPLATE_HEADER_MENUS:
|
case TEMPLATE_COLUMN:
|
||||||
ui_layout_header_menus(C, layout, block, template, &layout->x, &layout->y, layout->w, layout->h);
|
default:
|
||||||
break;
|
ui_layout_column(layout, block, template);
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX if(template->color)
|
// XXX if(template->color)
|
||||||
// XXX uiBlockSetCol(block, oldcolor);
|
// XXX uiBlockSetCol(block, oldcolor);
|
||||||
|
|
||||||
if(layout->dir == UI_LAYOUT_HORIZONTAL)
|
|
||||||
layout->x += TEMPLATE_SPACE;
|
|
||||||
else
|
|
||||||
layout->y -= TEMPLATE_SPACE;
|
layout->y -= TEMPLATE_SPACE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y)
|
void ui_layout_end(const bContext *C, uiBlock *block, uiLayout *layout, int *x, int *y)
|
||||||
{
|
{
|
||||||
@@ -1030,7 +1154,7 @@ void ui_layout_free(uiLayout *layout)
|
|||||||
MEM_freeN(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;
|
uiLayout *layout;
|
||||||
|
|
||||||
@@ -1039,8 +1163,15 @@ uiLayout *uiLayoutBegin(int dir, int x, int y, int w, int h)
|
|||||||
layout->dir= dir;
|
layout->dir= dir;
|
||||||
layout->x= x;
|
layout->x= x;
|
||||||
layout->y= y;
|
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;
|
return layout;
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1195,7 @@ void uiRegionPanelLayout(const bContext *C, ARegion *ar, int vertical, char *con
|
|||||||
PanelType *pt;
|
PanelType *pt;
|
||||||
Panel *panel;
|
Panel *panel;
|
||||||
float col[3];
|
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
|
// 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))) {
|
if(pt->draw && (!pt->poll || pt->poll(C))) {
|
||||||
block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS);
|
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;
|
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;
|
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)) {
|
if(uiNewPanel(C, ar, block, pt->name, pt->name, x, y, w, 0)) {
|
||||||
panel= uiPanelFromBlock(block);
|
panel= uiPanelFromBlock(block);
|
||||||
panel->type= pt;
|
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);
|
pt->draw(C, panel);
|
||||||
|
|
||||||
uiLayoutEnd(C, block, panel->layout, &xco, &yco);
|
uiLayoutEnd(C, block, panel->layout, &xco, &yco);
|
||||||
panel->layout= NULL;
|
panel->layout= NULL;
|
||||||
uiNewPanelHeight(block, y - yco + 6);
|
uiNewPanelHeight(block, y - yco + 12);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
w= PNL_HEADER;
|
w= PNL_HEADER;
|
||||||
@@ -1150,7 +1285,7 @@ void uiRegionHeaderLayout(const bContext *C, ARegion *ar)
|
|||||||
/* draw all headers types */
|
/* draw all headers types */
|
||||||
for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
|
for(ht= ar->type->headertypes.first; ht; ht= ht->next) {
|
||||||
block= uiBeginBlock(C, ar, "header buttons", UI_EMBOSS);
|
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)
|
if(ht->draw)
|
||||||
ht->draw(C, layout);
|
ht->draw(C, layout);
|
||||||
|
|||||||
@@ -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);
|
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);
|
uiItemL(layout, (char*)RNA_struct_ui_name(ptr), 0);
|
||||||
|
|
||||||
iterprop= RNA_struct_iterator_property(ptr);
|
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)
|
if(strcmp(RNA_property_identifier(ptr, prop), "rna_type") == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uiTemplateColumn(layout);
|
uiLayoutSplit(layout, 2, 0);
|
||||||
|
|
||||||
name= (char*)RNA_property_ui_name(ptr, prop);
|
name= (char*)RNA_property_ui_name(ptr, prop);
|
||||||
uiTemplateSlot(layout, UI_TSLOT_COLUMN_1);
|
uiItemL(uiLayoutSub(layout, 0), name, 0);
|
||||||
uiItemL(layout, name, 0);
|
uiItemFullR(uiLayoutSub(layout, 1), "", 0, ptr, prop, -1, 0);
|
||||||
uiTemplateSlot(layout, UI_TSLOT_COLUMN_2);
|
|
||||||
uiItemR(layout, "", 0, ptr, (char*)RNA_property_identifier(ptr, prop));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RNA_property_collection_end(&iter);
|
RNA_property_collection_end(&iter);
|
||||||
|
|||||||
@@ -381,10 +381,10 @@ static void text_header_draw(const bContext *C, uiLayout *layout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uiTemplateHeaderButtons(layout);
|
uiTemplateHeaderButtons(layout);
|
||||||
uiItemR(layout, "", ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers");
|
uiItemR(layout, "", ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers", 0);
|
||||||
uiItemR(layout, "", ICON_WORDWRAP_OFF, &spaceptr, "word_wrap");
|
uiItemR(layout, "", ICON_WORDWRAP_OFF, &spaceptr, "word_wrap", 0);
|
||||||
uiItemR(layout, "", ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight");
|
uiItemR(layout, "", ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight", 0);
|
||||||
// XXX uiItemR(layout, "", ICON_SCRIPTPLUGINS, &spaceptr, "do_python_plugins");
|
// XXX uiItemR(layout, "", ICON_SCRIPTPLUGINS, &spaceptr, "do_python_plugins", 0);
|
||||||
|
|
||||||
uiTemplateHeaderID(layout, &spaceptr, "text",
|
uiTemplateHeaderID(layout, &spaceptr, "text",
|
||||||
UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE,
|
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);
|
RNA_pointer_create(&sc->id, &RNA_SpaceTextEditor, st, &spaceptr);
|
||||||
|
|
||||||
uiTemplateColumn(layout);
|
uiLayoutColumn(layout);
|
||||||
uiItemR(layout, NULL, ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers");
|
uiItemR(layout, NULL, ICON_LINENUMBERS_OFF, &spaceptr, "line_numbers", 0);
|
||||||
uiItemR(layout, NULL, ICON_WORDWRAP_OFF, &spaceptr, "word_wrap");
|
uiItemR(layout, NULL, ICON_WORDWRAP_OFF, &spaceptr, "word_wrap", 0);
|
||||||
uiItemR(layout, NULL, ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight");
|
uiItemR(layout, NULL, ICON_SYNTAX_OFF, &spaceptr, "syntax_highlight", 0);
|
||||||
|
|
||||||
uiTemplateColumn(layout);
|
uiLayoutColumn(layout);
|
||||||
uiItemR(layout, NULL, 0, &spaceptr, "font_size");
|
uiItemR(layout, NULL, 0, &spaceptr, "font_size", 0);
|
||||||
uiItemR(layout, NULL, 0, &spaceptr, "tab_width");
|
uiItemR(layout, NULL, 0, &spaceptr, "tab_width", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void text_find_panel_draw(const bContext *C, Panel *panel)
|
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);
|
RNA_pointer_create(&sc->id, &RNA_SpaceTextEditor, st, &spaceptr);
|
||||||
|
|
||||||
/* find */
|
/* find */
|
||||||
uiTemplateLeftRight(layout);
|
uiLayoutRow(layout);
|
||||||
uiTemplateSlot(layout, UI_TSLOT_LR_LEFT);
|
uiItemR(layout, "", 0, &spaceptr, "find_text", 0);
|
||||||
uiItemR(layout, "", 0, &spaceptr, "find_text");
|
|
||||||
uiTemplateSlot(layout, UI_TSLOT_LR_RIGHT);
|
|
||||||
uiItemO(layout, "", ICON_TEXT, "TEXT_OT_find_set_selected");
|
uiItemO(layout, "", ICON_TEXT, "TEXT_OT_find_set_selected");
|
||||||
uiTemplateColumn(layout);
|
uiLayoutColumn(layout);
|
||||||
uiItemO(layout, NULL, 0, "TEXT_OT_find");
|
uiItemO(layout, NULL, 0, "TEXT_OT_find");
|
||||||
|
|
||||||
/* replace */
|
/* replace */
|
||||||
uiTemplateLeftRight(layout);
|
uiLayoutRow(layout);
|
||||||
uiTemplateSlot(layout, UI_TSLOT_LR_LEFT);
|
uiItemR(layout, "", 0, &spaceptr, "replace_text", 0);
|
||||||
uiItemR(layout, "", 0, &spaceptr, "replace_text");
|
|
||||||
uiTemplateSlot(layout, UI_TSLOT_LR_RIGHT);
|
|
||||||
uiItemO(layout, "", ICON_TEXT, "TEXT_OT_replace_set_selected");
|
uiItemO(layout, "", ICON_TEXT, "TEXT_OT_replace_set_selected");
|
||||||
uiTemplateColumn(layout);
|
uiLayoutColumn(layout);
|
||||||
uiItemO(layout, NULL, 0, "TEXT_OT_replace");
|
uiItemO(layout, NULL, 0, "TEXT_OT_replace");
|
||||||
|
|
||||||
/* mark */
|
/* mark */
|
||||||
uiTemplateColumn(layout);
|
uiLayoutColumn(layout);
|
||||||
uiItemO(layout, NULL, 0, "TEXT_OT_mark_all");
|
uiItemO(layout, NULL, 0, "TEXT_OT_mark_all");
|
||||||
|
|
||||||
/* settings */
|
/* settings */
|
||||||
uiTemplateColumnFlow(layout, 2);
|
uiLayoutColumnFlow(layout, 0);
|
||||||
uiItemR(layout, "Wrap", 0, &spaceptr, "find_wrap");
|
uiItemR(layout, "Wrap", 0, &spaceptr, "find_wrap", 0);
|
||||||
uiItemR(layout, "All", 0, &spaceptr, "find_all");
|
uiItemR(layout, "All", 0, &spaceptr, "find_all", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void text_properties_register(ARegionType *art)
|
void text_properties_register(ARegionType *art)
|
||||||
|
|||||||
Reference in New Issue
Block a user