Skip to content

Commit

Permalink
CHANGE: Show remove assets progress bar in side panel
Browse files Browse the repository at this point in the history
  • Loading branch information
zachEastin committed Aug 16, 2024
1 parent adfb519 commit 8b44b2a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 39 deletions.
3 changes: 2 additions & 1 deletion ops/add_to_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ def invoke(self, context, event):
utils.ensure_sidepanel_right_is_open(context.space_data)

sets: "scene.SH_Scene" = context.scene.superhive
self.prog = sets.header_progress_bar
self.prog = sets.remove_assets_progress_bar
self.prog.label = "Removing Assets"
self.prog.start()

self._thread.start()
Expand Down
61 changes: 23 additions & 38 deletions settings/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class RenderThumbnailProps:

flip_y: BoolProperty(name="Flip Y", default=False)

thumb_res: IntProperty(
default=256, min=128, max=1024, subtype="PIXEL", name="Resolution"
)
thumb_res: IntProperty(default=256, min=128, max=1024, subtype="PIXEL", name="Resolution")

camera_height: FloatProperty(
default=1.0,
Expand Down Expand Up @@ -320,11 +318,7 @@ def process_text(self, text: str) -> str:
case "OVERWRITE":
return self.value
case "ADD":
return (
text + self.value
if self.add_type == "SUFFIX"
else self.value + text
)
return text + self.value if self.add_type == "SUFFIX" else self.value + text
case "REPLACE":
if self.use_regex_find:
replace_src = self.value
Expand Down Expand Up @@ -458,11 +452,7 @@ class BatchMetadataUpdate(PropertyGroup, RenderThumbnailProps):
)

def _get_ignore_licenses(self, context):
self.metadata_items: (
bpy.types.CollectionProperty
| list[BatchItemWithActions]
| dict[str, BatchItemWithActions]
)
self.metadata_items: bpy.types.CollectionProperty | list[BatchItemWithActions] | dict[str, BatchItemWithActions]
return [
("IGNORE", "Ignore", "Ignore the license"),
] + hive_mind.get_licenses()
Expand Down Expand Up @@ -574,9 +564,7 @@ def draw_metadata_settings(self, context: Context, layout: UILayout, use_ops: bo
for i, tag in enumerate(hive_mind.get_tags()):
grid.prop(self, "tags", index=i, text=tag[1], expand=True)
case _:
meta_data_item: BatchItemWithActions = self.metadata_items.get(
self.metadata_type
)
meta_data_item: BatchItemWithActions = self.metadata_items.get(self.metadata_type)
meta_data_item.draw(layout, use_ops=use_ops)

box = layout.box()
Expand All @@ -591,11 +579,7 @@ def draw_metadata_settings(self, context: Context, layout: UILayout, use_ops: bo
+ ": "
+ meta_data_item.process_text(
getattr(
(
asset
if self.metadata_type == "name"
else asset.metadata
),
(asset if self.metadata_type == "name" else asset.metadata),
self.metadata_type,
)
)
Expand All @@ -605,9 +589,7 @@ def draw_metadata_settings(self, context: Context, layout: UILayout, use_ops: bo

def process_tags(self, asset: utils.Asset):
selected_tags = [
tag_id
for i, (tag_id, _tag_name, _tag_desc) in enumerate(hive_mind.get_tags())
if self.tags[i]
tag_id for i, (tag_id, _tag_name, _tag_desc) in enumerate(hive_mind.get_tags()) if self.tags[i]
]
if self.tags_update_type == "OVERWRITE":
return sorted(selected_tags)
Expand Down Expand Up @@ -657,9 +639,7 @@ def process_asset_metadata(
cat_file: "utils.CatalogsFile"
if "/" in catalog_simple_name:
name = catalog_simple_name.split("/")[-1]
cat = cat_file.add_catalog(
name, path=catalog_simple_name
)
cat = cat_file.add_catalog(name, path=catalog_simple_name)
else:
cat = cat_file.add_catalog(catalog_simple_name)
asset.catalog_id = cat.id
Expand Down Expand Up @@ -693,6 +673,7 @@ class ProgressBarBase:
show: BoolProperty()
label: StringProperty()
"""Label for the progress bar. This is the text that will be displayed on the progress bar."""
show_label_in_bar: BoolProperty(default=False)

formated_time: StringProperty()
start_time: StringProperty()
Expand Down Expand Up @@ -747,9 +728,17 @@ def update_formated_time(self) -> None:

def draw(self, layout: UILayout, draw_time: bool = False) -> None:
row = layout.row(align=True)
row.progress(
text=self.label or f"{round(self.progress * 100, 2)}%", factor=self.progress
)

if not self.show_label_in_bar and self.label:
r = row.row(align=True)
r.alignment = "LEFT"
r.label(text=self.label)

if self.show_label_in_bar and self.label:
label = self.label
else:
label = f"{round(self.progress * 100, 2)}%"
row.progress(text=label, factor=self.progress)

if draw_time:
row.label(text=self.formated_time)
Expand All @@ -776,11 +765,7 @@ def active_bar(self) -> ProgressBarForMulti:
return self.progress_bars[self.active_bar_index]

def new_progress_bar(self, name: str) -> ProgressBarForMulti:
self.progress_bars: (
bpy.types.CollectionProperty
| list[ProgressBarForMulti]
| dict[str, ProgressBarForMulti]
)
self.progress_bars: bpy.types.CollectionProperty | list[ProgressBarForMulti] | dict[str, ProgressBarForMulti]
self.total_progress: ProgressBar
pb: ProgressBarForMulti = self.progress_bars.add()
pb.name = name
Expand Down Expand Up @@ -1006,9 +991,8 @@ def draw(self, layout: UILayout) -> None:

class SH_Scene(PropertyGroup):
header_progress_bar: PointerProperty(type=ProgressBar)
side_panel_batch_asset_update_progress_bar: PointerProperty(
type=MultiProgressBarUpdate_Assets
)
remove_assets_progress_bar: PointerProperty(type=ProgressBar)
side_panel_batch_asset_update_progress_bar: PointerProperty(type=MultiProgressBarUpdate_Assets)

export_library: PointerProperty(type=MultiProgressBarExportLibrary)

Expand Down Expand Up @@ -1037,6 +1021,7 @@ class SH_Scene(PropertyGroup):
def __ignore__(self):
self.metadata_update: BatchMetadataUpdate
self.header_progress_bar: ProgressBar
self.remove_assets_progress_bar: ProgressBar
self.side_panel_batch_asset_update_progress_bar: MultiProgressBarUpdate_Assets
self.export_library: MultiProgressBarExportLibrary

Expand Down
2 changes: 2 additions & 0 deletions ui/asset_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def draw(self, context):
scene_sets.side_panel_batch_asset_update_progress_bar.draw(layout)
elif scene_sets.export_library.show:
scene_sets.export_library.draw(layout)
elif scene_sets.remove_assets_progress_bar.show:
scene_sets.remove_assets_progress_bar.draw(layout)
elif not context.selected_assets:
row = layout.row()
row.alignment = "CENTER"
Expand Down

0 comments on commit 8b44b2a

Please sign in to comment.