Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-13 04:41:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-13 05:32:10 +0300
commit100854c17c057823aa9e8720369a2940be9138f4 (patch)
tree34b6f69b98339c4e114e158157a15128a44d9474 /release/scripts/startup/bl_ui/utils.py
parent88fe48b56a2e36907fa4100fbbd77324cc0218c7 (diff)
UI: rename PresetMenu to PresetPanel, move to bl_ui.utils
Confusing to call a menu a panel when subclasses need to define panel specific variables. Avoid having bl_ui depend on bl_operator module too. Since this isn't an operator, add utils modules for shared types.
Diffstat (limited to 'release/scripts/startup/bl_ui/utils.py')
-rw-r--r--release/scripts/startup/bl_ui/utils.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/utils.py b/release/scripts/startup/bl_ui/utils.py
new file mode 100644
index 00000000000..8c7ceefecb6
--- /dev/null
+++ b/release/scripts/startup/bl_ui/utils.py
@@ -0,0 +1,56 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+
+from bpy.types import Menu
+
+
+# Panel mix-in class (don't register).
+class PresetPanel:
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'HEADER'
+ bl_label = "Presets"
+ path_menu = Menu.path_menu
+
+ @classmethod
+ def draw_panel_header(cls, layout):
+ layout.emboss = 'NONE'
+ layout.popover(
+ panel=cls.__name__,
+ icon='PRESET',
+ text="",
+ )
+
+ @classmethod
+ def draw_menu(cls, layout, text=None):
+ if text is None:
+ text = cls.bl_label
+
+ layout.popover(
+ panel=cls.__name__,
+ icon='PRESET',
+ text=text,
+ )
+
+ def draw(self, context):
+ layout = self.layout
+ layout.emboss = 'PULLDOWN_MENU'
+ layout.operator_context = 'EXEC_DEFAULT'
+
+ Menu.draw_preset(self, context)