glimmer-dsl-opal 0.9.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +213 -104
- data/VERSION +1 -1
- data/lib/display.rb +1 -1
- data/lib/glimmer-dsl-opal.rb +4 -3
- data/lib/glimmer-dsl-opal/ext/file.rb +1 -1
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +27 -2
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_repository.rb +4 -4
- data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +2 -2
- data/lib/glimmer-dsl-opal/samples/hello/hello_browser.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb +21 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_dialog.rb +78 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_menu_bar.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_message_box.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_pop_up_context_menu.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +1 -1
- data/lib/glimmer-dsl-swt.rb +1 -1
- data/lib/glimmer/dsl/opal/async_exec_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/block_property_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/color_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/dialog_expression.rb +20 -0
- data/lib/glimmer/dsl/opal/display_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/dsl.rb +1 -1
- data/lib/glimmer/dsl/opal/exec_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/font_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/menu_bar_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/menu_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/message_box_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/rgb_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/rgba_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/swt_expression.rb +4 -4
- data/lib/glimmer/dsl/opal/sync_exec_expression.rb +1 -1
- data/lib/glimmer/swt.rb +1 -1
- data/lib/glimmer/swt/color_proxy.rb +1 -1
- data/lib/glimmer/swt/composite_proxy.rb +16 -2
- data/lib/glimmer/swt/control_editor.rb +1 -1
- data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
- data/lib/glimmer/swt/custom/radio_group.rb +1 -1
- data/lib/glimmer/swt/dialog_proxy.rb +188 -0
- data/lib/glimmer/swt/display_proxy.rb +70 -10
- data/lib/glimmer/swt/font_proxy.rb +1 -1
- data/lib/glimmer/swt/grid_layout_proxy.rb +11 -16
- data/lib/glimmer/swt/label_proxy.rb +22 -1
- data/lib/{glimmer-dsl-opal/ext/struct.rb → glimmer/swt/latest_dialog_proxy.rb} +19 -12
- data/lib/glimmer/swt/latest_message_box_proxy.rb +25 -1
- data/lib/glimmer/swt/latest_shell_proxy.rb +43 -4
- data/lib/glimmer/swt/layout_data_proxy.rb +4 -0
- data/lib/glimmer/swt/layout_proxy.rb +9 -6
- data/lib/glimmer/swt/make_shift_shell_proxy.rb +1 -1
- data/lib/glimmer/swt/menu_item_proxy.rb +1 -1
- data/lib/glimmer/swt/menu_proxy.rb +3 -3
- data/lib/glimmer/swt/message_box_proxy.rb +45 -16
- data/lib/glimmer/swt/row_layout_proxy.rb +24 -6
- data/lib/glimmer/swt/shell_proxy.rb +43 -9
- data/lib/glimmer/swt/style_constantizable.rb +1 -1
- data/lib/glimmer/swt/swt_proxy.rb +1 -1
- data/lib/glimmer/swt/tab_folder_proxy.rb +1 -1
- data/lib/glimmer/swt/table_editor.rb +1 -1
- data/lib/glimmer/swt/table_item_proxy.rb +1 -1
- data/lib/glimmer/swt/table_proxy.rb +1 -1
- data/lib/glimmer/swt/widget_proxy.rb +50 -17
- data/lib/glimmer/ui/custom_shell.rb +1 -1
- data/lib/glimmer/ui/custom_widget.rb +1 -1
- data/lib/glimmer/util/proc_tracker.rb +17 -6
- data/lib/net/http.rb +30 -2
- data/lib/os.rb +1 -1
- metadata +28 -7
- data/CHANGELOG.md +0 -194
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2020 Andy Maleh
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -19,19 +19,26 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
module Glimmer
|
23
|
+
module SWT
|
24
|
+
class LatestDialogProxy #< DialogProxy
|
25
|
+
# TODO consider overriding all methods from DialogProxy and proxying to them
|
26
|
+
# TODO consider the idea of promoting this object into the real dialog once Document is ready
|
27
|
+
|
28
|
+
def initialize(parent, args, block)
|
29
|
+
# No Op
|
30
|
+
end
|
31
|
+
|
32
|
+
def open
|
33
|
+
Document.ready? do
|
34
|
+
DisplayProxy.instance.async_exec {
|
35
|
+
DisplayProxy.instance.dialogs.last&.open
|
36
|
+
}
|
33
37
|
end
|
34
38
|
end
|
39
|
+
|
35
40
|
end
|
41
|
+
|
36
42
|
end
|
43
|
+
|
37
44
|
end
|
@@ -1,7 +1,29 @@
|
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
module Glimmer
|
2
23
|
module SWT
|
3
24
|
class LatestMessageBoxProxy #< MessageBoxProxy
|
4
25
|
# TODO consider overriding all methods from MessageBoxProxy and proxying to them
|
26
|
+
# TODO consider the idea of promoting this object into the real message_box once Document is ready
|
5
27
|
|
6
28
|
def initialize(parent, args, block)
|
7
29
|
# No Op
|
@@ -9,7 +31,9 @@ module Glimmer
|
|
9
31
|
|
10
32
|
def open
|
11
33
|
Document.ready? do
|
12
|
-
DisplayProxy.instance.
|
34
|
+
DisplayProxy.instance.async_exec {
|
35
|
+
DisplayProxy.instance.message_boxes.last&.open
|
36
|
+
}
|
13
37
|
end
|
14
38
|
end
|
15
39
|
|
@@ -1,17 +1,56 @@
|
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/swt/shell_proxy'
|
23
|
+
|
1
24
|
module Glimmer
|
2
25
|
module SWT
|
3
|
-
class LatestShellProxy
|
4
|
-
# TODO consider overriding all methods from ShellProxy and proxying to them
|
5
|
-
|
26
|
+
class LatestShellProxy < ShellProxy
|
6
27
|
def initialize(parent, args, block)
|
7
28
|
# No Op
|
8
29
|
end
|
9
30
|
|
31
|
+
def method_missing(method, *args, &block)
|
32
|
+
if latest_shell.nil?
|
33
|
+
super(method, *args, &block)
|
34
|
+
else
|
35
|
+
latest_shell.send(method, *args, &block)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def respond_to?(method, *args, &block)
|
40
|
+
super || latest_shell&.respond_to?(method, *args, &block)
|
41
|
+
end
|
42
|
+
|
10
43
|
def open
|
11
44
|
Document.ready? do
|
12
|
-
DisplayProxy.instance.
|
45
|
+
DisplayProxy.instance.async_exec {
|
46
|
+
latest_shell&.open
|
47
|
+
}
|
13
48
|
end
|
14
49
|
end
|
50
|
+
|
51
|
+
def latest_shell
|
52
|
+
@latest_shell ||= DisplayProxy.instance.shells.last
|
53
|
+
end
|
15
54
|
|
16
55
|
end
|
17
56
|
|
@@ -17,6 +17,8 @@ module Glimmer
|
|
17
17
|
:grab_excess_vertical_space,
|
18
18
|
:width_hint,
|
19
19
|
:height_hint
|
20
|
+
alias width width_hint
|
21
|
+
alias height height_hint
|
20
22
|
|
21
23
|
def initialize(parent, args)
|
22
24
|
@parent = parent
|
@@ -35,12 +37,14 @@ module Glimmer
|
|
35
37
|
@parent.dom_element.css('width', "#{@width_hint}px")
|
36
38
|
# reapply
|
37
39
|
end
|
40
|
+
alias width= width_hint=
|
38
41
|
|
39
42
|
def height_hint=(height_hint)
|
40
43
|
@height_hint = height_hint
|
41
44
|
@parent.dom_element.css('height', "#{@height_hint}px")
|
42
45
|
# reapply
|
43
46
|
end
|
47
|
+
alias height= height_hint=
|
44
48
|
|
45
49
|
def horizontal_alignment=(horizontal_alignment)
|
46
50
|
@horizontal_alignment = horizontal_alignment
|
@@ -31,29 +31,32 @@ module Glimmer
|
|
31
31
|
|
32
32
|
def initialize(parent, args)
|
33
33
|
@parent = parent
|
34
|
+
@args = args
|
34
35
|
@parent = parent.body_root if @parent.is_a?(Glimmer::UI::CustomWidget)
|
35
36
|
@parent.css_classes.each do |css_class|
|
36
37
|
@parent.remove_css_class(css_class) if css_class.include?('layout')
|
37
38
|
end
|
38
|
-
@args = args
|
39
39
|
@parent.add_css_class(css_class)
|
40
40
|
@parent.layout = self
|
41
41
|
self.margin_width = 15 if respond_to?(:margin_width=)
|
42
42
|
self.margin_height = 15 if respond_to?(:margin_height=)
|
43
43
|
end
|
44
|
-
|
45
|
-
def
|
46
|
-
|
44
|
+
|
45
|
+
def layout(composite = nil, flush_cache = false)
|
46
|
+
# TODO implement def layout(composite = nil, flush_cache = false) as per SWT API
|
47
|
+
composite ||= @parent
|
48
|
+
initialize(composite, @args)
|
47
49
|
end
|
48
50
|
|
49
|
-
def
|
50
|
-
|
51
|
+
def css_class
|
52
|
+
self.class.name.split('::').last.underscore.sub(/_proxy$/, '').gsub('_', '-')
|
51
53
|
end
|
52
54
|
|
53
55
|
# Decorates widget dom. Subclasses may override. Returns widget dom by default.
|
54
56
|
def dom(widget_dom)
|
55
57
|
widget_dom
|
56
58
|
end
|
59
|
+
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2020 Andy Maleh
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -207,11 +207,11 @@ module Glimmer
|
|
207
207
|
the_element.on('mouseover') { |event|
|
208
208
|
if event.page_x.between?(the_element.offset.left, the_element.offset.left + the_element.width) and
|
209
209
|
event.page_y.between?(the_element.offset.top, the_element.offset.top + the_element.height)
|
210
|
-
`$(#{path}).menu('option', 'position', { my: 'left top', at: 'left bottom' })
|
210
|
+
`$(#{path}).menu('option', 'position', { my: 'left top', at: 'left bottom' })`
|
211
211
|
end
|
212
212
|
}
|
213
213
|
the_element.on('menublur') {
|
214
|
-
`$(#{path}).menu('option', 'position', { my: 'left top', at: 'right top' })
|
214
|
+
`$(#{path}).menu('option', 'position', { my: 'left top', at: 'right top' })`
|
215
215
|
}
|
216
216
|
minimum_width = children.to_a.map(&:dom_element).map(&:width).reduce(:+)
|
217
217
|
the_element.css('min-width', minimum_width)
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'glimmer/swt/widget_proxy'
|
2
23
|
require 'glimmer/swt/display_proxy'
|
3
24
|
|
@@ -5,9 +26,9 @@ module Glimmer
|
|
5
26
|
module SWT
|
6
27
|
class MessageBoxProxy < WidgetProxy
|
7
28
|
STYLE = <<~CSS
|
8
|
-
.
|
29
|
+
.message-box {
|
9
30
|
position: fixed;
|
10
|
-
z-index:
|
31
|
+
z-index: 1000;
|
11
32
|
padding-top: 100px;
|
12
33
|
left: 0;
|
13
34
|
top: 0;
|
@@ -18,15 +39,15 @@ module Glimmer
|
|
18
39
|
background-color: rgba(0,0,0,0.4);
|
19
40
|
text-align: center;
|
20
41
|
}
|
21
|
-
.
|
42
|
+
.message-box-content .text {
|
22
43
|
background: rgb(80, 116, 211);
|
23
44
|
color: white;
|
24
45
|
padding: 5px;
|
25
46
|
}
|
26
|
-
.
|
47
|
+
.message-box-content .message {
|
27
48
|
padding: 20px;
|
28
49
|
}
|
29
|
-
.
|
50
|
+
.message-box-content {
|
30
51
|
background-color: #fefefe;
|
31
52
|
padding-bottom: 15px;
|
32
53
|
border: 1px solid #888;
|
@@ -51,7 +72,9 @@ module Glimmer
|
|
51
72
|
|
52
73
|
def initialize(parent, args, block)
|
53
74
|
i = 0
|
54
|
-
@parent = parent
|
75
|
+
@parent = parent
|
76
|
+
@parent = nil if parent.is_a?(LatestShellProxy)
|
77
|
+
@parent ||= DisplayProxy.instance.shells.detect(&:open?) || ShellProxy.new([])
|
55
78
|
@args = args
|
56
79
|
@block = block
|
57
80
|
@children = Set.new
|
@@ -64,34 +87,40 @@ module Glimmer
|
|
64
87
|
|
65
88
|
def text=(txt)
|
66
89
|
@text = txt
|
67
|
-
dom_element.find('.
|
90
|
+
dom_element.find('.message-box-content .text').html(@text)
|
68
91
|
end
|
69
92
|
|
70
93
|
def html_message
|
71
|
-
message
|
94
|
+
message&.gsub("\n", '<br />')
|
72
95
|
end
|
73
96
|
|
74
97
|
def message=(msg)
|
75
98
|
@message = msg
|
76
|
-
dom_element.find('.
|
99
|
+
dom_element.find('.message-box-content .message').html(html_message)
|
100
|
+
end
|
101
|
+
|
102
|
+
def open?
|
103
|
+
@open
|
77
104
|
end
|
78
105
|
|
79
106
|
def open
|
80
|
-
|
107
|
+
shell.open(async: false) unless shell.open?
|
108
|
+
owned_proc = Glimmer::Util::ProcTracker.new(owner: self, invoked_from: :open) {
|
109
|
+
parent.post_initialize_child(self)
|
110
|
+
@open = true
|
111
|
+
}
|
112
|
+
DisplayProxy.instance.async_exec(owned_proc)
|
81
113
|
end
|
82
114
|
|
83
115
|
def hide
|
84
116
|
dom_element.remove
|
117
|
+
@open = false
|
85
118
|
end
|
86
119
|
|
87
120
|
def content(&block)
|
88
121
|
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::MessageBoxExpression.new, &block)
|
89
122
|
end
|
90
123
|
|
91
|
-
def name
|
92
|
-
'div'
|
93
|
-
end
|
94
|
-
|
95
124
|
def selector
|
96
125
|
super + ' .close'
|
97
126
|
end
|
@@ -111,9 +140,9 @@ module Glimmer
|
|
111
140
|
def dom
|
112
141
|
@dom ||= html {
|
113
142
|
div(id: id, class: "modal #{name}") {
|
114
|
-
div(class: '
|
143
|
+
div(class: 'message-box-content') {
|
115
144
|
header(class: 'text') {
|
116
|
-
text
|
145
|
+
"#{text} " # ensure title area occuppied when there is no text by adding non-breaking space ( )
|
117
146
|
}
|
118
147
|
tag(_name: 'p', id: 'message', class: 'message') {
|
119
148
|
html_message
|
@@ -14,6 +14,16 @@ module Glimmer
|
|
14
14
|
.row-layout-pack-false {
|
15
15
|
align-items: stretch;
|
16
16
|
}
|
17
|
+
|
18
|
+
.row-layout-center.row-layout-horizontal > * {
|
19
|
+
margin-top: auto;
|
20
|
+
margin-bottom: auto;
|
21
|
+
}
|
22
|
+
|
23
|
+
.row-layout-center.row-layout-vertical > * {
|
24
|
+
margin-left: auto;
|
25
|
+
margin-right: auto;
|
26
|
+
}
|
17
27
|
|
18
28
|
.row-layout-horizontal {
|
19
29
|
flex-direction: row;
|
@@ -32,13 +42,11 @@ module Glimmer
|
|
32
42
|
}
|
33
43
|
CSS
|
34
44
|
|
35
|
-
attr_reader :type, :margin_width, :margin_height, :margin_top, :margin_right, :margin_bottom, :margin_left, :spacing, :pack
|
36
|
-
|
45
|
+
attr_reader :type, :margin_width, :margin_height, :margin_top, :margin_right, :margin_bottom, :margin_left, :spacing, :pack, :center
|
46
|
+
|
37
47
|
def initialize(parent, args)
|
38
48
|
super(parent, args)
|
39
|
-
@type =
|
40
|
-
@marign_width = 15
|
41
|
-
@margin_height = 15
|
49
|
+
@type = args.first || :horizontal
|
42
50
|
self.pack = true
|
43
51
|
@parent.dom_element.add_class('row-layout')
|
44
52
|
@parent.dom_element.add_class(horizontal? ? 'row-layout-horizontal' : 'row-layout-vertical')
|
@@ -67,6 +75,16 @@ module Glimmer
|
|
67
75
|
end
|
68
76
|
end
|
69
77
|
|
78
|
+
def center=(center_value)
|
79
|
+
@center = center_value
|
80
|
+
# Using padding for width since margin-right isn't getting respected with width 100%
|
81
|
+
if @center
|
82
|
+
parent.dom_element.add_class("row-layout-center")
|
83
|
+
else
|
84
|
+
parent.dom_element.remove_class("row-layout-center")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
70
88
|
def margin_width=(pixels)
|
71
89
|
@margin_width = pixels
|
72
90
|
# Using padding for width since margin-right isn't getting respected with width 100%
|
@@ -101,7 +119,7 @@ module Glimmer
|
|
101
119
|
@margin_left = pixels
|
102
120
|
@parent.dom_element.css('padding-left', @margin_left)
|
103
121
|
end
|
104
|
-
|
122
|
+
|
105
123
|
def spacing=(spacing)
|
106
124
|
@spacing = spacing.to_i
|
107
125
|
# TODO implement changes to accomodate layout_data in the future
|
@@ -24,6 +24,17 @@ module Glimmer
|
|
24
24
|
width: 100%;
|
25
25
|
height: 100%;
|
26
26
|
}
|
27
|
+
.shell .dialog-overlay {
|
28
|
+
position: fixed;
|
29
|
+
z-index: 10;
|
30
|
+
padding-top: 100px;
|
31
|
+
left: 0;
|
32
|
+
top: 0;
|
33
|
+
width: 100%;
|
34
|
+
height: 100%;
|
35
|
+
overflow: auto;
|
36
|
+
background-color: rgba(0,0,0,0.4);
|
37
|
+
}
|
27
38
|
CSS
|
28
39
|
|
29
40
|
# TODO consider renaming to ShellProxy to match SWT API
|
@@ -36,9 +47,7 @@ module Glimmer
|
|
36
47
|
def initialize(args)
|
37
48
|
@args = args
|
38
49
|
@children = []
|
39
|
-
# TODO
|
40
|
-
Document.find('body').empty unless ENV['RUBY_ENV'] == 'test'
|
41
|
-
render
|
50
|
+
render # TODO attach to specific element
|
42
51
|
@layout = FillLayoutProxy.new(self, [])
|
43
52
|
@layout.margin_width = 0
|
44
53
|
@layout.margin_height = 0
|
@@ -84,7 +93,7 @@ module Glimmer
|
|
84
93
|
def dom
|
85
94
|
i = 0
|
86
95
|
body_id = id
|
87
|
-
body_class = ([name] + css_classes.to_a).join(' ')
|
96
|
+
body_class = ([name, 'hide'] + css_classes.to_a).join(' ')
|
88
97
|
@dom ||= html {
|
89
98
|
div(id: body_id, class: body_class) {
|
90
99
|
# TODO consider supporting the idea of dynamic CSS building on close of shell that adds only as much CSS as needed for widgets that were mentioned
|
@@ -98,15 +107,40 @@ module Glimmer
|
|
98
107
|
}
|
99
108
|
end
|
100
109
|
end
|
101
|
-
''
|
110
|
+
div(class: 'dialog-overlay hide') {
|
111
|
+
}
|
102
112
|
}
|
103
113
|
}.to_s
|
104
114
|
end
|
105
115
|
|
106
|
-
def open
|
107
|
-
|
108
|
-
|
109
|
-
|
116
|
+
def open(async: true)
|
117
|
+
work = lambda do
|
118
|
+
unless @open
|
119
|
+
DisplayProxy.instance.shells.select(&:open?).reject {|s| s == self}.map(&:hide)
|
120
|
+
dom_element.remove_class('hide')
|
121
|
+
@open = true
|
122
|
+
end
|
123
|
+
end
|
124
|
+
if async
|
125
|
+
DisplayProxy.instance.async_exec(&work)
|
126
|
+
else
|
127
|
+
work.call
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def hide
|
132
|
+
dom_element.add_class('hide')
|
133
|
+
@open = false
|
134
|
+
end
|
135
|
+
|
136
|
+
def close
|
137
|
+
DisplayProxy.instance.shells.delete(self)
|
138
|
+
dom_element.remove
|
139
|
+
@open = false
|
140
|
+
end
|
141
|
+
|
142
|
+
def open?
|
143
|
+
@open
|
110
144
|
end
|
111
145
|
end
|
112
146
|
end
|