Skip to content

Commit

Permalink
Be able to create a borderless window (by popular demand)
Browse files Browse the repository at this point in the history
* fixes #1052
  • Loading branch information
PragTob committed Mar 15, 2016
1 parent f4b1aae commit fe3df18
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
1 change: 1 addition & 0 deletions samples/README
Expand Up @@ -12,6 +12,7 @@ simple-anim-shapes.rb
simple-animate.rb
simple-anim-text.rb
# simple-arc.rb Pending on #423
simple-borderless.rb
simple-bounce.rb
simple-brightness-transitions.rb
simple-button-animate.rb
Expand Down
3 changes: 3 additions & 0 deletions samples/simple-borderless.rb
@@ -0,0 +1,3 @@
Shoes.app borderless: true do
title "Look, no borders!"
end
3 changes: 2 additions & 1 deletion shoes-swt/lib/shoes/swt/app.rb
Expand Up @@ -199,7 +199,8 @@ def main_window_style
style = ::Swt::SWT::CLOSE | ::Swt::SWT::MIN | ::Swt::SWT::V_SCROLL
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::ON_TOP if @dsl.opts[:always_on_top]
style |= ::Swt::SWT::NO_TRIM if @dsl.opts[:borderless]
style
end

Expand Down
46 changes: 22 additions & 24 deletions shoes-swt/spec/shoes/swt/app_spec.rb
Expand Up @@ -8,26 +8,9 @@
width: width,
height: 0,
app_title: 'double') }

let(:opts_unresizable) { { background: Shoes::COLORS[:salmon],
resizable: false } }
let(:app_unresizable) { double('app', opts: opts_unresizable,
width: 0,
height: 0,
app_title: 'double') }
let(:opts_always_on_top) { {background: Shoes::COLORS[:salmon],
always_on_top: true} }
let(:app_always_on_top) { double('app', opts: opts_always_on_top,
width: 0,
height: 0,
app_title: 'double') }
let(:plain_app) { double('app', opts: {},
width: 2,
height: 2,
app_title: 'double') }
let(:width) {0}

let(:swt_salmon) { Shoes::Swt::Color.new(Shoes::COLORS[:salmon]).real }
let(:swt_salmon) { }

subject { Shoes::Swt::App.new(dsl) }

Expand Down Expand Up @@ -85,14 +68,19 @@
end

it "should return a bitmask that represents not being resizable" do
not_resizable = Shoes::Swt::App.new app_unresizable
not_resizable = app_with_opts resizable: false
expect(not_resizable.send(:main_window_style)).to eq(BASE_BITMASK)
end

it "should return a bitmask that represents always being on top" do
always_on_top = Shoes::Swt::App.new app_always_on_top
always_on_top = app_with_opts always_on_top: true
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)
expect(no_border.send(:main_window_style)).to eq(BASE_BITMASK | Swt::SWT::NO_TRIM)
end
end

context "when attempting to copy text" do
Expand Down Expand Up @@ -142,12 +130,12 @@

describe 'App Background color' do
it 'has the given background when specified' do
not_resizable = Shoes::Swt::App.new app_unresizable
background = not_resizable.shell.background
expect(background).to eq swt_salmon
color = Shoes::COLORS[:salmon]
colored = app_with_opts background: color
background = colored.shell.background
expect(background).to eq Shoes::Swt::Color.new(color).real
end


it 'has the default system background when unspecified' do
default_background = ::Swt.display.getSystemColor(::Swt::SWT::COLOR_WIDGET_BACKGROUND)
app = Shoes::Swt::App.new(Shoes::InternalApp.new(Shoes::App.new, {}))
Expand All @@ -165,4 +153,14 @@
subject.class.setup_system_colors
end
end

def app_with_opts(opts)
dsl_app_double = double('app',
opts: opts,
width: 0,
height: 0,
app_title: 'double')

Shoes::Swt::App.new dsl_app_double
end
end

0 comments on commit fe3df18

Please sign in to comment.