Fixed UI for box alignment

Replaced checkboxes with icons and removed vertical and horizontal space between them, now looks neat.
This commit is contained in:
Andrej730
2023-03-28 19:33:05 +05:00
parent 8d3347c02b
commit 50ba0815f7
2 changed files with 25 additions and 22 deletions
@@ -1236,19 +1236,20 @@ class EditTextPopup(bpy.types.Operator):
attributes = [a for a in literal_props.attributes if a.name != "BoxAlignment"] attributes = [a for a in literal_props.attributes if a.name != "BoxAlignment"]
blenderbim.bim.helper.draw_attributes(attributes, box) blenderbim.bim.helper.draw_attributes(attributes, box)
# a bit hacky way to align box alignment widget row = box.row(align=True)
rows = [box.row(align=True) for i in range(3)] cols = [row.column(align=True) for i in range(3)]
for i in range(9): for i in range(9):
if i % 3 == 0: cols[i % 3].prop(
split = rows[i // 3].split(factor=0.1, align=True) literal_props,
split.column() "box_alignment",
split.prop(literal_props, "box_alignment", text="", index=i) text="",
index=i,
icon="RADIOBUT_ON" if literal_props.box_alignment[i] else "RADIOBUT_OFF",
)
text_lines = ["Text box alignment:", literal_props.attributes["BoxAlignment"].string_value, ""] col = row.column(align=True)
for i in range(3): col.label(text=" Text box alignment:")
split = rows[i].split(factor=0.1, align=False) col.label(text=f' {literal_props.attributes["BoxAlignment"].string_value}')
split.column()
split.label(text=text_lines[i])
def cancel(self, context): def cancel(self, context):
# disable editing when dialog is closed # disable editing when dialog is closed
@@ -373,19 +373,21 @@ class BIM_PT_text(Panel):
attributes = [a for a in literal_props.attributes if a.name != "BoxAlignment"] attributes = [a for a in literal_props.attributes if a.name != "BoxAlignment"]
blenderbim.bim.helper.draw_attributes(attributes, box) blenderbim.bim.helper.draw_attributes(attributes, box)
# a bit hacky way to align box alignment widget row = box.row(align=True)
rows = [box.row(align=True) for i in range(3)] cols = [row.column(align=True) for i in range(3)]
for i in range(9): for i in range(9):
if i % 3 == 0: cols[i % 3].prop(
split = rows[i // 3].split(factor=0.1, align=True) literal_props,
split.column() "box_alignment",
split.prop(literal_props, "box_alignment", text="", index=i) text="",
index=i,
icon="RADIOBUT_ON" if literal_props.box_alignment[i] else "RADIOBUT_OFF",
)
col = row.column(align=True)
col.label(text=" Text box alignment:")
col.label(text=f' {literal_props.attributes["BoxAlignment"].string_value}')
text_lines = ["Text box alignment:", literal_props.attributes["BoxAlignment"].string_value, ""]
for i in range(3):
split = rows[i].split(factor=0.1, align=False)
split.column()
split.label(text=text_lines[i])
else: else:
text_data = DecoratorData.get_ifc_text_data(obj) text_data = DecoratorData.get_ifc_text_data(obj)