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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
require 'set'
|
|
2
|
+
|
|
3
|
+
module Sirens
|
|
4
|
+
##
|
|
5
|
+
# A View is the library binding to a GUI interface handle.
|
|
6
|
+
# It is not a Component but is wrapped by a PrimitiveComponent.
|
|
7
|
+
# a View takes care of handling the internals of the GUI objects such as handles, events, default initialization,
|
|
8
|
+
# etc.
|
|
9
|
+
#
|
|
10
|
+
# By separating the View from the PrimitiveComponent that wraps it makes the PrimitiveComponents responsibilities
|
|
11
|
+
# more consistent with regular Components and it makes it easier to switch between GUI libraries
|
|
12
|
+
# (say, from Gtk to Qt).
|
|
13
|
+
#
|
|
14
|
+
class WidgetView < AbstractView
|
|
15
|
+
|
|
16
|
+
# Initializing
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# Initializes this View handles
|
|
20
|
+
#
|
|
21
|
+
def initialize()
|
|
22
|
+
super()
|
|
23
|
+
|
|
24
|
+
@event_handles = Hash[]
|
|
25
|
+
|
|
26
|
+
@main_handle = nil
|
|
27
|
+
|
|
28
|
+
initialize_handles
|
|
29
|
+
|
|
30
|
+
subscribe_to_ui_events
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
## Instantiates this view handles.
|
|
34
|
+
# A View usually has a single handle to the GUI library, but in same cases it may have more than one.
|
|
35
|
+
# For instance when adding a Scroll decorator to the actual widget.
|
|
36
|
+
#
|
|
37
|
+
def initialize_handles()
|
|
38
|
+
raise RuntimeError.new("Subclass #{self.class.name} must implement the method ::initialize_handles().")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
# Subscribes this View to the events/signals emitted by the GUI handle(s) of interest.
|
|
43
|
+
# When an event/signal is received calls the proper event_handler provided by the PrimitiveComponent,
|
|
44
|
+
# if one was given.
|
|
45
|
+
#
|
|
46
|
+
# This mechanism of event handler callbacks is more simple and lightweight than making this View to announce
|
|
47
|
+
# events using the Observer pattern, and since there is only one PrimitiveComponent wrapping each View
|
|
48
|
+
# using the Observer pattern would be unnecessary complex.
|
|
49
|
+
#
|
|
50
|
+
def subscribe_to_ui_events()
|
|
51
|
+
raise RuntimeError.new("Subclass #{self.class.name} must implement the method ::subscribe_to_ui_events().")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Accessing
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# Returns the main handle of this View.
|
|
58
|
+
# The main handle is the one that this View parent add as its child.
|
|
59
|
+
# Also, it is the handle that receives the style props and events by default.
|
|
60
|
+
#
|
|
61
|
+
def main_handle()
|
|
62
|
+
@main_handle
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Styling
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# Applies each prop in props to the actual GUI object.
|
|
69
|
+
#
|
|
70
|
+
def apply_props(props)
|
|
71
|
+
accepted_styles = self.accepted_styles
|
|
72
|
+
|
|
73
|
+
props.each_pair { |prop, value|
|
|
74
|
+
apply_prop(prop, value) if accepted_styles.include?(prop)
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# Apply the prop to the actual GUI object.
|
|
80
|
+
#
|
|
81
|
+
def apply_prop(prop, value)
|
|
82
|
+
setter = prop.to_s + '='
|
|
83
|
+
|
|
84
|
+
send(setter, value)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
##
|
|
88
|
+
# Adds a child_view.
|
|
89
|
+
#
|
|
90
|
+
def add_view(child_view)
|
|
91
|
+
super(child_view)
|
|
92
|
+
|
|
93
|
+
main_handle.add(child_view.main_handle)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
data/lib/views/window_view.rb
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sirens
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Haijin Development
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2019-
|
|
12
|
+
date: 2019-07-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: gtk3
|
|
@@ -25,14 +25,28 @@ dependencies:
|
|
|
25
25
|
- - "~>"
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '3.0'
|
|
28
|
-
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: method_source
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0.9'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0.9'
|
|
42
|
+
description: Interactive utilities to develop in Ruby, implemented in Ruby and GTK3.
|
|
29
43
|
email: haijin.development@gmail.com
|
|
30
44
|
executables: []
|
|
31
45
|
extensions: []
|
|
32
46
|
extra_rdoc_files: []
|
|
33
47
|
files:
|
|
48
|
+
- lib/components/abstract_component.rb
|
|
34
49
|
- lib/components/component.rb
|
|
35
|
-
- lib/components/component_behaviour.rb
|
|
36
50
|
- lib/components/containers/splitter.rb
|
|
37
51
|
- lib/components/containers/stack.rb
|
|
38
52
|
- lib/components/containers/tabs.rb
|
|
@@ -40,16 +54,16 @@ files:
|
|
|
40
54
|
- lib/components/primitive_component.rb
|
|
41
55
|
- lib/components/widgets/button.rb
|
|
42
56
|
- lib/components/widgets/checkbox.rb
|
|
43
|
-
- lib/components/widgets/column_props.rb
|
|
44
57
|
- lib/components/widgets/input_text.rb
|
|
45
58
|
- lib/components/widgets/list.rb
|
|
46
59
|
- lib/components/widgets/list_choice.rb
|
|
47
60
|
- lib/components/widgets/radio_button.rb
|
|
48
61
|
- lib/components/widgets/text.rb
|
|
49
62
|
- lib/components/widgets/tree_choice.rb
|
|
50
|
-
- lib/
|
|
51
|
-
- lib/
|
|
52
|
-
- lib/
|
|
63
|
+
- lib/components_builder/column_props.rb
|
|
64
|
+
- lib/components_builder/columns_builder.rb
|
|
65
|
+
- lib/components_builder/layout_builder.rb
|
|
66
|
+
- lib/components_builder/radio_button_group_builder.rb
|
|
53
67
|
- lib/models/choice_model.rb
|
|
54
68
|
- lib/models/list_model.rb
|
|
55
69
|
- lib/models/tree_choice_model.rb
|
|
@@ -66,22 +80,39 @@ files:
|
|
|
66
80
|
- lib/sirens/components/modules_list.rb
|
|
67
81
|
- lib/sirens/components/namespaces_list.rb
|
|
68
82
|
- lib/sirens/models/constant_model.rb
|
|
83
|
+
- lib/sirens/models/icons.rb
|
|
84
|
+
- lib/sirens/models/method.rb
|
|
69
85
|
- lib/sirens/models/method_model.rb
|
|
70
86
|
- lib/sirens/models/module_browser_model.rb
|
|
71
87
|
- lib/sirens/models/object_browser_model.rb
|
|
88
|
+
- lib/views/abstract_view.rb
|
|
72
89
|
- lib/views/button_view.rb
|
|
73
|
-
- lib/views/
|
|
74
|
-
- lib/views/
|
|
90
|
+
- lib/views/checkbox_view.rb
|
|
91
|
+
- lib/views/component_view.rb
|
|
92
|
+
- lib/views/input_text_view.rb
|
|
75
93
|
- lib/views/list_view.rb
|
|
76
94
|
- lib/views/menu_view.rb
|
|
77
|
-
- lib/views/notebook_view.rb
|
|
78
|
-
- lib/views/paned_view.rb
|
|
79
95
|
- lib/views/radio_button_view.rb
|
|
96
|
+
- lib/views/splitter_view.rb
|
|
80
97
|
- lib/views/stack_view.rb
|
|
98
|
+
- lib/views/tabs_view.rb
|
|
81
99
|
- lib/views/text_view.rb
|
|
82
100
|
- lib/views/tree_view.rb
|
|
83
|
-
- lib/views/
|
|
101
|
+
- lib/views/widget_view.rb
|
|
84
102
|
- lib/views/window_view.rb
|
|
103
|
+
- resources/icons/array.png
|
|
104
|
+
- resources/icons/class.png
|
|
105
|
+
- resources/icons/false.png
|
|
106
|
+
- resources/icons/hash.png
|
|
107
|
+
- resources/icons/method.png
|
|
108
|
+
- resources/icons/module.png
|
|
109
|
+
- resources/icons/number.png
|
|
110
|
+
- resources/icons/object.png
|
|
111
|
+
- resources/icons/private-method.png
|
|
112
|
+
- resources/icons/protected-method.png
|
|
113
|
+
- resources/icons/public-method.png
|
|
114
|
+
- resources/icons/string.png
|
|
115
|
+
- resources/icons/true.png
|
|
85
116
|
homepage: https://rubygems.org/gems/sirens
|
|
86
117
|
licenses:
|
|
87
118
|
- MIT
|
|
@@ -102,9 +133,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
133
|
- !ruby/object:Gem::Version
|
|
103
134
|
version: '0'
|
|
104
135
|
requirements:
|
|
105
|
-
- gtk3 gobject-introspection
|
|
136
|
+
- gtk3 gobject-introspection method_source
|
|
106
137
|
rubygems_version: 3.0.3
|
|
107
138
|
signing_key:
|
|
108
139
|
specification_version: 4
|
|
109
|
-
summary:
|
|
140
|
+
summary: Development utilities for Ruby.
|
|
110
141
|
test_files: []
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
module Sirens
|
|
2
|
-
class LayoutBuilder
|
|
3
|
-
|
|
4
|
-
# Initializing
|
|
5
|
-
|
|
6
|
-
def initialize(main_component:)
|
|
7
|
-
@main_component = main_component
|
|
8
|
-
|
|
9
|
-
@props = Hash[]
|
|
10
|
-
@components = []
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Evaluating
|
|
14
|
-
|
|
15
|
-
def render(props = Hash[], &build_block)
|
|
16
|
-
instance_exec(@main_component, &build_block)
|
|
17
|
-
|
|
18
|
-
@main_component.add_all_components(@components)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Accessing
|
|
22
|
-
|
|
23
|
-
def merge_to_current_props(props)
|
|
24
|
-
@props.merge!(props)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Current component model
|
|
28
|
-
|
|
29
|
-
def model(object)
|
|
30
|
-
merge_to_current_props(model: object)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Current component props
|
|
34
|
-
|
|
35
|
-
def styles(props)
|
|
36
|
-
merge_to_current_props(props)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def props(props)
|
|
40
|
-
merge_to_current_props(props)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def handlers(props)
|
|
44
|
-
merge_to_current_props(props)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Components
|
|
48
|
-
|
|
49
|
-
def component(component, &build_block)
|
|
50
|
-
build_component_from(Hash[], build_block) { |props, child_components|
|
|
51
|
-
component.set_props(props)
|
|
52
|
-
|
|
53
|
-
component.add_all_components(child_components)
|
|
54
|
-
}
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Containers
|
|
58
|
-
|
|
59
|
-
def window(props = Hash[], &build_block)
|
|
60
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
61
|
-
Window.new(props)
|
|
62
|
-
.add_all_components(child_components)
|
|
63
|
-
}
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def horizontal_stack(props = Hash[], &build_block)
|
|
67
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
68
|
-
Stack.horizontal(props)
|
|
69
|
-
.add_all_components(child_components)
|
|
70
|
-
}
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def vertical_stack(props = Hash[], &build_block)
|
|
74
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
75
|
-
Stack.vertical(props)
|
|
76
|
-
.add_all_components(child_components)
|
|
77
|
-
}
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def horizontal_splitter(props = Hash[], &build_block)
|
|
81
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
82
|
-
Splitter.horizontal(props)
|
|
83
|
-
.add_all_components(child_components)
|
|
84
|
-
}
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def vertical_splitter(props = Hash[], &build_block)
|
|
88
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
89
|
-
Splitter.vertical(props)
|
|
90
|
-
.add_all_components(child_components)
|
|
91
|
-
}
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def tabs(props = Hash[], &build_block)
|
|
95
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
96
|
-
Tabs.new(props)
|
|
97
|
-
.add_all_components(child_components)
|
|
98
|
-
}
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# Widgets
|
|
102
|
-
|
|
103
|
-
def button(props = Hash[], &build_block)
|
|
104
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
105
|
-
Button.new(props)
|
|
106
|
-
}
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def checkbox(props = Hash[], &build_block)
|
|
110
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
111
|
-
Checkbox.new(props)
|
|
112
|
-
}
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def radio_button(props = Hash[], &build_block)
|
|
116
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
117
|
-
RadioButton.new(props)
|
|
118
|
-
}
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
def radio_buttons_group(props = Hash[], &build_block)
|
|
122
|
-
buttons = RadioButtonGroupBuilder.new.render(&build_block)
|
|
123
|
-
|
|
124
|
-
@components.concat(buttons)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def list(props = Hash[], &build_block)
|
|
128
|
-
columns_builder = ColumnsBuilder.new.render(props, &build_block)
|
|
129
|
-
|
|
130
|
-
props[:popup_menu] = columns_builder.popup_menu unless columns_builder.popup_menu.nil?
|
|
131
|
-
|
|
132
|
-
List.new(props).tap { |list|
|
|
133
|
-
list.define_columns(columns_builder.columns)
|
|
134
|
-
|
|
135
|
-
@components << list
|
|
136
|
-
}
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def choices_list(props = Hash[], &build_block)
|
|
140
|
-
columns_builder = ColumnsBuilder.new.render(props, &build_block)
|
|
141
|
-
|
|
142
|
-
props[:popup_menu] = columns_builder.popup_menu unless columns_builder.popup_menu.nil?
|
|
143
|
-
|
|
144
|
-
ListChoice.new(props).tap { |list|
|
|
145
|
-
list.define_columns(columns_builder.columns)
|
|
146
|
-
|
|
147
|
-
@components << list
|
|
148
|
-
}
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def input_text(props = Hash[], &build_block)
|
|
152
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
153
|
-
InputText.new(props)
|
|
154
|
-
}
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def text(props = Hash[], &build_block)
|
|
158
|
-
build_component_from(props, build_block) { |props, child_components|
|
|
159
|
-
Text.new(props)
|
|
160
|
-
}
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def choices_tree(props = Hash[], &build_block)
|
|
164
|
-
columns_builder = ColumnsBuilder.new.render(props, &build_block)
|
|
165
|
-
|
|
166
|
-
props[:popup_menu] = columns_builder.get_popup_menu unless columns_builder.get_popup_menu.nil?
|
|
167
|
-
|
|
168
|
-
TreeChoice.new(props).tap { |tree|
|
|
169
|
-
tree.define_columns(columns_builder.columns)
|
|
170
|
-
|
|
171
|
-
@components << tree
|
|
172
|
-
}
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def popup_menu(&block)
|
|
176
|
-
merge_to_current_props(popup_menu: block)
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
# Utility methods
|
|
180
|
-
|
|
181
|
-
def build_component_from(props = Hash[], build_block, &after_build_block)
|
|
182
|
-
current_props = @props
|
|
183
|
-
current_components = @components
|
|
184
|
-
|
|
185
|
-
built_component = nil
|
|
186
|
-
|
|
187
|
-
begin
|
|
188
|
-
@props = props.clone
|
|
189
|
-
@components = []
|
|
190
|
-
|
|
191
|
-
build_block.call unless build_block.nil?
|
|
192
|
-
|
|
193
|
-
built_component = after_build_block.call(@props, @components)
|
|
194
|
-
ensure
|
|
195
|
-
@props = current_props
|
|
196
|
-
@components = current_components
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
@components << built_component unless built_component.nil?
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
end
|
|
203
|
-
end
|