Skip to content

Commit

Permalink
Add a main controller and options stage
Browse files Browse the repository at this point in the history
  • Loading branch information
lexun committed Jan 26, 2015
1 parent 06606b1 commit aaa71ed
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/launchpad.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'lib/launchpad/settings'
require 'lib/launchpad/index'
require 'lib/launchpad/gui/application'
require 'lib/launchpad/gui/controllers/main_controller'

# The main top level module for the launchpad gem.
module Launchpad
Expand Down
2 changes: 1 addition & 1 deletion lib/launchpad/gui/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Application < JRubyFX::Application
# automatically provided when {.launch} is called.
def start(stage)
with(stage, title: 'Launchpad', resizable: false) do
fxml 'main.fxml'
fxml MainController
show
end
end
Expand Down
14 changes: 14 additions & 0 deletions lib/launchpad/gui/controllers/main_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Launchpad
# Main application GUI controller
class MainController
include JRubyFX::Controller
fxml 'main.fxml'

# Triggered when the options button is pressed
def show_options
@options ||= stage title: 'Options'
@options.on_close_request { @options = nil }
@options.show
end
end
end
2 changes: 1 addition & 1 deletion lib/launchpad/gui/fxml/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<children>
<Button layoutX="720.0" layoutY="11.0" mnemonicParsing="false" text="Launch" />
<Button layoutX="662.0" layoutY="11.0" mnemonicParsing="false" text="Scan" />
<Button layoutX="585.0" layoutY="11.0" mnemonicParsing="false" text="Options" />
<Button layoutX="585.0" layoutY="11.0" mnemonicParsing="false" onAction="#show_options" text="Options" />
<ProgressBar layoutX="14.0" layoutY="11.0" prefHeight="27.0" prefWidth="559.0" progress="0.0" />
<Label layoutX="33.0" layoutY="17.0" text="Info" />
</children>
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/launchpad/gui/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
it 'should set up the stage' do
expect(stage).to have_received(:title=).with 'Launchpad'
expect(stage).to have_received(:resizable=).with false
expect(stage).to have_received(:fxml).with 'main.fxml'
expect(stage).to have_received(:fxml).with Launchpad::MainController
expect(stage).to have_received(:show)
end

Expand Down

0 comments on commit aaa71ed

Please sign in to comment.