Class | Limelight::Stage |
In: |
lib/limelight/stage.rb
|
Parent: | Object |
In the metephorical sense, a Stage is a platform which may hold a scene. In a more, to-the-point sence, a Stage represents a window on the computer screen. The Stage objects within a Production are configured by the StagesBuilder. By default a Production will have one Stage. A Stage may open any number of Scenes but it may only have one current scene loaded at a time.
current_scene | [R] | |
default_scene | [RW] | |
frame | [R] | |
name | [R] | |
theater | [R] |
To create a new Stage, it be given a Theater to which it belongs, and the name is optional. If no name is provided it will default to ‘default’. A stage name must be unique, so it is recommended you provide a name.
# File lib/limelight/stage.rb, line 26 26: def initialize(theater, name, options = {}) 27: @theater = theater 28: @name = name 29: build_frame 30: self.title = @name 31: apply_options(options) 32: end
Invoked when the stage has become the active stage on the desktop. Only 1 stage my be active at a time. System hook that should NOT be called by you.
# File lib/limelight/stage.rb, line 306 306: def activated(e) 307: @theater.stage_activated(self) 308: end
Pops up a simple modal dialog with the provided message.
# File lib/limelight/stage.rb, line 231 231: def alert(message) 232: Thread.new do 233: begin 234: Context.instance.studio.utilities_production.alert(message) 235: rescue StandardError => e 236: puts "Error on alert: #{e}" 237: end 238: end 239: end
When true, the stage will remain on top of all other windows.
# File lib/limelight/stage.rb, line 162 162: def always_on_top=(value) 163: @frame.always_on_top = value 164: end
Return true if the stage has been set to always be on top.
# File lib/limelight/stage.rb, line 168 168: def always_on_top? 169: return @frame.always_on_top 170: end
Returns the background color of the stage in the format RRGGBB(AA)
# File lib/limelight/stage.rb, line 143 143: def background_color 144: return @frame.background_color 145: end
Sets the background color of the stage
# File lib/limelight/stage.rb, line 137 137: def background_color=(value) 138: @frame.background_color = value.to_s 139: end
Opens a file chooser window to select a file on the file system. Options may include:
# File lib/limelight/stage.rb, line 223 223: def choose_file(options={}, &block) 224: options[:parent] = @frame 225: chooser = FileChooser.new(options, &block) 226: return chooser.choose_file 227: end
Invoked when the stage has lost status as the active stage. Only 1 stage my have focus at a time. System hook that should NOT be called by you.
# File lib/limelight/stage.rb, line 313 313: def deactivated(e) 314: @theater.stage_deactivated(self) 315: end
Invoked when the stage has been deiconified. This occurs when the icon for the stage has been removed from the taskbar or dock, and the stage is again visible on the desktop. System hook that should NOT be called by you.
# File lib/limelight/stage.rb, line 300 300: def deiconified(e) 301: end
Invoked when the stage has gained focus on the desktop. Only 1 stage my have focus at a time. System hook that should NOT be called by you.
# File lib/limelight/stage.rb, line 279 279: def focus_gained(e) 280: @theater.stage_activated(self) 281: end
Invoked when the stage has lost focus on the desktop. Only 1 stage my have focus at a time. System hook that should NOT be called by you.
# File lib/limelight/stage.rb, line 286 286: def focus_lost(e) 287: end
Return true if the stage is framed.
# File lib/limelight/stage.rb, line 156 156: def framed? 157: return !@frame.isUndecorated() 158: end
Turns fullscreen mode on and off. In fullscreen mode, the stage will fill the entire screen and appear on top of all other windows.
stage.fullscreen = true
# File lib/limelight/stage.rb, line 87 87: def fullscreen=(on) 88: @frame.setFullScreen(on) 89: end
Returns true if the stage is in fullscreen mode.
# File lib/limelight/stage.rb, line 93 93: def fullscreen? 94: return @frame.isFullScreen() 95: end
Hides the stage so that it is not visible on the screen without destroying it.
# File lib/limelight/stage.rb, line 119 119: def hide 120: @frame.visible = false 121: end
Invoked when the stage has been iconified. This occurs when the stage is no longer visible on the desktop and an icon for the stage has been added to the OS‘s taskbar or dock. System hook that should NOT be called by you.
# File lib/limelight/stage.rb, line 293 293: def iconified(e) 294: end
Turns kiosk mode for this stage on and off. When on, the stage will:
* be fullscreen * not be frames * disable OS key commands * OS X: Cmd-Tab, Cmd-Alt-Esc, etc... * Windows: Alt-Tab, Ctrl-Esc, etc... (Ctrl-Alt-Del must be disabled through a registry entry) stage.kiosk = true
# File lib/limelight/stage.rb, line 106 106: def kiosk=(on) 107: @frame.setKiosk(on) 108: end
Return true if the stage is in kiosk mode.
# File lib/limelight/stage.rb, line 112 112: def kiosk? 113: return @frame.isKiosk() 114: end
Loads a scene on the Stage. If the Stage is currently hosting a Scene, the original Scene will be removed and the new Scene will replace it.
# File lib/limelight/stage.rb, line 207 207: def load_scene(scene) 208: # @frame.setJMenuBar(scene.menu_bar) 209: @frame.load(scene.panel) 210: if (has_static_size?(scene.style)) 211: @frame.set_size(scene.style.compiled_width.value + @frame.getHorizontalInsetWidth, scene.style.compiled_height.value + @frame.getVerticalInsetWidth) 212: end 213: @current_scene = scene 214: end
Opens the Stage and loads the provided Scene.
See load_scene
# File lib/limelight/stage.rb, line 188 188: def open(scene) 189: @current_scene.visible = false if @current_scene 190: scene.stage = self 191: scene.illuminate 192: load_scene(scene) 193: @frame.open unless @should_remain_hidden 194: scene.visible = true 195: scene.scene_opened(self) 196: end
Called when the user or system would like to close the stage. The stage will return true, allowing it to be closed, unless the current_scene defines the allow_close? method in which case the decision it left up to the current_scene.
# File lib/limelight/stage.rb, line 245 245: def should_allow_close 246: return true if @current_scene.nil? 247: return true if !@current_scene.respond_to?(:allow_close?) 248: return @current_scene.allow_close? 249: end
Shows the stage after having hiding it.
# File lib/limelight/stage.rb, line 125 125: def show 126: @frame.visible = true unless @should_remain_hidden 127: end
Sets the width and height styles of the Stage.
state.size = [100, 200] state.size = ["50%", "100%"] # consuming 50% of the width and 100% of the height of the screen
# File lib/limelight/stage.rb, line 59 59: def size=(*values) 60: values = values[0] if values.size == 1 && values[0].is_a?(Array) 61: @frame.set_size_styles(values[0], values[1]) 62: end
Returns true if the stage is visible on the screen.
# File lib/limelight/stage.rb, line 131 131: def visible? 132: return @frame.visible 133: end