Skip to content

Commit

Permalink
Add quick selection of filtered subfixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Sep 5, 2024
1 parent 0a383d4 commit 46454a8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
4 changes: 4 additions & 0 deletions dmx_temp_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
_ = DMX_Lang._

class DMX_TempData(PropertyGroup):
filtered_subfixtures=[]

def set_filtered_subfixtures(self, subs):
DMX_TempData.filtered_subfixtures = subs

def onUpdateCollections(self, context):
dmx = context.scene.dmx
Expand Down
35 changes: 32 additions & 3 deletions panels/subfixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@ def draw_item(self, context, layout, data, item, icon, active_data, active_propn
layout.alignment = "CENTER"
layout.label(text=str(item.id), icon=icon)

def filter_items(self, context, data, propname):
#temp_data = bpy.context.window_manager.dmx
vgroups = getattr(data, propname)
helper_funcs = bpy.types.UI_UL_list
temp_data = bpy.context.window_manager.dmx

# Default return values.
flt_flags = []
flt_neworder = []

flt_flags = helper_funcs.filter_items_by_name(self.filter_name, self.bitflag_filter_item, vgroups, "name")
if not flt_flags:
flt_flags = [self.bitflag_filter_item] * len(vgroups)
temp_data.set_filtered_subfixtures(flt_flags)
return flt_flags,[]

class DMX_OT_Subfixture_SelectVisible(Operator):
bl_label = _("Select visible")
bl_idname = "dmx.select_visible_subfixtures"
bl_description = _("Select visible subfixtures")
bl_options = {"UNDO"}

def execute(self, context):
temp_data = bpy.context.window_manager.dmx
for fixture, enabled in zip(temp_data.subfixtures, temp_data.filtered_subfixtures):
if enabled:
fixture.enabled = True
return {"FINISHED"}

class DMX_OT_Subfixture_Clear(Operator):
bl_label = _("Clear selection")
Expand Down Expand Up @@ -78,10 +106,11 @@ def draw(self, context):
selected = ",".join([s.name for s in temp_data.active_subfixtures])
row = layout.row()
col1 = row.column()
if selected:
col1.label(text=f"Selected: {selected}")
col1.label(text=f"Selected: {len(selected)} {selected}")
col2 = row.column()
col2.operator("dmx.clear_subfixtures", icon="CHECKBOX_DEHLT", text="")
col3 = row.column()
col2.operator("dmx.select_visible_subfixtures", icon="CHECKBOX_HLT", text="")
col3.operator("dmx.clear_subfixtures", icon="CHECKBOX_DEHLT", text="")

class DMX_Subfixture(PropertyGroup):
name: StringProperty()
Expand Down

0 comments on commit 46454a8

Please sign in to comment.