sirens 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/components/{component_behaviour.rb → abstract_component.rb} +32 -47
- data/lib/components/component.rb +24 -9
- data/lib/components/containers/splitter.rb +12 -64
- data/lib/components/containers/stack.rb +1 -1
- data/lib/components/containers/tabs.rb +3 -3
- data/lib/components/containers/window.rb +4 -0
- data/lib/components/primitive_component.rb +4 -57
- data/lib/components/widgets/checkbox.rb +2 -2
- data/lib/components/widgets/input_text.rb +1 -1
- data/lib/components/widgets/tree_choice.rb +2 -9
- data/lib/{components/widgets → components_builder}/column_props.rb +14 -2
- data/lib/{layouts → components_builder}/columns_builder.rb +0 -0
- data/lib/components_builder/layout_builder.rb +215 -0
- data/lib/{layouts → components_builder}/radio_button_group_builder.rb +0 -0
- data/lib/sirens.rb +18 -11
- data/lib/sirens/browsers/module_browser.rb +4 -4
- data/lib/sirens/browsers/object_browser.rb +4 -1
- data/lib/sirens/components/ancestors_list.rb +4 -1
- data/lib/sirens/components/class_browser.rb +5 -4
- data/lib/sirens/components/constants_list.rb +1 -1
- data/lib/sirens/components/method_source_code.rb +1 -1
- data/lib/sirens/components/methods_list.rb +5 -2
- data/lib/sirens/components/modules_list.rb +4 -1
- data/lib/sirens/components/namespaces_list.rb +4 -1
- data/lib/sirens/models/constant_model.rb +2 -1
- data/lib/sirens/models/icons.rb +28 -0
- data/lib/sirens/models/method.rb +94 -0
- data/lib/sirens/models/method_model.rb +8 -83
- data/lib/sirens/models/module_browser_model.rb +85 -25
- data/lib/sirens/models/object_browser_model.rb +4 -0
- data/lib/views/{view.rb → abstract_view.rb} +16 -50
- data/lib/views/button_view.rb +1 -1
- data/lib/views/{check_button_view.rb → checkbox_view.rb} +1 -1
- data/lib/views/component_view.rb +12 -0
- data/lib/views/{entry_view.rb → input_text_view.rb} +1 -1
- data/lib/views/list_view.rb +33 -8
- data/lib/views/menu_view.rb +1 -1
- data/lib/views/radio_button_view.rb +1 -1
- data/lib/views/splitter_view.rb +101 -0
- data/lib/views/stack_view.rb +1 -1
- data/lib/views/{notebook_view.rb → tabs_view.rb} +1 -1
- data/lib/views/text_view.rb +1 -1
- data/lib/views/tree_view.rb +42 -20
- data/lib/views/widget_view.rb +96 -0
- data/lib/views/window_view.rb +1 -1
- data/resources/icons/array.png +0 -0
- data/resources/icons/class.png +0 -0
- data/resources/icons/false.png +0 -0
- data/resources/icons/hash.png +0 -0
- data/resources/icons/method.png +0 -0
- data/resources/icons/module.png +0 -0
- data/resources/icons/number.png +0 -0
- data/resources/icons/object.png +0 -0
- data/resources/icons/private-method.png +0 -0
- data/resources/icons/protected-method.png +0 -0
- data/resources/icons/public-method.png +0 -0
- data/resources/icons/string.png +0 -0
- data/resources/icons/true.png +0 -0
- metadata +46 -15
- data/lib/layouts/layout_builder.rb +0 -203
- data/lib/views/paned_view.rb +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 997719a31c64b52ed18fdc3b35f6dd03faec3486dfc9a25a26df39c769ef63b7
|
|
4
|
+
data.tar.gz: ab26f2627e38e683e16c3dcb86ea911056da4b72069933da3812126321ee1ebd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9a647ae5352f583165108ec15cbea29e097db20e67425d008b9dd7e19e90e8da048a123b4f94416a82ddf07ce7f97955a0d91f0b9f6b93e473e8f5acca48c2a
|
|
7
|
+
data.tar.gz: b2804ce2f735a7be3ccf0f64bbccc8346e3778a03913355cbc8a38001d41ba2073d0ea1c7ef178e5ce230a088c0b329724c8dce3637903bea668a66e9d3f17e5
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
module Sirens
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# Opening
|
|
5
|
-
|
|
6
|
-
##
|
|
7
|
-
# Todo: Opens a new window with this component. Currently only works for actual Windows.
|
|
8
|
-
#
|
|
9
|
-
def open(props = Hash[])
|
|
10
|
-
self.new(props)
|
|
11
|
-
.open
|
|
12
|
-
end
|
|
13
|
-
end
|
|
2
|
+
class AbstractComponent
|
|
3
|
+
# Opening
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
##
|
|
6
|
+
# Todo: Opens a new window with this component. Currently only works for actual Windows.
|
|
7
|
+
#
|
|
8
|
+
def self.open(props = Hash[])
|
|
9
|
+
self.new(props).tap { |window|
|
|
10
|
+
window.open
|
|
11
|
+
}
|
|
17
12
|
end
|
|
18
13
|
|
|
19
14
|
# Initializing
|
|
@@ -25,9 +20,18 @@ module Sirens
|
|
|
25
20
|
super()
|
|
26
21
|
|
|
27
22
|
@props = Hash[]
|
|
28
|
-
@
|
|
23
|
+
@child_components = []
|
|
24
|
+
@props = props
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
@view = create_view
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# Creates the PrimitiveView that this component wraps.
|
|
31
|
+
# This method must be implemented by each subclass.
|
|
32
|
+
#
|
|
33
|
+
def create_view()
|
|
34
|
+
raise RuntimeError.new("Class #{self.class.name} must implement a ::create_view() method.")
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
# Accessing
|
|
@@ -50,15 +54,8 @@ module Sirens
|
|
|
50
54
|
##
|
|
51
55
|
# Returns the child components of this component.
|
|
52
56
|
#
|
|
53
|
-
def
|
|
54
|
-
@
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
##
|
|
58
|
-
# Returns the main child component.
|
|
59
|
-
#
|
|
60
|
-
def main_component()
|
|
61
|
-
@components.first
|
|
57
|
+
def child_components()
|
|
58
|
+
@child_components
|
|
62
59
|
end
|
|
63
60
|
|
|
64
61
|
##
|
|
@@ -86,7 +83,11 @@ module Sirens
|
|
|
86
83
|
on_model_changed(new_model: new_model, old_model: old_model)
|
|
87
84
|
end
|
|
88
85
|
|
|
89
|
-
|
|
86
|
+
##
|
|
87
|
+
# Returns this component View.
|
|
88
|
+
#
|
|
89
|
+
def view()
|
|
90
|
+
@view
|
|
90
91
|
end
|
|
91
92
|
|
|
92
93
|
# Child components
|
|
@@ -95,7 +96,7 @@ module Sirens
|
|
|
95
96
|
# Adds the child_component to this component.
|
|
96
97
|
#
|
|
97
98
|
def add_component(child_component)
|
|
98
|
-
|
|
99
|
+
@child_components << child_component
|
|
99
100
|
|
|
100
101
|
on_component_added(child_component)
|
|
101
102
|
|
|
@@ -117,16 +118,16 @@ module Sirens
|
|
|
117
118
|
# Removes the last child component and returns it.
|
|
118
119
|
#
|
|
119
120
|
def remove_last_component()
|
|
120
|
-
remove_component_at(index:
|
|
121
|
+
remove_component_at(index: @child_components.size - 1)
|
|
121
122
|
end
|
|
122
123
|
|
|
123
124
|
##
|
|
124
125
|
# Removes the component at the index-th position.
|
|
125
126
|
#
|
|
126
127
|
def remove_component_at(index:)
|
|
127
|
-
component =
|
|
128
|
+
component = @child_components.delete_at(index)
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
@view.remove_view(component.view)
|
|
130
131
|
|
|
131
132
|
component
|
|
132
133
|
end
|
|
@@ -138,23 +139,7 @@ module Sirens
|
|
|
138
139
|
def on_component_added(child_component)
|
|
139
140
|
end
|
|
140
141
|
|
|
141
|
-
|
|
142
|
-
# Returns the top most view of this component.
|
|
143
|
-
# This method is required to assemble parent and child views.
|
|
144
|
-
#
|
|
145
|
-
def main_view()
|
|
146
|
-
raise RuntimeError.new("Class #{self.class.name} must implement a ::main_view() method.")
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
##
|
|
150
|
-
# Todo: Opens this component in a Window.
|
|
151
|
-
# At this moment only works if the main_component is a window.
|
|
152
|
-
#
|
|
153
|
-
def open()
|
|
154
|
-
main_component.show
|
|
155
|
-
|
|
156
|
-
self
|
|
142
|
+
def on_model_changed(new_model:, old_model:)
|
|
157
143
|
end
|
|
158
|
-
|
|
159
144
|
end
|
|
160
145
|
end
|
data/lib/components/component.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module Sirens
|
|
2
|
-
class Component
|
|
3
|
-
include ComponentBehaviour
|
|
4
|
-
|
|
2
|
+
class Component < AbstractComponent
|
|
5
3
|
|
|
6
4
|
# Initializing
|
|
7
5
|
|
|
@@ -14,6 +12,10 @@ module Sirens
|
|
|
14
12
|
build
|
|
15
13
|
end
|
|
16
14
|
|
|
15
|
+
def create_view()
|
|
16
|
+
ComponentView.new
|
|
17
|
+
end
|
|
18
|
+
|
|
17
19
|
##
|
|
18
20
|
# Configures the widget with its model, styles and child widgets but does not apply the styles yet.
|
|
19
21
|
# This method is called when opening a widget with ::open and after calling ::initialize_handles.
|
|
@@ -24,23 +26,36 @@ module Sirens
|
|
|
24
26
|
def build()
|
|
25
27
|
set_model( props.key?(:model) ? props[:model] : default_model )
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
render_with(LayoutBuilder.new(root_component: self))
|
|
28
30
|
|
|
29
31
|
self
|
|
30
32
|
end
|
|
31
33
|
|
|
34
|
+
|
|
35
|
+
# Accessing
|
|
36
|
+
|
|
37
|
+
def main_child_component()
|
|
38
|
+
@child_components.first
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Rendering
|
|
42
|
+
|
|
32
43
|
##
|
|
33
44
|
# Hook method to allow each Component subclass to define its default styles and compose its child components.
|
|
34
45
|
# Subclasses are expected to implement this method.
|
|
35
|
-
def
|
|
36
|
-
raise RuntimeError.new("Class #{self.class.name} must implement a ::
|
|
46
|
+
def render_with(layout)
|
|
47
|
+
raise RuntimeError.new("Class #{self.class.name} must implement a ::render_with(layout) method.")
|
|
37
48
|
end
|
|
38
49
|
|
|
39
50
|
##
|
|
40
|
-
#
|
|
51
|
+
# Adds the child_component to this component.
|
|
41
52
|
#
|
|
42
|
-
def
|
|
43
|
-
|
|
53
|
+
def on_component_added(child_component)
|
|
54
|
+
@view.add_view(child_component.view)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def open()
|
|
58
|
+
main_child_component.open
|
|
44
59
|
end
|
|
45
60
|
end
|
|
46
61
|
end
|
|
@@ -20,79 +20,27 @@ module Sirens
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
on_size_allocation: proc{ |width:, height:|
|
|
30
|
-
on_size_allocation(width: width, height: height)
|
|
31
|
-
}
|
|
32
|
-
)
|
|
23
|
+
def on_component_added(child_component)
|
|
24
|
+
splitter_proportion = child_component.props.fetch(:splitter_proportion)
|
|
25
|
+
|
|
26
|
+
child_component.view.set_attribute(:splitter_proportion, splitter_proportion)
|
|
27
|
+
|
|
28
|
+
super(child_component)
|
|
33
29
|
end
|
|
34
30
|
|
|
35
31
|
##
|
|
36
|
-
#
|
|
32
|
+
# Returns a SplitterView.
|
|
37
33
|
#
|
|
38
|
-
def
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
on_component_added(child_component)
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
last_child = remove_last_component
|
|
48
|
-
|
|
49
|
-
new_splitter_proportion = 1.0 - components.first.props[:splitter_proportion]
|
|
50
|
-
|
|
51
|
-
new_splitter = self.class.new(orientation: orientation)
|
|
52
|
-
|
|
53
|
-
last_child.props[:splitter_proportion] = last_child.props[:splitter_proportion] / new_splitter_proportion
|
|
54
|
-
new_splitter.add_component(last_child)
|
|
55
|
-
|
|
56
|
-
child_component.props[:splitter_proportion] = child_component.props[:splitter_proportion] / new_splitter_proportion
|
|
57
|
-
new_splitter.add_component(child_component)
|
|
58
|
-
|
|
59
|
-
components << new_splitter
|
|
60
|
-
on_component_added(new_splitter)
|
|
34
|
+
def create_view()
|
|
35
|
+
SplitterView.new(
|
|
36
|
+
orientation: orientation
|
|
37
|
+
)
|
|
61
38
|
end
|
|
62
39
|
|
|
63
40
|
# Asking
|
|
64
41
|
|
|
65
42
|
def orientation()
|
|
66
|
-
props
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Events
|
|
70
|
-
|
|
71
|
-
def on_size_allocation(width:, height:)
|
|
72
|
-
components.each do |child_component|
|
|
73
|
-
size_proportion = child_component.props[:splitter_proportion]
|
|
74
|
-
|
|
75
|
-
next if size_proportion.nil?
|
|
76
|
-
|
|
77
|
-
if orientation == :vertical
|
|
78
|
-
proportional_height = height * size_proportion
|
|
79
|
-
|
|
80
|
-
if child_component.props.key?(:height)
|
|
81
|
-
proportional_height = [proportional_height, child_component.props[:height]].max
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
child_component.main_view.height = proportional_height
|
|
85
|
-
|
|
86
|
-
else
|
|
87
|
-
proportional_width = width * size_proportion
|
|
88
|
-
|
|
89
|
-
if child_component.props.key?(:width)
|
|
90
|
-
proportional_width = [proportional_width, child_component.props[:width]].max
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
child_component.main_view.width = proportional_width
|
|
94
|
-
end
|
|
95
|
-
end
|
|
43
|
+
props.fetch(:orientation)
|
|
96
44
|
end
|
|
97
45
|
end
|
|
98
46
|
end
|
|
@@ -32,7 +32,7 @@ module Sirens
|
|
|
32
32
|
#
|
|
33
33
|
def on_component_added(child_component)
|
|
34
34
|
view.add_view(
|
|
35
|
-
child_component.
|
|
35
|
+
child_component.view,
|
|
36
36
|
expand: child_component.props.fetch(:stack_expand, true),
|
|
37
37
|
fill: child_component.props.fetch(:stack_fill, true),
|
|
38
38
|
padding: child_component.props.fetch(:stack_padding, 0)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
module Sirens
|
|
2
2
|
##
|
|
3
|
-
# Component that wraps a
|
|
3
|
+
# Component that wraps a TabsView.
|
|
4
4
|
#
|
|
5
5
|
class Tabs < PrimitiveComponent
|
|
6
6
|
##
|
|
7
7
|
# Returns a StackView.
|
|
8
8
|
#
|
|
9
9
|
def create_view()
|
|
10
|
-
|
|
10
|
+
TabsView.new
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
##
|
|
@@ -18,7 +18,7 @@ module Sirens
|
|
|
18
18
|
|
|
19
19
|
tab_label_text = child_component.props[:tab_label]
|
|
20
20
|
|
|
21
|
-
view.set_tab_label_at(index:
|
|
21
|
+
view.set_tab_label_at(index: @child_components.size - 1, text: tab_label_text)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -4,8 +4,7 @@ module Sirens
|
|
|
4
4
|
# A PrimitiveView implements the actual GUI binding to a Widget (a Gtk widget, for instance).
|
|
5
5
|
# Besides acting as a regular Component, PrimitiveComponent also takes care of handling the PrimitiveView.
|
|
6
6
|
#
|
|
7
|
-
class PrimitiveComponent
|
|
8
|
-
include ComponentBehaviour
|
|
7
|
+
class PrimitiveComponent < AbstractComponent
|
|
9
8
|
|
|
10
9
|
# Initializing
|
|
11
10
|
|
|
@@ -15,10 +14,6 @@ module Sirens
|
|
|
15
14
|
def initialize(props = Hash[])
|
|
16
15
|
super(props)
|
|
17
16
|
|
|
18
|
-
@view = create_view
|
|
19
|
-
|
|
20
|
-
@updating_view = false
|
|
21
|
-
|
|
22
17
|
apply_props
|
|
23
18
|
|
|
24
19
|
sync_ui_from_model
|
|
@@ -28,23 +23,13 @@ module Sirens
|
|
|
28
23
|
# Applies the props to the view.
|
|
29
24
|
#
|
|
30
25
|
def apply_props()
|
|
31
|
-
|
|
32
|
-
@view.apply_props(props)
|
|
26
|
+
@view.apply_props(props)
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
end
|
|
28
|
+
@view.populate_popup_menu_block = proc { |menu:| populate_popup_menu(menu: menu) }
|
|
36
29
|
|
|
37
30
|
set_model( props.key?(:model) ? props[:model] : default_model )
|
|
38
31
|
end
|
|
39
32
|
|
|
40
|
-
##
|
|
41
|
-
# Creates the PrimitiveView that this component wraps.
|
|
42
|
-
# This method must be implemented by each subclass.
|
|
43
|
-
#
|
|
44
|
-
def create_view()
|
|
45
|
-
raise RuntimeError.new("Class #{self.class.name} must implement a ::create_view() method.")
|
|
46
|
-
end
|
|
47
|
-
|
|
48
33
|
# Accessing
|
|
49
34
|
|
|
50
35
|
##
|
|
@@ -55,22 +40,6 @@ module Sirens
|
|
|
55
40
|
super(props)
|
|
56
41
|
|
|
57
42
|
apply_props
|
|
58
|
-
|
|
59
|
-
sync_ui_from_model if props.key?(:model)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
##
|
|
63
|
-
# Returns this component View.
|
|
64
|
-
#
|
|
65
|
-
def view()
|
|
66
|
-
@view
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
##
|
|
70
|
-
# Returns the top most view of this component.
|
|
71
|
-
#
|
|
72
|
-
def main_view()
|
|
73
|
-
view
|
|
74
43
|
end
|
|
75
44
|
|
|
76
45
|
# Child components
|
|
@@ -79,7 +48,7 @@ module Sirens
|
|
|
79
48
|
# Adds the child_component to this component.
|
|
80
49
|
#
|
|
81
50
|
def on_component_added(child_component)
|
|
82
|
-
view.add_view(child_component.
|
|
51
|
+
@view.add_view(child_component.view)
|
|
83
52
|
end
|
|
84
53
|
|
|
85
54
|
# Events
|
|
@@ -129,27 +98,5 @@ module Sirens
|
|
|
129
98
|
#
|
|
130
99
|
def sync_ui_from_model()
|
|
131
100
|
end
|
|
132
|
-
|
|
133
|
-
##
|
|
134
|
-
# Returns true if this component is currently updating the view.
|
|
135
|
-
#
|
|
136
|
-
def is_updating_view?()
|
|
137
|
-
@updating_view
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
##
|
|
141
|
-
# Flags that this component is updating the view during the evaluation of the given &block.
|
|
142
|
-
#
|
|
143
|
-
def while_updating_view(&block)
|
|
144
|
-
updating = is_updating_view?
|
|
145
|
-
|
|
146
|
-
@updating_view = true
|
|
147
|
-
|
|
148
|
-
begin
|
|
149
|
-
block.call
|
|
150
|
-
ensure
|
|
151
|
-
@updating_view = updating
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
101
|
end
|
|
155
102
|
end
|