glimmer-dsl-opal 0.9.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/LICENSE.txt +1 -1
- data/README.md +366 -161
- data/VERSION +1 -1
- data/lib/display.rb +1 -1
- data/lib/glimmer-dsl-opal.rb +8 -4
- data/lib/glimmer-dsl-opal/ext/file.rb +1 -1
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +28 -8
- 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 +4 -4
- data/lib/glimmer-dsl-swt.rb +1 -1
- data/lib/glimmer/config/opal_logger.rb +16 -0
- 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 +191 -0
- data/lib/glimmer/swt/display_proxy.rb +34 -5
- 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 +59 -0
- 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 +15 -6
- data/lib/net/http.rb +30 -2
- data/lib/os.rb +1 -1
- metadata +30 -5
@@ -14,39 +14,29 @@ module Glimmer
|
|
14
14
|
|
15
15
|
attr_reader :num_columns, :make_columns_equal_width, :horizontal_spacing, :vertical_spacing, :margin_width, :margin_height
|
16
16
|
|
17
|
-
def initialize(parent, args)
|
18
|
-
super(parent, args)
|
19
|
-
self.horizontal_spacing = 10
|
20
|
-
self.vertical_spacing = 10
|
21
|
-
self.margin_width = 15
|
22
|
-
self.margin_height = 15
|
23
|
-
self.num_columns = @args.first || 1
|
24
|
-
reapply
|
25
|
-
end
|
26
|
-
|
27
17
|
def num_columns=(columns)
|
28
18
|
@num_columns = columns
|
29
19
|
# TODO do the following instead of reapply
|
30
20
|
# @parent.add_css_class("num-columns-#{@num_columns}")
|
31
|
-
|
21
|
+
# reinitialize # TODO reimplement without using reinitialize
|
32
22
|
end
|
33
23
|
|
34
24
|
def make_columns_equal_width=(equal_width)
|
35
25
|
@make_columns_equal_width = equal_width
|
36
26
|
# @parent.add_css_class('make_columns_equal_width') if @make_columns_equal_width
|
37
|
-
|
27
|
+
# reinitialize # TODO reimplement without using reinitialize
|
38
28
|
end
|
39
29
|
|
40
30
|
def horizontal_spacing=(spacing)
|
41
31
|
@horizontal_spacing = spacing
|
42
32
|
# @parent.add_css_class("horizontal-spacing-#{@horizontal_spacing}")
|
43
|
-
|
33
|
+
# reinitialize # TODO reimplement without using reinitialize
|
44
34
|
end
|
45
35
|
|
46
36
|
def vertical_spacing=(spacing)
|
47
37
|
@vertical_spacing = spacing
|
48
38
|
# @parent.add_css_class("vertical-spacing-#{@vertical_spacing}")
|
49
|
-
|
39
|
+
# reinitialize # TODO reimplement without using reinitialize
|
50
40
|
end
|
51
41
|
|
52
42
|
def margin_width=(pixels)
|
@@ -66,8 +56,13 @@ module Glimmer
|
|
66
56
|
@parent.dom_element.css('padding-bottom', effective_margin_height)
|
67
57
|
end
|
68
58
|
|
69
|
-
def
|
70
|
-
|
59
|
+
def initialize(parent, args)
|
60
|
+
super(parent, args)
|
61
|
+
self.horizontal_spacing = 10
|
62
|
+
self.vertical_spacing = 10
|
63
|
+
self.margin_width = 15
|
64
|
+
self.margin_height = 15
|
65
|
+
self.num_columns = @args.first || 1
|
71
66
|
layout_css = <<~CSS
|
72
67
|
grid-template-columns: #{'auto ' * @num_columns.to_i};
|
73
68
|
grid-row-gap: #{@vertical_spacing}px;
|
@@ -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/image_proxy'
|
3
24
|
|
@@ -16,7 +37,7 @@ module Glimmer
|
|
16
37
|
end
|
17
38
|
|
18
39
|
def html_text
|
19
|
-
text
|
40
|
+
text&.gsub("\n", '<br />')
|
20
41
|
end
|
21
42
|
|
22
43
|
def background_image=(*image_options)
|
@@ -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
|
|
@@ -0,0 +1,59 @@
|
|
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
|
+
|
24
|
+
module Glimmer
|
25
|
+
module SWT
|
26
|
+
class LatestShellProxy < ShellProxy
|
27
|
+
def initialize(parent, args, block)
|
28
|
+
# No Op
|
29
|
+
end
|
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
|
+
|
43
|
+
def open
|
44
|
+
Document.ready? do
|
45
|
+
DisplayProxy.instance.async_exec {
|
46
|
+
latest_shell&.open
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def latest_shell
|
52
|
+
@latest_shell ||= DisplayProxy.instance.shells.last
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -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,33 +72,45 @@ 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.last || ShellProxy.new([])
|
55
78
|
@args = args
|
56
79
|
@block = block
|
57
80
|
@children = Set.new
|
58
81
|
@enabled = true
|
59
82
|
on_widget_selected {
|
60
83
|
hide
|
84
|
+
@open = false
|
61
85
|
}
|
62
86
|
DisplayProxy.instance.message_boxes << self
|
63
87
|
end
|
64
88
|
|
65
89
|
def text=(txt)
|
66
90
|
@text = txt
|
67
|
-
dom_element.find('.
|
91
|
+
dom_element.find('.message-box-content .text').html(@text)
|
68
92
|
end
|
69
93
|
|
70
94
|
def html_message
|
71
|
-
message
|
95
|
+
message&.gsub("\n", '<br />')
|
72
96
|
end
|
73
97
|
|
74
98
|
def message=(msg)
|
75
99
|
@message = msg
|
76
|
-
dom_element.find('.
|
100
|
+
dom_element.find('.message-box-content .message').html(html_message)
|
101
|
+
end
|
102
|
+
|
103
|
+
def open?
|
104
|
+
@open
|
77
105
|
end
|
78
106
|
|
79
107
|
def open
|
80
|
-
|
108
|
+
shell.open(async: false) unless shell.open?
|
109
|
+
owned_proc = Glimmer::Util::ProcTracker.new(owner: self) {
|
110
|
+
parent.post_initialize_child(self)
|
111
|
+
@open = true
|
112
|
+
}
|
113
|
+
DisplayProxy.instance.async_exec(owned_proc)
|
81
114
|
end
|
82
115
|
|
83
116
|
def hide
|
@@ -88,10 +121,6 @@ module Glimmer
|
|
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
|