Skip to content

Commit

Permalink
Apply new options layout and controller
Browse files Browse the repository at this point in the history
  • Loading branch information
lexun committed Feb 8, 2015
1 parent 1382fb7 commit 0ca2741
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/launchpad.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'lib/launchpad/index'
require 'lib/launchpad/gui/application'
require 'lib/launchpad/gui/controllers/main_controller'
require 'lib/launchpad/gui/controllers/options_controller'

# The main top level module for the launchpad gem.
module Launchpad
Expand Down
2 changes: 2 additions & 0 deletions lib/launchpad/gui/controllers/main_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class MainController
def show_options
@options ||=
stage title: 'Options',
fxml: OptionsController,
always_on_top: true,
resizable: false,
x: Application.main_stage.x + 20,
y: Application.main_stage.y + 40

Expand Down
7 changes: 7 additions & 0 deletions lib/launchpad/gui/controllers/options_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Launchpad
# Options controller for updating settings
class OptionsController
include JRubyFX::Controller
fxml 'options.fxml'
end
end
12 changes: 11 additions & 1 deletion spec/lib/launchpad/gui/controllers/main_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
describe Launchpad::MainController do
let(:stage_class) { described_class::Stage }
let(:stage_double) { double 'stage' }
let(:messages) { [:title=, :always_on_top=, :show, :x=, :y=] }

let(:messages) do
[:title=, :always_on_top=, :resizable=, :fxml=, :show, :x=, :y=]
end

before do
described_class.define_singleton_method(:initialize) {}
Expand All @@ -26,8 +29,15 @@
expect(subject.instance_variable_get :@options).to be stage_double
end

it 'uses the options controller for the stage' do
expect(stage_double).to have_received(:fxml=)
.with Launchpad::OptionsController
end

it 'sets the options stage attributes' do
expect(stage_double).to have_received(:title=).with 'Options'
expect(stage_double).to have_received(:always_on_top=).with true
expect(stage_double).to have_received(:resizable=).with false
expect(stage_double).to have_received(:x=).with 25
expect(stage_double).to have_received(:y=).with 45
end
Expand Down

0 comments on commit 0ca2741

Please sign in to comment.