ui: Hide column selectors with columns

main
Sofus Albert Høgsbro Rose 2024-04-26 19:25:42 +02:00
parent b2a7eefb45
commit 82e8e3f348
Signed by: so-rose
GPG Key ID: AD901CB0F3701434
2 changed files with 46 additions and 10 deletions

View File

@ -911,6 +911,8 @@ class MaxwellSimSocket(bpy.types.NodeSocket):
text: The socket's name in the UI. text: The socket's name in the UI.
""" """
col = layout.column() col = layout.column()
# Row: Label
row = col.row() row = col.row()
row.alignment = 'RIGHT' row.alignment = 'RIGHT'
self.draw_output_label_row(row, text) self.draw_output_label_row(row, text)

View File

@ -55,9 +55,13 @@ class DataBLSocket(base.MaxwellSimSocket):
show_info_columns: bool = bl_cache.BLField( show_info_columns: bool = bl_cache.BLField(
True, True,
prop_ui=True, prop_ui=True,
# use_prop_update=False,
) )
info_columns: DataInfoColumn = bl_cache.BLField( info_columns: DataInfoColumn = bl_cache.BLField(
{DataInfoColumn.MathType, DataInfoColumn.Unit}, prop_ui=True, enum_many=True {DataInfoColumn.MathType, DataInfoColumn.Unit},
prop_ui=True,
enum_many=True,
# use_prop_update=False,
) )
#################### ####################
@ -75,12 +79,25 @@ class DataBLSocket(base.MaxwellSimSocket):
# - UI # - UI
#################### ####################
def draw_input_label_row(self, row: bpy.types.UILayout, text) -> None: def draw_input_label_row(self, row: bpy.types.UILayout, text) -> None:
row.label(text=text)
info = self.compute_data(kind=ct.FlowKind.Info) info = self.compute_data(kind=ct.FlowKind.Info)
if not ct.FlowSignal.check(info) and self.format == 'jax' and info.dim_names: has_dims = (
row.prop(self, self.blfields['info_columns']) not ct.FlowSignal.check(info) and self.format == 'jax' and info.dim_names
row.prop( )
if has_dims:
split = row.split(factor=0.85, align=True)
_row = split.row(align=False)
else:
_row = row
_row.label(text=text)
if has_dims:
if self.show_info_columns:
_row.prop(self, self.blfields['info_columns'])
_row = split.row(align=True)
_row.alignment = 'RIGHT'
_row.prop(
self, self,
self.blfields['show_info_columns'], self.blfields['show_info_columns'],
toggle=True, toggle=True,
@ -90,17 +107,34 @@ class DataBLSocket(base.MaxwellSimSocket):
def draw_output_label_row(self, row: bpy.types.UILayout, text) -> None: def draw_output_label_row(self, row: bpy.types.UILayout, text) -> None:
info = self.compute_data(kind=ct.FlowKind.Info) info = self.compute_data(kind=ct.FlowKind.Info)
if not ct.FlowSignal.check(info) and self.format == 'jax' and info.dim_names: has_dims = (
row.prop( not ct.FlowSignal.check(info) and self.format == 'jax' and info.dim_names
)
if has_dims:
split = row.split(factor=0.15, align=True)
_row = split.row(align=True)
_row.prop(
self, self,
self.blfields['show_info_columns'], self.blfields['show_info_columns'],
toggle=True, toggle=True,
text='', text='',
icon=ct.Icon.ToggleSocketInfo, icon=ct.Icon.ToggleSocketInfo,
) )
row.prop(self, self.blfields['info_columns'])
row.label(text=text) _row = split.row(align=False)
_row.alignment = 'RIGHT'
if self.show_info_columns:
_row.prop(self, self.blfields['info_columns'])
else:
_col = _row.column()
_col.alignment = 'EXPAND'
_col.label(text='')
else:
_row = row
_row.label(text=text)
def draw_info(self, info: ct.InfoFlow, col: bpy.types.UILayout) -> None: def draw_info(self, info: ct.InfoFlow, col: bpy.types.UILayout) -> None:
if self.format == 'jax' and info.dim_names and self.show_info_columns: if self.format == 'jax' and info.dim_names and self.show_info_columns: