[Bf-blender-cvs] [0af8fcee76b] modifier-panels-ui: Support using property split for menu items & use for output FPS setting
Julian Eisel
noreply at git.blender.org
Thu Apr 16 21:30:24 CEST 2020
Commit: 0af8fcee76b909361f152141f1360ed21821bdbe
Author: Julian Eisel
Date: Mon Apr 13 18:22:26 2020 +0200
Branches: modifier-panels-ui
https://developer.blender.org/rB0af8fcee76b909361f152141f1360ed21821bdbe
Support using property split for menu items & use for output FPS setting
We could add an extra parameter for the label string, for now we can
just use the headings. So if a layout heading is available (set and not
already added) use that to enable the split layout.
===================================================================
M release/scripts/startup/bl_ui/properties_output.py
M source/blender/editors/interface/interface_layout.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_output.py b/release/scripts/startup/bl_ui/properties_output.py
index e2158d3644a..e90a0a06429 100644
--- a/release/scripts/startup/bl_ui/properties_output.py
+++ b/release/scripts/startup/bl_ui/properties_output.py
@@ -94,14 +94,14 @@ class RENDER_PT_dimensions(RenderOutputButtonsPanel, Panel):
return args
@staticmethod
- def draw_framerate(layout, sub, rd):
+ def draw_framerate(layout, rd):
if RENDER_PT_dimensions._preset_class is None:
RENDER_PT_dimensions._preset_class = bpy.types.RENDER_MT_framerate_presets
args = rd.fps, rd.fps_base, RENDER_PT_dimensions._preset_class.bl_label
fps_label_text, show_framerate = RENDER_PT_dimensions._draw_framerate_label(*args)
- sub.menu("RENDER_MT_framerate_presets", text=fps_label_text)
+ layout.menu("RENDER_MT_framerate_presets", text=fps_label_text)
if show_framerate:
col = layout.column(align=True)
@@ -136,10 +136,8 @@ class RENDER_PT_dimensions(RenderOutputButtonsPanel, Panel):
col.prop(scene, "frame_end", text="End")
col.prop(scene, "frame_step", text="Step")
- col = layout.split()
- col.alignment = 'RIGHT'
- col.label(text="Frame Rate")
- self.draw_framerate(layout, col, rd)
+ col = layout.column(heading="Frame Rate")
+ self.draw_framerate(col, rd)
class RENDER_PT_frame_remapping(RenderOutputButtonsPanel, Panel):
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index dec925a7eb4..32fb77b774d 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1894,7 +1894,8 @@ static uiLayout *ui_layout_heading_find(uiLayout *cur_layout)
static void ui_layout_heading_label_add(uiLayout *layout,
uiLayout *heading_layout,
- bool right_align)
+ bool right_align,
+ bool respect_prop_split)
{
const int prev_alignment = layout->alignment;
@@ -1902,7 +1903,12 @@ static void ui_layout_heading_label_add(uiLayout *layout,
uiLayoutSetAlignment(layout, UI_LAYOUT_ALIGN_RIGHT);
}
- uiItemL(layout, heading_layout->heading, ICON_NONE);
+ if (respect_prop_split) {
+ uiItemL_respect_property_split(layout, heading_layout->heading, ICON_NONE);
+ }
+ else {
+ uiItemL(layout, heading_layout->heading, ICON_NONE);
+ }
/* After adding the heading label, we have to mark it somehow as added, so it's not added again
* for other items in this layout. For now just clear it. */
heading_layout->heading[0] = '\0';
@@ -2110,7 +2116,7 @@ void uiItemFullR(uiLayout *layout,
layout = uiLayoutColumn(layout_row ? layout_row : layout, true);
layout->space = 0;
if (heading_layout) {
- ui_layout_heading_label_add(layout, heading_layout, false);
+ ui_layout_heading_label_add(layout, heading_layout, false, false);
}
}
else {
@@ -2171,7 +2177,7 @@ void uiItemFullR(uiLayout *layout,
}
if (!label_added && heading_layout) {
- ui_layout_heading_label_add(layout_sub, heading_layout, true);
+ ui_layout_heading_label_add(layout_sub, heading_layout, true, false);
}
layout_split = ui_item_prop_split_layout_hack(layout_parent, layout_split);
@@ -2214,7 +2220,7 @@ void uiItemFullR(uiLayout *layout,
else if (heading_layout) {
/* Could not add heading to split layout, fallback to inserting it to the layout with the
* heading itself. */
- ui_layout_heading_label_add(heading_layout, heading_layout, false);
+ ui_layout_heading_label_add(heading_layout, heading_layout, false, false);
}
else if (inside_prop_sep) {
/* When placing further items in a split row, add them to a column so they match the column
@@ -2814,6 +2820,7 @@ static uiBut *ui_item_menu(uiLayout *layout,
bool force_menu)
{
uiBlock *block = layout->root->block;
+ uiLayout *heading_layout = ui_layout_heading_find(layout);
uiBut *but;
int w, h;
@@ -2843,6 +2850,10 @@ static uiBut *ui_item_menu(uiLayout *layout,
}
}
+ if (heading_layout) {
+ ui_layout_heading_label_add(layout, heading_layout, true, true);
+ }
+
if (name[0] && icon) {
but = uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, tip);
}
More information about the Bf-blender-cvs
mailing list