Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier Gizmo Menu settings #47

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

MustafaJafar
Copy link
Contributor

@MustafaJafar MustafaJafar commented Nov 25, 2024

Changelog Description

resolve #46

  • Enhance settings
  • Enhance loading logic here.

Note

Settings in this PR should be backward compatible. i.e. it shouldn't break copy settings.
If it's not please report.

Demo

Settings:

  • Mode 1: Add a Gizmo Directory Path
    image
  • Mode 2: Add Gizmos By definitions
    image

Testing notes:

  1. Try different Gizmo Menu options
  2. When launching Nuke, Gizmo should be added as configured in the settings.

@MustafaJafar MustafaJafar added the type: enhancement Improvement of existing functionality or minor addition label Nov 25, 2024
@MustafaJafar MustafaJafar self-assigned this Nov 25, 2024
@MustafaJafar MustafaJafar marked this pull request as draft November 25, 2024 14:33
@MustafaJafar
Copy link
Contributor Author

MustafaJafar commented Nov 25, 2024

Loading logic enhancement boils down to
But, I didn't add to the PR. (I didn't test adding a source dir. I only tested adding gizmos by list)

import nuke 
import platform

from ayon_core.pipeline import get_current_project_name
from ayon_core.settings import get_current_project_settings
from ayon_core.resources import get_ayon_icon_filepath
from ayon_nuke.api.gizmo_menu import GizmoMenu

# load configuration of custom menu
project_name = get_current_project_name()
project_settings = get_current_project_settings()
platform_name = platform.system().lower()


for gizmo_settings in project_settings["nuke"]["gizmo"]:
    # Get the toolbar.
    toolbar_name = gizmo_settings["toolbar_menu_name"]
    toolbar_icon_path = gizmo_settings.get(
        "toolbar_icon_path", {}).get(platform_name)

    # Create the toolbar
    toolbar_menu = GizmoMenu(
            title=toolbar_name,
            icon=toolbar_icon_path or get_ayon_icon_filepath()
        )

    # Add gizmos based on options
    option = gizmo_settings["options"]
    if option == "gizmo_source_dir":
        gizmo_paths_to_add = gizmo_settings[option]
        toolbar_menu.add_gizmo_path(gizmo_paths_to_add)
    elif option == "gizmo_definition":
        toolbar_menu.build_from_configuration(gizmo_settings["gizmo_definition"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvement of existing functionality or minor addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gizmo Menu Nuke Addon Setting
1 participant