Class: Metro::UI::ModelLabeler
- Defined in:
- lib/metro/models/ui/model_labeler.rb
Overview
The model labeler will draw a bounding box and label around all the scene’s drawers.
The model labeler is used in the edit transition scene to generate the bounding boxes and labeles around all the actors within the scene being edited.
Constant Summary
Constants included from Metro::Units
Instance Attribute Summary collapse
-
#color ⇒ Object
The color use for the border surrounding each actor and the background behind the model’s name.
-
#font ⇒ Object
The font of the model name label.
-
#label_color ⇒ Object
The color of the model name text.
-
#should_draw_bounding_boxes ⇒ Object
Sets whether to draw the bounding boxes around the actors.
-
#should_draw_labels ⇒ Object
Sets whether to draw the model name labels.
-
#should_hide_boundless_actors ⇒ Object
For actors that have no bounds, like sound or custom models without a position, they are normally hidden but can be shown.
Attributes inherited from Model
Instance Method Summary collapse
- #draw ⇒ Object
-
#labels ⇒ Object
Store the labels that are being drawn in the scene.
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from Model
#_load, #_save, #after_initialize, #bounds, #create, #draw_completed?, hierarchy, inherited, #initialize, metro_name, #model, model_name, models, #name, #notification, #saveable_to_view, #to_hash, #update_completed?
Methods included from HasEvents
Methods included from KeyValueCoding
Methods included from PropertyOwner
Constructor Details
This class inherits a constructor from Metro::Model
Instance Attribute Details
#color ⇒ Object
The color use for the border surrounding each actor and the background behind the model’s name.
17 |
# File 'lib/metro/models/ui/model_labeler.rb', line 17 property :color, default: "rgba(255,0,0,0.5)" |
#font ⇒ Object
The font of the model name label.
29 |
# File 'lib/metro/models/ui/model_labeler.rb', line 29 property :font, default: { name: 'Arial', size: 16 } |
#label_color ⇒ Object
The color of the model name text.
25 |
# File 'lib/metro/models/ui/model_labeler.rb', line 25 property :label_color, default: "rgba(255,255,255,1.0)" |
#should_draw_bounding_boxes ⇒ Object
Sets whether to draw the bounding boxes around the actors.
21 |
# File 'lib/metro/models/ui/model_labeler.rb', line 21 property :should_draw_bounding_boxes, type: :boolean, default: true |
#should_draw_labels ⇒ Object
Sets whether to draw the model name labels
33 |
# File 'lib/metro/models/ui/model_labeler.rb', line 33 property :should_draw_labels, type: :boolean, default: true |
#should_hide_boundless_actors ⇒ Object
when enabled the boundless actors should be presented in a cleaner way to allow for easier viewing of them.
For actors that have no bounds, like sound or custom models without a position, they are normally hidden but can be shown. Currently they appear all overlapped in the upper-left corner of the screen.
42 |
# File 'lib/metro/models/ui/model_labeler.rb', line 42 property :should_hide_boundless_actors, type: :boolean, default: true |
Instance Method Details
#draw ⇒ Object
72 73 74 |
# File 'lib/metro/models/ui/model_labeler.rb', line 72 def draw labels.values.each { |label| label.draw } end |
#labels ⇒ Object
Store the labels that are being drawn in the scene. This hash of labels acts as a cache around the items that are being labeled based on the name of the objects that are being labeled.
47 48 49 |
# File 'lib/metro/models/ui/model_labeler.rb', line 47 def labels @labels ||= {} end |
#show ⇒ Object
51 52 53 |
# File 'lib/metro/models/ui/model_labeler.rb', line 51 def show self.saveable_to_view = false end |
#update ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/metro/models/ui/model_labeler.rb', line 55 def update scene.drawers.each do |drawer| next if (drawer.bounds == Bounds.none and should_hide_boundless_actors) label = labels[drawer.name] unless label label = create "metro::ui::model_label", target: drawer labels[drawer.name] = label end label.should_draw_label = should_draw_labels label.should_draw_bounding_box = should_draw_bounding_boxes label.bounds = drawer.bounds end end |