Compare commits
1 Commits
asset-engi
...
tmp-Timeli
Author | SHA1 | Date | |
---|---|---|---|
9637e4e65f |
@@ -35,16 +35,31 @@ class TIME_HT_editor_buttons(Header):
|
||||
scene = context.scene
|
||||
toolsettings = context.tool_settings
|
||||
screen = context.screen
|
||||
|
||||
# XXX: Nasty layout hacks ------------------------------
|
||||
MAX_WIDTH = context.area.width
|
||||
UI_UNIT_X = 20.0
|
||||
UI_DPI_FAC = context.user_preferences.system.ui_scale
|
||||
|
||||
# 7 for playback, 17 for frame nums (4 per control + 1 + 1), + menus
|
||||
total_content_width = (18 + 8 + 16) * UI_UNIT_X * UI_DPI_FAC
|
||||
|
||||
free_space = MAX_WIDTH - total_content_width
|
||||
if free_space < 0:
|
||||
spacer_scale = 0.1
|
||||
else:
|
||||
spacer_scale = (free_space / 2) / (UI_UNIT_X * UI_DPI_FAC)
|
||||
#print("area width = %s, total_content = %s, spacer_scale = %s" % (MAX_WIDTH, total_content_width, spacer_scale))
|
||||
|
||||
# XXX: Nasty layout hacks end ---------------------------
|
||||
|
||||
layout.separator() # XXX: This should be dynamic (e.g. layout.separator(stretch=1.0))
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
row.alignment = 'EXPAND'
|
||||
row.scale_x = spacer_scale
|
||||
row.spacer()
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.alignment = 'CENTER'
|
||||
row.prop(toolsettings, "use_keyframe_insert_auto", text="", toggle=True)
|
||||
|
||||
row.operator("screen.frame_jump", text="", icon='REW').end = False
|
||||
@@ -67,34 +82,34 @@ class TIME_HT_editor_buttons(Header):
|
||||
row.operator("screen.keyframe_jump", text="", icon='NEXT_KEYFRAME').next = True
|
||||
row.operator("screen.frame_jump", text="", icon='FF').end = True
|
||||
|
||||
layout.separator() # XXX: This should be dynamic (e.g. layout.separator(stretch=1.0))
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
row.alignment = 'EXPAND'
|
||||
row.scale_x = spacer_scale
|
||||
row.spacer()
|
||||
|
||||
row = layout.row()
|
||||
row.scale_x = 0.95
|
||||
row.alignment = 'RIGHT'
|
||||
|
||||
subrow = row.row()
|
||||
subrow.scale_x = 0.95
|
||||
if scene.show_subframe:
|
||||
row.prop(scene, "frame_float", text="")
|
||||
subrow.prop(scene, "frame_float", text="")
|
||||
else:
|
||||
row.prop(scene, "frame_current", text="")
|
||||
subrow.prop(scene, "frame_current", text="")
|
||||
|
||||
layout.separator()
|
||||
layout.separator()
|
||||
row.separator()
|
||||
row.separator()
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(scene, "use_preview_range", text="", toggle=True)
|
||||
sub = row.row(align=True)
|
||||
sub.scale_x = 0.8
|
||||
subrow = row.row(align=True)
|
||||
subrow.prop(scene, "use_preview_range", text="", toggle=True)
|
||||
subsub = subrow.row(align=True)
|
||||
subsub.scale_x = 0.8
|
||||
if not scene.use_preview_range:
|
||||
sub.prop(scene, "frame_start", text="Start")
|
||||
sub.prop(scene, "frame_end", text="End")
|
||||
subsub.prop(scene, "frame_start", text="Start")
|
||||
subsub.prop(scene, "frame_end", text="End")
|
||||
else:
|
||||
sub.prop(scene, "frame_preview_start", text="Start")
|
||||
sub.prop(scene, "frame_preview_end", text="End")
|
||||
subsub.prop(scene, "frame_preview_start", text="Start")
|
||||
subsub.prop(scene, "frame_preview_end", text="End")
|
||||
|
||||
|
||||
class TIME_MT_editor_menus(Menu):
|
||||
|
@@ -1105,6 +1105,7 @@ void uiItemLDrag(uiLayout *layout, struct PointerRNA *ptr, const char *name, int
|
||||
void uiItemM(uiLayout *layout, struct bContext *C, const char *menuname, const char *name, int icon); /* menu */
|
||||
void uiItemV(uiLayout *layout, const char *name, int icon, int argval); /* value */
|
||||
void uiItemS(uiLayout *layout); /* separator */
|
||||
void uiItemSpacer(uiLayout *layout); /* separator that stretches */
|
||||
|
||||
void uiItemPopoverPanel_ptr(
|
||||
uiLayout *layout, struct bContext *C,
|
||||
|
@@ -2113,6 +2113,18 @@ void uiItemS(uiLayout *layout)
|
||||
uiDefBut(block, (is_menu) ? UI_BTYPE_SEPR_LINE : UI_BTYPE_SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, "");
|
||||
}
|
||||
|
||||
/* spacer item - a separator that stretches out by default */
|
||||
void uiItemSpacer(uiLayout *layout)
|
||||
{
|
||||
uiBlock *block = layout->root->block;
|
||||
uiBut *but;
|
||||
int space = UI_UNIT_X;
|
||||
|
||||
UI_block_layout_set_current(block, layout);
|
||||
but = uiDefBut(block, UI_BTYPE_SEPR, 0, "", 0, 0, space, space, NULL, 0.0, 0.0, 0, 0, "");
|
||||
//printf(" spacer: s = %p -> L = %p\n", but, layout);
|
||||
}
|
||||
|
||||
/* level items */
|
||||
void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg)
|
||||
{
|
||||
@@ -2331,6 +2343,7 @@ static void ui_litem_layout_row(uiLayout *litem)
|
||||
{
|
||||
min_flag = false;
|
||||
}
|
||||
|
||||
|
||||
if ((neww < minw || min_flag) && w != 0) {
|
||||
/* fixed size */
|
||||
@@ -2360,7 +2373,8 @@ static void ui_litem_layout_row(uiLayout *litem)
|
||||
|
||||
for (item = litem->items.first; item; item = item->next) {
|
||||
ui_item_size(item, &itemw, &itemh);
|
||||
minw = ui_litem_min_width(itemw);
|
||||
//minw = ui_litem_min_width(itemw);
|
||||
minw = itemw;
|
||||
|
||||
if (item->flag & UI_ITEM_FIXED) {
|
||||
/* fixed minimum size items */
|
||||
|
@@ -718,6 +718,9 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
|
||||
func = RNA_def_function(srna, "separator", "uiItemS");
|
||||
RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items");
|
||||
|
||||
func = RNA_def_function(srna, "spacer", "uiItemSpacer");
|
||||
RNA_def_function_ui_description(func, "Item. Inserts empty space into layout between items that can grow and shrink as needed");
|
||||
|
||||
/* context */
|
||||
func = RNA_def_function(srna, "context_pointer_set", "uiLayoutSetContextPointer");
|
||||
|
Reference in New Issue
Block a user