Skip to content

Commit

Permalink
feat: Clean up the rearrange projects panel (a bit)
Browse files Browse the repository at this point in the history
Some rearrange operators are not displayed by default (but can be enabled), to make the rearrange panel less cluttered. Attempt to find a better solution in the future! This depends on Blender adding support for custom panel stacks with drag and drop.

fix #34
  • Loading branch information
BlenderDefender committed May 23, 2024
1 parent ab4baee commit 3fc955a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 26 deletions.
6 changes: 4 additions & 2 deletions addon_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ class AddonPreferences():

preview_subfolders: bool
"""Show the compiled subfolder-strings in the preferences,
defaults to False
)"""
defaults to False"""

enable_additional_rearrange_tools: bool
"""Show the "Move to top" and "Move to bottom" operators in the rearrange panel,
defaults to False"""

class ProjectFolderProps():

Expand Down
54 changes: 30 additions & 24 deletions panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import os
from os import path as p

from typing import List

from .addon_types import AddonPreferences

from .functions.main_functions import is_file_in_project_folder
Expand Down Expand Up @@ -78,9 +80,7 @@ def draw(self, context: Context):
row.label(text="Project Name")

row = layout.row()
row.prop(context.scene,
"project_name",
text="")
row.prop(context.scene, "project_name", text="")

layout.separator(factor=0.5)

Expand Down Expand Up @@ -245,7 +245,7 @@ class SUPER_PROJECT_MANAGER_PT_Open_Projects_subpanel(Panel):
def draw(self, context: Context):
layout: UILayout = self.layout

data = decode_json(BPS_DATA_FILE)["unfinished_projects"]
data: List[List[str]] = decode_json(BPS_DATA_FILE)["unfinished_projects"]

project_count = len([e for e in data if e[0] == "project"])
layout.label(
Expand Down Expand Up @@ -360,6 +360,8 @@ def draw_normal(self, context: Context, data):
# Drawing Function for the project rearrange mode.
def draw_rearrange(self, context: Context, data):
layout: UILayout = self.layout
prefs: 'AddonPreferences' = context.preferences.addons[__package__.split(".")[0]].preferences


for index, entry in enumerate(data):
type = entry[0]
Expand All @@ -381,29 +383,33 @@ def draw_rearrange(self, context: Context, data):
icon="FILE_TEXT")
op.index = index

op = row.operator("super_project_manager.rearrange_to_top",
text="",
emboss=False,
icon="EXPORT")
op.index = index
if index > 0 and prefs.enable_additional_rearrange_tools:
op = row.operator("super_project_manager.rearrange_to_top",
text="",
emboss=False,
icon="EXPORT")
op.index = index

op = row.operator("super_project_manager.rearrange_up",
text="",
emboss=False,
icon="SORT_DESC")
op.index = index
if index > 0:
op = row.operator("super_project_manager.rearrange_up",
text="",
emboss=False,
icon="SORT_DESC")
op.index = index

op = row.operator("super_project_manager.rearrange_down",
text="",
emboss=False,
icon="SORT_ASC")
op.index = index
if index < len(data) - 1:
op = row.operator("super_project_manager.rearrange_down",
text="",
emboss=False,
icon="SORT_ASC")
op.index = index

op = row.operator("super_project_manager.rearrange_to_bottom",
text="",
emboss=False,
icon="IMPORT")
op.index = index
if index < len(data) - 1 and prefs.enable_additional_rearrange_tools:
op = row.operator("super_project_manager.rearrange_to_bottom",
text="",
emboss=False,
icon="IMPORT")
op.index = index


class SUPER_PROJECT_MANAGER_PT_filebrowser_project_paths(Panel):
Expand Down
9 changes: 9 additions & 0 deletions prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ class SUPER_PROJECT_MANAGER_APT_Preferences(AddonPreferences):
default=False
)

enable_additional_rearrange_tools: BoolProperty(
name="Enable additional rearrange operators",
description="Enable the 'Move to top' and 'Move to bottom' operator. This will make the rearrange panel more crowded",
default=False
)

auto_check_update: BoolProperty(
name="Auto-check for Update",
description="If enabled, auto-check for updates using an interval",
Expand Down Expand Up @@ -268,6 +274,9 @@ def draw_misc_settings(self, context: Context, layout: UILayout):

layout.prop(self, "auto_set_render_outputpath",
text="Automatically set the render output path")
layout.separator(factor=0.4)

layout.prop(self, "enable_additional_rearrange_tools")

def draw_folder_structure_sets(self, context: Context, layout: UILayout):
layout.label(text="Folder Structure Set")
Expand Down

0 comments on commit 3fc955a

Please sign in to comment.