Class: ModraUp::Overlay
- Inherits:
-
Object
- Object
- ModraUp::Overlay
Overview
Viewport overlay layer. Not a ModraUp::Entity. Subclasses implement draw / mouse callbacks, then add to the model via ModraUp::OverlaysManager#add. The overlay layer is enabled by checking it in the 'Window › Tray Window › Overlays' menu; once #enabled= is true, the viewport calls draw(view) every time it refreshes. The overlay layer's drawings cannot be picked or exported.
Each model has a ModraUp::OverlaysManager. To appear in all documents, create an instance in ModraUp::AppObserver and add it in onNewModel / onOpenModel.
Class Method Summary # collapse
-
.new(id, name, description: "") ⇒ ModraUp::Overlay
Construct with source inferred by call stack #source: take the extension name of the registered file folder where the calling file is located.
Instance Method Summary # collapse
-
#overlay_id ⇒ String
The unique ID passed during construction.
-
#name ⇒ String
Panel display name.
-
#description ⇒ String
Panel description, displayed below the list when this line is selected.
-
#description= ⇒ String
Modify the description. The overlay refreshes in the viewport when added to the model.
-
#enabled? ⇒ Boolean
Enabled or not. It is false before ModraUp::OverlaysManager#add.
- #enabled= ⇒ Boolean
-
#valid? ⇒ Boolean
After removing an overlay with ModraUp::OverlaysManager#remove, its validity becomes false and it cannot be added back.
-
#source ⇒ String
The overlay layer comes from which extension: determined by the SketchupExtension#name found at the time of construction. It is displayed in the tray as "Extension: Name". If not in any registered extension's folder (e.g., created in the Ruby console), it is an empty string.
-
#start ⇒ nil
Called when the overlay is enabled through its checkbox or #enabled=. Attach observers and prepare caches here. The base implementation does nothing.
-
#stop ⇒ nil
Called when the overlay is disabled or removed through ModraUp::OverlaysManager#remove while enabled. Detach observers and clear caches here. The base implementation does nothing.
-
#draw(view) ⇒ nil
Callback (subclass implementation): Called every time the viewport is refreshed while the overlay is active. Only draw the cached data and do not perform any recomputation here.
-
#onMouseMove(flags, x, y, view) ⇒ nil
Implement this callback to track pointer motion within the viewport while the overlay is enabled, regardless of the active tool. Coordinates are in logical pixels. Keep this frequent callback lightweight.
-
#onMouseEnter(flags, x, y, view) ⇒ nil
Called when the pointer enters the viewport while the overlay is enabled. Implement this callback in a subclass.
-
#onMouseLeave(view) ⇒ nil
Called when the pointer leaves the viewport while the overlay is enabled. Implement this callback in a subclass.
-
#inspect ⇒ String
Returns a string of the form #<Sketchup::Overlay:0x...>, omitting instance variables.
Class Method Details
Overlay.new(id, name, description: "") ⇒ overlay
Construct with source inferred by call stack #source: take the extension name of the registered file folder where the calling file is located.
Instance Method Details
overlay.overlay_id ⇒ String
The unique ID passed during construction.
overlay.name ⇒ String
Panel display name.
overlay.description ⇒ String
Panel description, displayed below the list when this line is selected.
overlay.description = text ⇒ String
Modify the description. The overlay refreshes in the viewport when added to the model.
overlay.enabled? ⇒ Boolean
Enabled or not. It is false before ModraUp::OverlaysManager#add.
overlay.enabled = flag ⇒ Boolean
overlay.valid? ⇒ Boolean
After removing an overlay with ModraUp::OverlaysManager#remove, its validity becomes false and it cannot be added back.
overlay.source ⇒ String
The overlay layer comes from which extension: determined by the SketchupExtension#name found at the time of construction. It is displayed in the tray as "Extension: Name". If not in any registered extension's folder (e.g., created in the Ruby console), it is an empty string.
overlay.start ⇒ nil
Called when the overlay is enabled through its checkbox or #enabled=. Attach observers and prepare caches here. The base implementation does nothing.
overlay.stop ⇒ nil
Called when the overlay is disabled or removed through ModraUp::OverlaysManager#remove while enabled. Detach observers and clear caches here. The base implementation does nothing.
overlay.draw(view) ⇒ nil
Callback (subclass implementation): Called every time the viewport is refreshed while the overlay is active. Only draw the cached data and do not perform any recomputation here. Overlay layers are drawn in the order of the tray list from top to bottom, with later-drawn layers overlaying earlier-drawn ones.
overlay.onMouseMove(flags, x, y, view) ⇒ nil
Implement this callback to track pointer motion within the viewport while the overlay is enabled, regardless of the active tool. Coordinates are in logical pixels. Keep this frequent callback lightweight.
overlay.onMouseEnter(flags, x, y, view) ⇒ nil
Called when the pointer enters the viewport while the overlay is enabled. Implement this callback in a subclass.
overlay.onMouseLeave(view) ⇒ nil
Called when the pointer leaves the viewport while the overlay is enabled. Implement this callback in a subclass.
overlay.inspect ⇒ String
Returns a string of the form #<Sketchup::Overlay:0x...>, omitting instance variables.