Skip to content

Commit

Permalink
Use flow_grid for node icons in T panel.
Browse files Browse the repository at this point in the history
Number of columns now defaults to 0 (= Auto) for new installations.
  • Loading branch information
portnov committed Aug 3, 2020
1 parent 88ed79f commit a32b144
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
21 changes: 8 additions & 13 deletions menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,32 +291,27 @@ def __init__(self, parent, columns=4):
super().__init__(parent)
self.columns = columns
self._column = 0
self._row = None

def _tick_column(self):
self._column = (self._column + 1) % self.columns
if self._column == 0:
self._row = None
self._flow = None

def separator(self):
if not self._prev_is_separator:
self._row = None
self._flow = None
self._column = 0
self.parent.separator()
self._prev_is_separator = True

def operator(self, operator_name, **params):
self._prev_is_separator = False
if 'icon_value' in params or 'icon' in params:
if self._row is None:
self._row = self.parent.row(align=True)
self._row.scale_x = self._row.scale_y = 1.5
if self._flow is None:
#self._flow = self.parent.column_flow(columns=self.columns, align=True)
self._flow = self.parent.grid_flow(row_major=True, align=True, columns=self.columns)
self._flow.scale_x = self._flow.scale_y = 1.5
params['text'] = ""
op = self._row.operator(operator_name, **params)
self._tick_column()
op = self._flow.operator(operator_name, **params)
return op
else:
self._row = None
self._flow = None
self._column = 0
return self.parent.operator(operator_name, **params)

Expand Down
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def update_theme(self, context):
name = "Columns",
description = "Number of icon panels per row",
default = 4,
min = 2, max = 12
min = 0, max = 12
)

enable_live_objin: BoolProperty(
Expand Down

0 comments on commit a32b144

Please sign in to comment.