[Bf-blender-cvs] [2e3fdeb54c9] userpref_redesign: Avoid panel content margins in small regions

Severin noreply at git.blender.org
Sat Dec 29 16:44:25 CET 2018


Commit: 2e3fdeb54c9c0b144e82e34d7c41dc86554ca67e
Author: Severin
Date:   Sat Dec 29 16:38:55 2018 +0100
Branches: userpref_redesign
https://developer.blender.org/rB2e3fdeb54c9c0b144e82e34d7c41dc86554ca67e

Avoid panel content margins in small regions

Don't see a need for changes in the layout system here, a simple trick
like I've done here is sufficient.
Also: Some refactoring of the `PreferencePanel` class.

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

M	release/scripts/startup/bl_ui/space_userpref.py

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 658f059fc07..dfdc09dc325 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -75,29 +75,33 @@ class USERPREF_PT_save_preferences(Panel):
 
 
 class PreferencePanel(Panel):
+    """
+    Base class for panels to center align contents with some horizontal margin.
+    Deriving classes need to implement a ``draw_props(context, layout)`` function.
+    """
+
     bl_space_type = 'PREFERENCES'
     bl_region_type = 'WINDOW'
 
-    def draw_props(self, context, layout):
-        # Deriving classes should implement this.
-        # TODO use abc module for abstract method support?
-        pass
-
     def draw(self, context):
         layout = self.layout
+        width = context.region.width
 
         layout.use_property_split = True
         layout.use_property_decorate = False  # No animation.
 
         row = layout.row()
-        row.label()
+        if width > 350: # No horizontal margin if region is rather small.
+            row.label() # Needed so col below is centered.
 
         col = row.column()
         col.ui_units_x = 50
 
+        # draw_props implemented by deriving classes.
         self.draw_props(context, col)
 
-        row.label() # Needed so col above is centered.
+        if width > 350: # No horizontal margin if region is rather small.
+            row.label() # Needed so col above is centered.
 
 
 class USERPREF_PT_interface_display(PreferencePanel):



More information about the Bf-blender-cvs mailing list