Remove obsolete implementation and simplify project structure
This commit is contained in:
76
src/anyimage/menu.py
Normal file
76
src/anyimage/menu.py
Normal file
@@ -0,0 +1,76 @@
|
||||
import bpy
|
||||
|
||||
from .operators.image import is_image_empty
|
||||
|
||||
|
||||
class AnyImageImageMenu(bpy.types.Menu):
|
||||
bl_idname = "ANYIMAGE_MT_image_context"
|
||||
bl_label = "AnyImage"
|
||||
|
||||
def draw(self, _context):
|
||||
from .runtime import runtime
|
||||
from .properties import required_models_ready
|
||||
|
||||
layout = self.layout
|
||||
layout.operator_context = "INVOKE_DEFAULT"
|
||||
layout.operator(
|
||||
"anyimage.activate_balloon_tool",
|
||||
text="Balloon Lasso Tool",
|
||||
icon="MOD_SKIN",
|
||||
)
|
||||
layout.separator()
|
||||
environment_ready = runtime.environment_ready()
|
||||
if not environment_ready:
|
||||
layout.operator(
|
||||
"anyimage.install_environment",
|
||||
text="Install Environment",
|
||||
icon="IMPORT",
|
||||
)
|
||||
layout.operator(
|
||||
"anyimage.install_environment_mirror",
|
||||
text="Install Environment (Mirror)",
|
||||
icon="IMPORT",
|
||||
)
|
||||
models_ready = required_models_ready()
|
||||
if environment_ready and not models_ready:
|
||||
layout.operator(
|
||||
"anyimage.download_required_models",
|
||||
text="Download Required Models",
|
||||
icon="IMPORT",
|
||||
)
|
||||
features_ready = environment_ready and models_ready
|
||||
if not features_ready:
|
||||
layout.separator()
|
||||
depth_plane_row = layout.row()
|
||||
depth_plane_row.enabled = features_ready
|
||||
depth_plane_row.operator(
|
||||
"anyimage.convert_to_depth_plane",
|
||||
text="Convert to Depth Plane",
|
||||
icon="MOD_DISPLACE",
|
||||
)
|
||||
surface_row = layout.row()
|
||||
surface_row.enabled = features_ready
|
||||
surface_row.operator(
|
||||
"anyimage.convert_to_surface",
|
||||
text="Convert to Surface",
|
||||
icon="MESH_GRID",
|
||||
)
|
||||
layout.separator()
|
||||
background_row = layout.row()
|
||||
background_row.enabled = features_ready
|
||||
background_row.operator(
|
||||
"anyimage.remove_image_background",
|
||||
text="Remove Background",
|
||||
icon="IMAGE_ALPHA",
|
||||
)
|
||||
|
||||
|
||||
def draw_image_context_menu(self, context):
|
||||
if not is_image_empty(context.object):
|
||||
return
|
||||
self.layout.separator()
|
||||
self.layout.menu(
|
||||
AnyImageImageMenu.bl_idname,
|
||||
text="AnyImage",
|
||||
icon="PLUGIN",
|
||||
)
|
||||
Reference in New Issue
Block a user