From d9565f959887b9fc5e1eb528f601817abea2d9ad Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Wed, 16 Mar 2016 21:05:49 +0100 Subject: [PATCH] borderless --> border: false --- samples/simple-borderless.rb | 4 ++-- shoes-core/lib/shoes/internal_app.rb | 11 ++++++---- shoes-swt/lib/shoes/swt/app.rb | 2 +- shoes-swt/spec/shoes/swt/app_spec.rb | 32 ++++++++++++++-------------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/samples/simple-borderless.rb b/samples/simple-borderless.rb index be805a7a2..2a057bd65 100644 --- a/samples/simple-borderless.rb +++ b/samples/simple-borderless.rb @@ -1,3 +1,3 @@ -Shoes.app borderless: true do +Shoes.app border: false do title "Look, no borders!" -end \ No newline at end of file +end diff --git a/shoes-core/lib/shoes/internal_app.rb b/shoes-core/lib/shoes/internal_app.rb index 8d2a96724..0e0f3ecfe 100644 --- a/shoes-core/lib/shoes/internal_app.rb +++ b/shoes-core/lib/shoes/internal_app.rb @@ -13,10 +13,13 @@ class InternalApp extend Forwardable - DEFAULT_OPTIONS = { width: 600, - height: 500, - title: "Shoes 4", - resizable: true }.freeze + DEFAULT_OPTIONS = { + width: 600, + height: 500, + title: "Shoes 4", + resizable: true, + border: true + }.freeze def initialize(app, opts, &blk) @app = app diff --git a/shoes-swt/lib/shoes/swt/app.rb b/shoes-swt/lib/shoes/swt/app.rb index 1a0dfef2d..74cba38bc 100644 --- a/shoes-swt/lib/shoes/swt/app.rb +++ b/shoes-swt/lib/shoes/swt/app.rb @@ -200,7 +200,7 @@ def main_window_style style |= ::Swt::SWT::RESIZE | ::Swt::SWT::MAX if @dsl.opts[:resizable] style |= ::Swt::SWT::APPLICATION_MODAL if @dsl.opts[:modal] style |= ::Swt::SWT::ON_TOP if @dsl.opts[:always_on_top] - style |= ::Swt::SWT::NO_TRIM if @dsl.opts[:borderless] + style |= ::Swt::SWT::NO_TRIM unless @dsl.opts.fetch(:border, true) style end diff --git a/shoes-swt/spec/shoes/swt/app_spec.rb b/shoes-swt/spec/shoes/swt/app_spec.rb index c9746bc13..c3275bba0 100644 --- a/shoes-swt/spec/shoes/swt/app_spec.rb +++ b/shoes-swt/spec/shoes/swt/app_spec.rb @@ -2,17 +2,11 @@ describe Shoes::Swt::App do let(:opts) { {background: Shoes::COLORS[:salmon], resizable: true} } - let(:app) { double('app') } - let(:dsl) { double('dsl', app: app, - opts: opts, - width: width, - height: 0, - app_title: 'double') } let(:width) {0} + let(:dsl) { dsl_app_with_opts(opts) } + let(:app) {double 'app' } - let(:swt_salmon) { } - - subject { Shoes::Swt::App.new(dsl) } + subject { described_class.new dsl } it { is_expected.to respond_to :clipboard } it { is_expected.to respond_to :clipboard= } @@ -73,12 +67,12 @@ end it "should return a bitmask that represents always being on top" do - always_on_top = app_with_opts always_on_top: true + always_on_top = app_with_opts always_on_top: true, resizable: false expect(always_on_top.send(:main_window_style)).to eq(BASE_BITMASK | Swt::SWT::ON_TOP) end it "should return an bitmask that indicates no trim" do - no_border = app_with_opts(borderless: true) + no_border = app_with_opts(border: false, resizable: false) expect(no_border.send(:main_window_style)).to eq(BASE_BITMASK | Swt::SWT::NO_TRIM) end end @@ -155,12 +149,18 @@ end def app_with_opts(opts) - dsl_app_double = double('app', - opts: opts, - width: 0, - height: 0, - app_title: 'double') + dsl_app_double = dsl_app_with_opts(opts) Shoes::Swt::App.new dsl_app_double end + + def dsl_app_with_opts(opts) + double('app', + app: app, + opts: Shoes::InternalApp::DEFAULT_OPTIONS.merge(opts), + width: 0, + height: 0, + app_title: 'double') + end + end