[Bf-blender-cvs] [7a10cfe7fe0] blender2.8: UI: preset popover buttons in panel headers.
Brecht Van Lommel
noreply at git.blender.org
Wed Jun 13 15:23:52 CEST 2018
Commit: 7a10cfe7fe01bbeb7588239a9fd743ecc6af6c39
Author: Brecht Van Lommel
Date: Fri Apr 27 13:50:26 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7a10cfe7fe01bbeb7588239a9fd743ecc6af6c39
UI: preset popover buttons in panel headers.
Moves the preset into a menu for the panel header, so it can be changed
without opening the panel and takes up less space. Two remaining issues:
* For long lists the add new preset button can be scrolled off screen.
* We should support showing the name of the chosen preset in the panel
header, but the current preset system does not support detecting which
preset is used.
Differential Revision: https://developer.blender.org/D3366
===================================================================
M intern/cycles/blender/addon/ui.py
M release/datafiles/blender_icons.svg
A release/datafiles/blender_icons16/icon16_preset.dat
A release/datafiles/blender_icons32/icon32_preset.dat
M release/scripts/modules/bpy_types.py
M release/scripts/startup/bl_operators/presets.py
M release/scripts/startup/bl_ui/properties_data_camera.py
M release/scripts/startup/bl_ui/properties_data_lamp.py
M release/scripts/startup/bl_ui/properties_particle.py
M release/scripts/startup/bl_ui/properties_physics_cloth.py
M release/scripts/startup/bl_ui/properties_physics_fluid.py
M release/scripts/startup/bl_ui/properties_render.py
M release/scripts/startup/bl_ui/properties_scene.py
M release/scripts/startup/bl_ui/space_clip.py
M release/scripts/startup/bl_ui/space_node.py
M source/blender/blenkernel/BKE_screen.h
M source/blender/editors/include/UI_icons.h
M source/blender/editors/interface/interface_region_popover.c
M source/blender/editors/screen/area.c
M source/blender/makesrna/intern/rna_ui.c
===================================================================
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index c514ec1704e..c5eafe9ebfb 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -18,6 +18,7 @@
import bpy
from bpy_extras.node_utils import find_node_input, find_output_node
+from bl_operators.presets import PresetMenu
from bpy.types import (
Panel,
@@ -26,20 +27,20 @@ from bpy.types import (
)
-class CYCLES_MT_sampling_presets(Menu):
+class CYCLES_MT_sampling_presets(PresetMenu):
bl_label = "Sampling Presets"
preset_subdir = "cycles/sampling"
preset_operator = "script.execute_preset"
+ preset_add_operator = "render.cycles_sampling_preset_add"
COMPAT_ENGINES = {'CYCLES'}
- draw = Menu.draw_preset
-class CYCLES_MT_integrator_presets(Menu):
+class CYCLES_MT_integrator_presets(PresetMenu):
bl_label = "Integrator Presets"
preset_subdir = "cycles/integrator"
preset_operator = "script.execute_preset"
+ preset_add_operator = "render.cycles_integrator_preset_add"
COMPAT_ENGINES = {'CYCLES'}
- draw = Menu.draw_preset
class CyclesButtonsPanel:
@@ -144,6 +145,9 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
bl_label = "Sampling"
bl_options = {'DEFAULT_CLOSED'}
+ def draw_header_preset(self, context):
+ CYCLES_MT_sampling_presets.draw_panel_header(self.layout)
+
def draw(self, context):
layout = self.layout
layout.use_property_split = False
@@ -151,11 +155,6 @@ class CYCLES_RENDER_PT_sampling(CyclesButtonsPanel, Panel):
scene = context.scene
cscene = scene.cycles
- row = layout.row(align=True)
- row.menu("CYCLES_MT_sampling_presets", text=bpy.types.CYCLES_MT_sampling_presets.bl_label)
- row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMIN")
- row.operator("render.cycles_sampling_preset_add", text="", icon="ZOOMOUT").remove_active = True
-
layout.use_property_split = True
layout.prop(cscene, "progressive")
@@ -315,17 +314,11 @@ class CYCLES_RENDER_PT_light_paths(CyclesButtonsPanel, Panel):
bl_label = "Light Paths"
bl_options = {'DEFAULT_CLOSED'}
- def draw(self, context):
- layout = self.layout
- layout.use_property_split = True
-
- scene = context.scene
- cscene = scene.cycles
+ def draw_header_preset(self, context):
+ CYCLES_MT_integrator_presets.draw_panel_header(self.layout)
- row = layout.row(align=True)
- row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
- row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
- row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
+ def draw(self, context):
+ pass
class CYCLES_RENDER_PT_light_paths_max_bounces(CyclesButtonsPanel, Panel):
diff --git a/release/datafiles/blender_icons.svg b/release/datafiles/blender_icons.svg
index 4d5376913ab..d389831e668 100644
--- a/release/datafiles/blender_icons.svg
+++ b/release/datafiles/blender_icons.svg
@@ -31910,6 +31910,15 @@
id="radialGradient16215"
xlink:href="#linearGradient18134"
inkscape:collect="always" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient27277-1-8"
+ id="linearGradient18811"
+ gradientUnits="userSpaceOnUse"
+ x1="4.1933641"
+ y1="199.12067"
+ x2="17.16466"
+ y2="211.01585" />
</defs>
<sodipodi:namedview
id="base"
@@ -92657,6 +92666,61 @@
y="75.5" />
</g>
</g>
+ <g
+ transform="translate(461.71013,377.29483)"
+ style="display:inline;enable-background:new"
+ id="ICON_SOLO_OFF-7">
+ <rect
+ y="198.9792"
+ x="4.9506397"
+ height="16"
+ width="16"
+ id="rect23018-5-4-5"
+ style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" />
+ <g
+ transform="matrix(0.94058502,0,0,0.94058502,0.9128606,12.74924)"
+ id="g56716-3" />
+ </g>
+ <g
+ transform="translate(461.99301,376.87052)"
+ style="display:inline;enable-background:new"
+ id="ICON_SOLO_OFF-1">
+ <rect
+ y="198.9792"
+ x="4.9506397"
+ height="16"
+ width="16"
+ id="rect23018-5-4-2"
+ style="display:inline;overflow:visible;visibility:visible;opacity:0;fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.79999995;marker:none;enable-background:accumulate" />
+ <g
+ transform="matrix(0.94058502,0,0,0.94058502,0.9128606,12.74924)"
+ id="g56716-7">
+ <path
+ sodipodi:type="star"
+ style="fill:url(#linearGradient18811);fill-opacity:1.0;stroke:#000000;stroke-width:0.96882826;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.80000001"
+ id="path15855-0"
+ sodipodi:sides="5"
+ sodipodi:cx="13.700194"
+ sodipodi:cy="207.20645"
+ sodipodi:r1="7.1873641"
+ sodipodi:r2="3.3158474"
+ sodipodi:arg1="0.94697287"
+ sodipodi:arg2="1.5618338"
+ inkscape:flatsided="false"
+ inkscape:rounded="0"
+ inkscape:randomized="0"
+ d="m 17.898641,213.04008 -4.168729,-2.51791 -4.280439,2.47993 1.106473,-4.74277 -3.6812884,-3.3046 4.8525664,-0.41328 2.005278,-4.52229 1.892578,4.48735 4.920618,0.50967 -3.682889,3.18662 z"
+ inkscape:transform-center-x="-0.010954063"
+ inkscape:transform-center-y="-0.74285516"
+ transform="matrix(1.0972098,0,0,1.0975406,-2.0923019,-19.740595)" />
+ <path
+ style="fill:none;stroke:#ffffff;stroke-width:1.06316817;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:0.51147538"
+ d="m 12.931855,202.51514 -1.201334,2.70994 c -0.137665,0.32193 -0.454082,0.55986 -0.800889,0.60222 l -2.9032248,0.26765 2.2358168,1.97391 c 0.261321,0.2395 0.380487,0.62447 0.300333,0.97022 l -0.667408,2.81032"
+ id="path15869-9"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccc" />
+ </g>
+ </g>
</g>
<g
inkscape:groupmode="layer"
diff --git a/release/datafiles/blender_icons16/icon16_preset.dat b/release/datafiles/blender_icons16/icon16_preset.dat
new file mode 100644
index 00000000000..52026e95a1a
Binary files /dev/null and b/release/datafiles/blender_icons16/icon16_preset.dat differ
diff --git a/release/datafiles/blender_icons32/icon32_preset.dat b/release/datafiles/blender_icons32/icon32_preset.dat
new file mode 100644
index 00000000000..57d5d2536f1
Binary files /dev/null and b/release/datafiles/blender_icons32/icon32_preset.dat differ
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 3a9704b12e9..6cca60bd49e 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -856,7 +856,8 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
def path_menu(self, searchpaths, operator, *,
props_default=None, prop_filepath="filepath",
- filter_ext=None, filter_path=None, display_name=None):
+ filter_ext=None, filter_path=None, display_name=None,
+ add_operator=None):
"""
Populate a menu from a list of paths.
@@ -902,12 +903,16 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
files.sort()
+ col = layout.column(align=True)
+
for f, filepath in files:
# Intentionally pass the full path to 'display_name' callback,
# since the callback may want to use part a directory in the name.
- props = layout.operator(
+ row = col.row(align=True)
+ name = display_name(filepath) if display_name else bpy.path.display_name(f)
+ props = row.operator(
operator,
- text=display_name(filepath) if display_name else bpy.path.display_name(f),
+ text=name,
translate=False,
)
@@ -919,6 +924,25 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
if operator == "script.execute_preset":
props.menu_idname = self.bl_idname
+ if add_operator:
+ props = row.operator(add_operator, text="", icon='ZOOMOUT')
+ props.name = name
+ props.remove_name = True
+
+ if add_operator:
+ wm = bpy.data.window_managers[0]
+
+ layout.separator()
+ row = layout.row()
+
+ sub = row.row()
+ sub.emboss = 'NORMAL'
+ sub.prop(wm, "preset_name", text="")
+
+ props = row.operator(add_operator, text="", icon='ZOOMIN')
+ props.name = wm.preset_name
+
+
def draw_preset(self, context):
"""
Define these on the subclass:
@@ -926,16 +950,19 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta):
- preset_subdir (string)
Optionally:
+ - preset_add_operator (string)
- preset_extensions (set of strings)
- preset_operator_defaults (dict of keyword args)
"""
import bpy
ext_valid = getattr(self, "preset_extensions", {".py", ".xml"})
props_default = getattr(self, "preset_operator_defaults", None)
+ add_operator = getattr(self, "preset_add_operator", None)
self.path_menu(bpy.utils.preset_paths(self.preset_subdir),
self.preset_operator,
props_default=props_default,
- filter_ext=lambda ext: ext.lower() in ext_valid)
+ filter_ext=lambda ext: ext.lower() in ext_valid,
+ add_operator=add_operator)
@classmethod
def draw_collapsible(cls,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list