Preferences: fit a little better when opened in place of properties editor.

This commit is contained in:
2019-01-17 14:31:18 +01:00
parent be079e742d
commit 1a3abc7f79
3 changed files with 20 additions and 1 deletions

View File

@@ -35,6 +35,10 @@ class USERPREF_HT_header(Header):
layout.template_header()
layout.separator_spacer()
layout.operator("wm.save_userpref")
class USERPREF_PT_navigation_bar(Panel):
bl_label = "Preferences Navigation"
@@ -60,6 +64,15 @@ class USERPREF_PT_save_preferences(Panel):
bl_region_type = 'EXECUTE'
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
# Hide when header is visible
for region in context.area.regions:
if region.type == 'HEADER' and region.height <= 1:
return True
return False
def draw(self, _context):
layout = self.layout
layout.operator_context = 'EXEC_AREA'

View File

@@ -226,6 +226,7 @@ enum {
#define UI_PANEL_WIDTH 340
#define UI_COMPACT_PANEL_WIDTH 160
#define UI_NAVIGATION_REGION_WIDTH UI_COMPACT_PANEL_WIDTH
#define UI_NARROW_NAVIGATION_REGION_WIDTH 100
#define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f)

View File

@@ -53,7 +53,7 @@
/* ******************** default callbacks for userpref space ***************** */
static SpaceLink *userpref_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
static SpaceLink *userpref_new(const ScrArea *area, const Scene *UNUSED(scene))
{
ARegion *ar;
SpaceUserPref *spref;
@@ -76,6 +76,11 @@ static SpaceLink *userpref_new(const ScrArea *UNUSED(area), const Scene *UNUSED(
ar->regiontype = RGN_TYPE_NAV_BAR;
ar->alignment = RGN_ALIGN_LEFT;
/* Use smaller size when opened in area like properties editor. */
if (area->winx && area->winx < 3.0f * UI_NAVIGATION_REGION_WIDTH * UI_DPI_FAC) {
ar->sizex = UI_NARROW_NAVIGATION_REGION_WIDTH;
}
/* execution region */
ar = MEM_callocN(sizeof(ARegion), "execution region for userpref");