Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.6

0.11.6 / src / shelf_context.luc

## The viewport tool shelf's contexts (shelf_tabs.luc lists each one's
## tabs): apart from the tabs so the chrome can ask without the sketch
## editor's imports.
from workspace import Workspace
import tool_menus
import edit_mesh
import edit_cad

## The shelf's context where the viewport is ("" none: no shelf): a
## sketch, Edit Mesh, Edit CAD, a CAD network or a geometry network. The
## shelf remembers its tab per context.
pub func context_of(w: Workspace) -> str:
    if w.sketching():
        return "sketch"
    if w.editing():
        let node = w.selected() else return ""
        if node.kind == edit_mesh.kind_name:
            return "edit mesh"
        if node.kind == edit_cad.kind_name:
            return "edit cad"
        return ""
    let context = w.network.context()
    if context == "cad":
        return "cad"
    if context == "geometry" and tool_menus.from_registry(w):
        return "geometry"
    return ""