Add Text Literal re-ordering #3643

This commit is contained in:
mat
2024-06-27 03:38:26 +01:00
committed by Dion Moult
parent 48d058a32a
commit a98cddf676
3 changed files with 32 additions and 0 deletions
@@ -71,6 +71,8 @@ classes = (
operator.OpenReference,
operator.OpenSchedule,
operator.OpenSheet,
operator.OrderTextLiteralDown,
operator.OrderTextLiteralUp,
operator.ReloadDrawingStyles,
operator.RemoveDrawing,
operator.RemoveDrawingFromSheet,
@@ -2352,6 +2352,32 @@ class RemoveTextLiteral(bpy.types.Operator):
return {"FINISHED"}
class OrderTextLiteralUp(bpy.types.Operator):
bl_idname = "bim.order_text_literal_up"
bl_label = "Move Text Literal Up"
bl_options = {"REGISTER", "UNDO"}
literal_prop_id: bpy.props.IntProperty()
def execute(self, context):
obj = context.active_object
obj.BIMTextProperties.literals.move(self.literal_prop_id, self.literal_prop_id - 1)
return {"FINISHED"}
class OrderTextLiteralDown(bpy.types.Operator):
bl_idname = "bim.order_text_literal_down"
bl_label = "Move Text Literal Down"
bl_options = {"REGISTER", "UNDO"}
literal_prop_id: bpy.props.IntProperty()
def execute(self, context):
obj = context.active_object
obj.BIMTextProperties.literals.move(self.literal_prop_id, self.literal_prop_id + 1)
return {"FINISHED"}
class AssignSelectedObjectAsProduct(bpy.types.Operator):
bl_idname = "bim.assign_selected_as_product"
bl_label = "Assign Selected Object As Product"
@@ -525,6 +525,10 @@ class BIM_PT_text(Panel):
row = box.row(align=True)
row.label(text=f"Literal[{i}]:")
if i > 0:
row.operator("bim.order_text_literal_up", icon="TRIA_UP", text="").literal_prop_id = i
if i < len(props.literals) - 1:
row.operator("bim.order_text_literal_down", icon="TRIA_DOWN", text="").literal_prop_id = i
row.operator("bim.remove_text_literal", icon="X", text="").literal_prop_id = i
# skip BoxAlignment since we're going to format it ourselves