Skip to content

Commit

Permalink
ShellProxy#include_focus_control?
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Nov 8, 2020
1 parent 61cf0ed commit 5d46ced
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -9,7 +9,8 @@
- Hello, Table! Sample editor :date_time, property: :date_time in
- Hello, Table! Sample label for (Baseball Game Schedule)
- Hello, Table! Sample combo for selecting nlds, nlcs, alds, alcs, world series
- Add a Game Promotions field to Hello, Table! to indicate things like Free Bobblehead, Free Towel, Free Umbrella, etc...
- Hello, Table! Sample promotion field that indicates things like Free Bobblehead, Free Towel, Free Umbrella, etc...
- ShellProxy#include_focus_control?


### 4.17.9.0
Expand Down
3 changes: 1 addition & 2 deletions TODO.md
Expand Up @@ -4,9 +4,8 @@ Here is a list of tasks to do (moved to [CHANGELOG.md](CHANGELOG.md) once done).

## Next

- method on shell to indicate if it conatins widget in focus
- Document Table Editing instructions in README including all editor types like spinner and data_time
- Hello, Spinner! Sample
- Document Table Editing instructions in README including all editor types like spinner and data_time

## Soon

Expand Down
21 changes: 18 additions & 3 deletions lib/glimmer/swt/shell_proxy.rb
Expand Up @@ -88,18 +88,26 @@ def center

# Opens shell and starts SWT's UI thread event loop
def open
open_only
start_event_loop unless nested?
end
alias show open

# Opens without starting the event loop.
def open_only
if @opened_before
@swt_widget.setVisible(true)
# notify_observers('visible')
else
@opened_before = true
@swt_widget.pack
center
@swt_widget.open
start_event_loop
end
end
alias show open

def nested?
!parent.nil?
end

def hide
@swt_widget.setVisible(false)
Expand All @@ -113,6 +121,10 @@ def visible?
def visible=(visibility)
visibility ? show : hide
end

def include_focus_control?
DisplayProxy.instance.focus_control&.shell == swt_widget
end

def pack
@swt_widget.pack
Expand Down Expand Up @@ -169,6 +181,9 @@ def add_observer(observer, property_name)
super
end
end

end

end

end
37 changes: 35 additions & 2 deletions spec/lib/glimmer/swt/shell_proxy_spec.rb
Expand Up @@ -49,8 +49,41 @@ module GlimmerSpec
end
@target.visible = true
end

describe '#include_focus_control?' do
it 'is true for a shell that includes the focus control and false otherwise' do
@target = shell {
text {
focus true
}
}
@target.setAlpha(0) # keep invisible while running specs
@target2 = shell(@target) {
combo {
focus true
}
}
@target2.setAlpha(0) # keep invisible while running specs
expect(@target.include_focus_control?).to eq(false)
expect(@target2.include_focus_control?).to eq(false)
# async_exec blocks execute after opening target
async_exec do
@target2.open
@shell1_include_focus_control = @target.include_focus_control?
@shell2_include_focus_control = @target2.include_focus_control?
end
async_exec do
@target2.close
@target.close
end
@target.open
expect(@shell1_include_focus_control).to eq(false)
expect(@shell2_include_focus_control).to eq(true)
end

end
end

describe '#pack' do
it 'packs shell content by invoking SWT Shell#pack' do
@target = shell {
Expand Down Expand Up @@ -129,4 +162,4 @@ module GlimmerSpec
end

end
end
end

0 comments on commit 5d46ced

Please sign in to comment.