[Bf-blender-cvs] [e4fb564c543] profiler-editor: add buttons to header

Jacques Lucke noreply at git.blender.org
Thu Apr 29 11:30:48 CEST 2021


Commit: e4fb564c543993f21199423256d6c058c712d562
Author: Jacques Lucke
Date:   Tue Apr 27 15:50:04 2021 +0200
Branches: profiler-editor
https://developer.blender.org/rBe4fb564c543993f21199423256d6c058c712d562

add buttons to header

===================================================================

M	release/scripts/startup/bl_operators/__init__.py
A	release/scripts/startup/bl_operators/profiler.py
M	release/scripts/startup/bl_ui/space_profiler.py

===================================================================

diff --git a/release/scripts/startup/bl_operators/__init__.py b/release/scripts/startup/bl_operators/__init__.py
index 078b32f5e2a..42ef1b632c8 100644
--- a/release/scripts/startup/bl_operators/__init__.py
+++ b/release/scripts/startup/bl_operators/__init__.py
@@ -42,6 +42,7 @@ _modules = [
     "object_quick_effects",
     "object_randomize_transform",
     "presets",
+    "profiler",
     "rigidbody",
     "screen_play_rendered_anim",
     "sequencer",
diff --git a/release/scripts/startup/bl_operators/profiler.py b/release/scripts/startup/bl_operators/profiler.py
new file mode 100644
index 00000000000..63ec01f3c27
--- /dev/null
+++ b/release/scripts/startup/bl_operators/profiler.py
@@ -0,0 +1,70 @@
+# ##### 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 #####
+
+from __future__ import annotations
+
+import bpy
+
+
+class PROFILE_OT_enable(bpy.types.Operator):
+    bl_idname = "profile.enable"
+    bl_label = "Enable Profiling"
+    bl_options = {'REGISTER'}
+
+    @classmethod
+    def poll(cls, context):
+        return context.area.type == 'PROFILER'
+
+    def execute(self, context):
+        sprofiler = context.space_data
+        sprofiler.profile_enable()
+        return {'FINISHED'}
+
+class PROFILE_OT_disable(bpy.types.Operator):
+    bl_idname = "profile.disable"
+    bl_label = "Disable Profiling"
+    bl_options = {'REGISTER'}
+
+    @classmethod
+    def poll(cls, context):
+        return context.area.type == 'PROFILER'
+
+    def execute(self, context):
+        sprofiler = context.space_data
+        sprofiler.profile_disable()
+        return {'FINISHED'}
+
+class PROFILE_OT_clear(bpy.types.Operator):
+    bl_idname = "profile.clear"
+    bl_label = "Clear Profile Data"
+    bl_options = {'REGISTER'}
+
+    @classmethod
+    def poll(cls, context):
+        return context.area.type == 'PROFILER'
+
+    def execute(self, context):
+        sprofiler = context.space_data
+        sprofiler.profile_clear()
+        return {'FINISHED'}
+
+classes = (
+    PROFILE_OT_enable,
+    PROFILE_OT_disable,
+    PROFILE_OT_clear,
+)
diff --git a/release/scripts/startup/bl_ui/space_profiler.py b/release/scripts/startup/bl_ui/space_profiler.py
index 0ecf6190d56..10c765e0c1a 100644
--- a/release/scripts/startup/bl_ui/space_profiler.py
+++ b/release/scripts/startup/bl_ui/space_profiler.py
@@ -23,9 +23,17 @@ class PROFILER_HT_header(bpy.types.Header):
 
     def draw(self, context):
         layout = self.layout
+        sprofiler = context.space_data
 
         layout.template_header()
 
+        if sprofiler.profile_is_enabled:
+            layout.operator("profile.disable")
+        else:
+            layout.operator("profile.enable")
+
+        layout.operator("profile.clear")
+
 
 classes = (
     PROFILER_HT_header,



More information about the Bf-blender-cvs mailing list