konpeito 0.1.0
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 +7 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +75 -0
- data/CONTRIBUTING.md +123 -0
- data/LICENSE +21 -0
- data/README.md +257 -0
- data/Rakefile +11 -0
- data/bin/konpeito +6 -0
- data/konpeito.gemspec +43 -0
- data/lib/konpeito/ast/typed_ast.rb +620 -0
- data/lib/konpeito/ast/visitor.rb +78 -0
- data/lib/konpeito/cache/cache_manager.rb +230 -0
- data/lib/konpeito/cache/dependency_graph.rb +192 -0
- data/lib/konpeito/cache.rb +8 -0
- data/lib/konpeito/cli/base_command.rb +187 -0
- data/lib/konpeito/cli/build_command.rb +220 -0
- data/lib/konpeito/cli/check_command.rb +104 -0
- data/lib/konpeito/cli/config.rb +231 -0
- data/lib/konpeito/cli/deps_command.rb +128 -0
- data/lib/konpeito/cli/doctor_command.rb +340 -0
- data/lib/konpeito/cli/fmt_command.rb +199 -0
- data/lib/konpeito/cli/init_command.rb +312 -0
- data/lib/konpeito/cli/lsp_command.rb +40 -0
- data/lib/konpeito/cli/run_command.rb +150 -0
- data/lib/konpeito/cli/test_command.rb +248 -0
- data/lib/konpeito/cli/watch_command.rb +212 -0
- data/lib/konpeito/cli.rb +301 -0
- data/lib/konpeito/codegen/builtin_methods.rb +229 -0
- data/lib/konpeito/codegen/cruby_backend.rb +1090 -0
- data/lib/konpeito/codegen/debug_info.rb +352 -0
- data/lib/konpeito/codegen/inliner.rb +486 -0
- data/lib/konpeito/codegen/jvm_backend.rb +197 -0
- data/lib/konpeito/codegen/jvm_generator.rb +13412 -0
- data/lib/konpeito/codegen/llvm_generator.rb +13191 -0
- data/lib/konpeito/codegen/loop_optimizer.rb +363 -0
- data/lib/konpeito/codegen/monomorphizer.rb +359 -0
- data/lib/konpeito/codegen/profile_runtime.c +341 -0
- data/lib/konpeito/codegen/profiler.rb +99 -0
- data/lib/konpeito/compiler.rb +592 -0
- data/lib/konpeito/dependency_resolver.rb +296 -0
- data/lib/konpeito/diagnostics/collector.rb +127 -0
- data/lib/konpeito/diagnostics/diagnostic.rb +237 -0
- data/lib/konpeito/diagnostics/renderer.rb +144 -0
- data/lib/konpeito/formatter/formatter.rb +1214 -0
- data/lib/konpeito/hir/builder.rb +7167 -0
- data/lib/konpeito/hir/nodes.rb +2465 -0
- data/lib/konpeito/lsp/document_manager.rb +820 -0
- data/lib/konpeito/lsp/server.rb +183 -0
- data/lib/konpeito/lsp/transport.rb +38 -0
- data/lib/konpeito/parser/prism_adapter.rb +65 -0
- data/lib/konpeito/platform.rb +103 -0
- data/lib/konpeito/profile/report.rb +136 -0
- data/lib/konpeito/rbs_inline/preprocessor.rb +199 -0
- data/lib/konpeito/stdlib/compression/compression.rb +72 -0
- data/lib/konpeito/stdlib/compression/compression.rbs +60 -0
- data/lib/konpeito/stdlib/compression/compression_native.c +415 -0
- data/lib/konpeito/stdlib/compression/extconf.rb +19 -0
- data/lib/konpeito/stdlib/crypto/crypto.rb +85 -0
- data/lib/konpeito/stdlib/crypto/crypto.rbs +74 -0
- data/lib/konpeito/stdlib/crypto/crypto_native.c +312 -0
- data/lib/konpeito/stdlib/crypto/extconf.rb +40 -0
- data/lib/konpeito/stdlib/http/extconf.rb +19 -0
- data/lib/konpeito/stdlib/http/http.rb +125 -0
- data/lib/konpeito/stdlib/http/http.rbs +57 -0
- data/lib/konpeito/stdlib/http/http_native.c +440 -0
- data/lib/konpeito/stdlib/json/extconf.rb +17 -0
- data/lib/konpeito/stdlib/json/json.rb +44 -0
- data/lib/konpeito/stdlib/json/json.rbs +33 -0
- data/lib/konpeito/stdlib/json/json_native.c +286 -0
- data/lib/konpeito/stdlib/ui/extconf.rb +216 -0
- data/lib/konpeito/stdlib/ui/konpeito_ui_native.cpp +1625 -0
- data/lib/konpeito/stdlib/ui/konpeito_ui_native.h +162 -0
- data/lib/konpeito/stdlib/ui/ui.rb +318 -0
- data/lib/konpeito/stdlib/ui/ui.rbs +247 -0
- data/lib/konpeito/type_checker/annotation_parser.rb +67 -0
- data/lib/konpeito/type_checker/hm_inferrer.rb +2565 -0
- data/lib/konpeito/type_checker/inferrer.rb +565 -0
- data/lib/konpeito/type_checker/rbs_loader.rb +1621 -0
- data/lib/konpeito/type_checker/type_resolver.rb +276 -0
- data/lib/konpeito/type_checker/types.rb +1434 -0
- data/lib/konpeito/type_checker/unification.rb +323 -0
- data/lib/konpeito/ui/animation/animated_state.rb +80 -0
- data/lib/konpeito/ui/animation/easing.rb +59 -0
- data/lib/konpeito/ui/animation/value_tween.rb +66 -0
- data/lib/konpeito/ui/app.rb +379 -0
- data/lib/konpeito/ui/box.rb +38 -0
- data/lib/konpeito/ui/castella.rb +70 -0
- data/lib/konpeito/ui/castella_native.rb +76 -0
- data/lib/konpeito/ui/chart/area_chart.rb +305 -0
- data/lib/konpeito/ui/chart/bar_chart.rb +288 -0
- data/lib/konpeito/ui/chart/base_chart.rb +210 -0
- data/lib/konpeito/ui/chart/chart_helpers.rb +79 -0
- data/lib/konpeito/ui/chart/gauge_chart.rb +171 -0
- data/lib/konpeito/ui/chart/heatmap_chart.rb +222 -0
- data/lib/konpeito/ui/chart/line_chart.rb +289 -0
- data/lib/konpeito/ui/chart/pie_chart.rb +219 -0
- data/lib/konpeito/ui/chart/scales.rb +77 -0
- data/lib/konpeito/ui/chart/scatter_chart.rb +303 -0
- data/lib/konpeito/ui/chart/stacked_bar_chart.rb +276 -0
- data/lib/konpeito/ui/column.rb +271 -0
- data/lib/konpeito/ui/core.rb +2199 -0
- data/lib/konpeito/ui/dsl.rb +443 -0
- data/lib/konpeito/ui/frame.rb +171 -0
- data/lib/konpeito/ui/frame_native.rb +494 -0
- data/lib/konpeito/ui/markdown/ast.rb +124 -0
- data/lib/konpeito/ui/markdown/mermaid/layout.rb +387 -0
- data/lib/konpeito/ui/markdown/mermaid/models.rb +232 -0
- data/lib/konpeito/ui/markdown/mermaid/parser.rb +519 -0
- data/lib/konpeito/ui/markdown/mermaid/renderer.rb +336 -0
- data/lib/konpeito/ui/markdown/parser.rb +805 -0
- data/lib/konpeito/ui/markdown/renderer.rb +639 -0
- data/lib/konpeito/ui/markdown/theme.rb +165 -0
- data/lib/konpeito/ui/render_node.rb +260 -0
- data/lib/konpeito/ui/row.rb +207 -0
- data/lib/konpeito/ui/spacer.rb +18 -0
- data/lib/konpeito/ui/style.rb +799 -0
- data/lib/konpeito/ui/theme.rb +563 -0
- data/lib/konpeito/ui/themes/material.rb +35 -0
- data/lib/konpeito/ui/themes/tokyo_night.rb +6 -0
- data/lib/konpeito/ui/widgets/button.rb +103 -0
- data/lib/konpeito/ui/widgets/calendar.rb +1034 -0
- data/lib/konpeito/ui/widgets/checkbox.rb +119 -0
- data/lib/konpeito/ui/widgets/container.rb +91 -0
- data/lib/konpeito/ui/widgets/data_table.rb +667 -0
- data/lib/konpeito/ui/widgets/divider.rb +29 -0
- data/lib/konpeito/ui/widgets/image.rb +105 -0
- data/lib/konpeito/ui/widgets/input.rb +485 -0
- data/lib/konpeito/ui/widgets/markdown.rb +57 -0
- data/lib/konpeito/ui/widgets/modal.rb +163 -0
- data/lib/konpeito/ui/widgets/multiline_input.rb +968 -0
- data/lib/konpeito/ui/widgets/multiline_text.rb +180 -0
- data/lib/konpeito/ui/widgets/net_image.rb +100 -0
- data/lib/konpeito/ui/widgets/progress_bar.rb +70 -0
- data/lib/konpeito/ui/widgets/radio_buttons.rb +93 -0
- data/lib/konpeito/ui/widgets/slider.rb +133 -0
- data/lib/konpeito/ui/widgets/switch.rb +84 -0
- data/lib/konpeito/ui/widgets/tabs.rb +157 -0
- data/lib/konpeito/ui/widgets/text.rb +110 -0
- data/lib/konpeito/ui/widgets/tree.rb +426 -0
- data/lib/konpeito/version.rb +5 -0
- data/lib/konpeito.rb +109 -0
- data/test_native_array.rb +172 -0
- data/test_native_array_class.rb +197 -0
- data/test_native_class.rb +151 -0
- data/tools/konpeito-asm/build.sh +65 -0
- data/tools/konpeito-asm/lib/asm-9.7.1.jar +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KArray.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KCompression.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KConditionVariable.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KCrypto.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KFile.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KHTTP.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KHash.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KJSON$Parser.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KJSON.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KMath.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KRactor.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KRactorPort.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KSizedQueue.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KThread.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/KTime.class +0 -0
- data/tools/konpeito-asm/runtime-classes/konpeito/runtime/RubyDispatch.class +0 -0
- data/tools/konpeito-asm/src/ClassIntrospector.java +312 -0
- data/tools/konpeito-asm/src/KonpeitoAssembler.java +659 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KArray.java +390 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KCompression.java +168 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KConditionVariable.java +48 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KCrypto.java +151 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KFile.java +100 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KHTTP.java +113 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KHash.java +228 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KJSON.java +405 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KMath.java +54 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KRactor.java +244 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KRactorPort.java +53 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KSizedQueue.java +49 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KThread.java +49 -0
- data/tools/konpeito-asm/src/konpeito/runtime/KTime.java +53 -0
- data/tools/konpeito-asm/src/konpeito/runtime/RubyDispatch.java +416 -0
- metadata +267 -0
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
# rbs_inline: enabled
|
|
2
|
+
|
|
3
|
+
# Style - composable widget style (CSS-inspired)
|
|
4
|
+
#
|
|
5
|
+
# Collects layout, visual, and typography properties and applies them to widgets.
|
|
6
|
+
# Each setter returns self for chaining.
|
|
7
|
+
# Compose via .then(other) or + to merge two Styles.
|
|
8
|
+
#
|
|
9
|
+
# Usage (with DSL s() helper):
|
|
10
|
+
# s.spacing(8).scrollable
|
|
11
|
+
# s.font_size(24).color(0xFFC0CAF5).bold
|
|
12
|
+
# style_a + style_b
|
|
13
|
+
#
|
|
14
|
+
# Note: Float fields use boolean flags instead of nil to avoid
|
|
15
|
+
# JVM null-unboxing issues (nil in Float field causes NPE).
|
|
16
|
+
|
|
17
|
+
class Style
|
|
18
|
+
def initialize
|
|
19
|
+
# Layout (Widget common)
|
|
20
|
+
@has_fixed_width = false
|
|
21
|
+
@fixed_width_val = 0
|
|
22
|
+
@has_fixed_height = false
|
|
23
|
+
@fixed_height_val = 0
|
|
24
|
+
@fit_content_val = false
|
|
25
|
+
@has_flex = false
|
|
26
|
+
@flex_val = 1
|
|
27
|
+
@has_padding = false
|
|
28
|
+
@pad_top = 0
|
|
29
|
+
@pad_right = 0
|
|
30
|
+
@pad_bottom = 0
|
|
31
|
+
@pad_left = 0
|
|
32
|
+
# Container (Column/Row)
|
|
33
|
+
@has_spacing = false
|
|
34
|
+
@spacing_val = 0
|
|
35
|
+
@scrollable_val = false
|
|
36
|
+
@pin_bottom_val = false
|
|
37
|
+
@pin_end_val = false
|
|
38
|
+
# Container wrapper (Container widget)
|
|
39
|
+
@has_bg_color = false
|
|
40
|
+
@bg_color_val = 0
|
|
41
|
+
@has_border_color = false
|
|
42
|
+
@border_color_val = 0
|
|
43
|
+
@has_border_radius = false
|
|
44
|
+
@border_radius_val = 0
|
|
45
|
+
# Text properties
|
|
46
|
+
@has_font_size = false
|
|
47
|
+
@font_size_val = 0
|
|
48
|
+
# Expanding policy
|
|
49
|
+
@has_expanding = false
|
|
50
|
+
@expanding_width_val = false
|
|
51
|
+
@expanding_height_val = false
|
|
52
|
+
# Typography (text visual)
|
|
53
|
+
@has_color = false
|
|
54
|
+
@color_val = 0
|
|
55
|
+
@has_text_color = false
|
|
56
|
+
@text_color_val = 0
|
|
57
|
+
@bold_val = false
|
|
58
|
+
@italic_val = false
|
|
59
|
+
@has_align = false
|
|
60
|
+
@align_val = 0
|
|
61
|
+
@has_font_family = false
|
|
62
|
+
@font_family_val = "default"
|
|
63
|
+
@has_kind = false
|
|
64
|
+
@kind_val = 0
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# --- Class methods: create new Style with one property set ---
|
|
68
|
+
|
|
69
|
+
#: (Float w) -> Style
|
|
70
|
+
def self.fixed_width(w)
|
|
71
|
+
Style.new.fixed_width(w)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
#: (Float w) -> Style
|
|
75
|
+
def self.width(w)
|
|
76
|
+
Style.new.fixed_width(w)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
#: (Float h) -> Style
|
|
80
|
+
def self.fixed_height(h)
|
|
81
|
+
Style.new.fixed_height(h)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
#: (Float h) -> Style
|
|
85
|
+
def self.height(h)
|
|
86
|
+
Style.new.fixed_height(h)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
#: (Float w, Float h) -> Style
|
|
90
|
+
def self.size(w, h)
|
|
91
|
+
Style.new.size(w, h)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
#: () -> Style
|
|
95
|
+
def self.fit_content
|
|
96
|
+
Style.new.fit_content
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
#: (Integer f) -> Style
|
|
100
|
+
def self.flex(f)
|
|
101
|
+
Style.new.flex(f)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
#: (Float v) -> Style
|
|
105
|
+
def self.padding(v)
|
|
106
|
+
Style.new.padding(v)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
#: (Float v) -> Style
|
|
110
|
+
def self.spacing(v)
|
|
111
|
+
Style.new.spacing(v)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
#: () -> Style
|
|
115
|
+
def self.scrollable
|
|
116
|
+
Style.new.scrollable
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
#: () -> Style
|
|
120
|
+
def self.pin_to_bottom
|
|
121
|
+
Style.new.pin_to_bottom
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
#: () -> Style
|
|
125
|
+
def self.pin_to_end
|
|
126
|
+
Style.new.pin_to_end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
#: (Integer c) -> Style
|
|
130
|
+
def self.bg_color(c)
|
|
131
|
+
Style.new.bg_color(c)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
#: (Integer c) -> Style
|
|
135
|
+
def self.border_color(c)
|
|
136
|
+
Style.new.border_color(c)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
#: (Float r) -> Style
|
|
140
|
+
def self.border_radius(r)
|
|
141
|
+
Style.new.border_radius(r)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
#: (Float s) -> Style
|
|
145
|
+
def self.font_size(s)
|
|
146
|
+
Style.new.font_size(s)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
#: () -> Style
|
|
150
|
+
def self.expanding
|
|
151
|
+
Style.new.expanding
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
#: () -> Style
|
|
155
|
+
def self.expanding_width
|
|
156
|
+
Style.new.expanding_width
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
#: () -> Style
|
|
160
|
+
def self.expanding_height
|
|
161
|
+
Style.new.expanding_height
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
#: (Integer c) -> Style
|
|
165
|
+
def self.color(c)
|
|
166
|
+
Style.new.color(c)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
#: (Integer c) -> Style
|
|
170
|
+
def self.text_color(c)
|
|
171
|
+
Style.new.text_color(c)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#: () -> Style
|
|
175
|
+
def self.bold
|
|
176
|
+
Style.new.bold
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
#: () -> Style
|
|
180
|
+
def self.italic
|
|
181
|
+
Style.new.italic
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
#: (Integer a) -> Style
|
|
185
|
+
def self.align(a)
|
|
186
|
+
Style.new.align(a)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
#: (String f) -> Style
|
|
190
|
+
def self.font_family(f)
|
|
191
|
+
Style.new.font_family(f)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
#: (Integer k) -> Style
|
|
195
|
+
def self.kind(k)
|
|
196
|
+
Style.new.kind(k)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# --- Instance methods: chainable setters ---
|
|
200
|
+
|
|
201
|
+
#: (Float w) -> Style
|
|
202
|
+
def fixed_width(w)
|
|
203
|
+
@has_fixed_width = true
|
|
204
|
+
@fixed_width_val = w
|
|
205
|
+
self
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
#: (Float w) -> Style
|
|
209
|
+
def width(w)
|
|
210
|
+
@has_fixed_width = true
|
|
211
|
+
@fixed_width_val = w
|
|
212
|
+
self
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
#: (Float h) -> Style
|
|
216
|
+
def fixed_height(h)
|
|
217
|
+
@has_fixed_height = true
|
|
218
|
+
@fixed_height_val = h
|
|
219
|
+
self
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
#: (Float h) -> Style
|
|
223
|
+
def height(h)
|
|
224
|
+
@has_fixed_height = true
|
|
225
|
+
@fixed_height_val = h
|
|
226
|
+
self
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
#: (Float w, Float h) -> Style
|
|
230
|
+
def size(w, h)
|
|
231
|
+
@has_fixed_width = true
|
|
232
|
+
@fixed_width_val = w
|
|
233
|
+
@has_fixed_height = true
|
|
234
|
+
@fixed_height_val = h
|
|
235
|
+
self
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
#: () -> Style
|
|
239
|
+
def fit_content
|
|
240
|
+
@fit_content_val = true
|
|
241
|
+
self
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
#: (Integer f) -> Style
|
|
245
|
+
def flex(f)
|
|
246
|
+
@has_flex = true
|
|
247
|
+
@flex_val = f
|
|
248
|
+
self
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
#: (Float v) -> Style
|
|
252
|
+
def padding(v)
|
|
253
|
+
@has_padding = true
|
|
254
|
+
@pad_top = v
|
|
255
|
+
@pad_right = v
|
|
256
|
+
@pad_bottom = v
|
|
257
|
+
@pad_left = v
|
|
258
|
+
self
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
#: (Float v) -> Style
|
|
262
|
+
def spacing(v)
|
|
263
|
+
@has_spacing = true
|
|
264
|
+
@spacing_val = v
|
|
265
|
+
self
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
#: () -> Style
|
|
269
|
+
def scrollable
|
|
270
|
+
@scrollable_val = true
|
|
271
|
+
self
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
#: () -> Style
|
|
275
|
+
def pin_to_bottom
|
|
276
|
+
@pin_bottom_val = true
|
|
277
|
+
self
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
#: () -> Style
|
|
281
|
+
def pin_to_end
|
|
282
|
+
@pin_end_val = true
|
|
283
|
+
self
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
#: (Integer c) -> Style
|
|
287
|
+
def bg_color(c)
|
|
288
|
+
@has_bg_color = true
|
|
289
|
+
@bg_color_val = c
|
|
290
|
+
self
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
#: (Integer c) -> Style
|
|
294
|
+
def border_color(c)
|
|
295
|
+
@has_border_color = true
|
|
296
|
+
@border_color_val = c
|
|
297
|
+
self
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
#: (Float r) -> Style
|
|
301
|
+
def border_radius(r)
|
|
302
|
+
@has_border_radius = true
|
|
303
|
+
@border_radius_val = r
|
|
304
|
+
self
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
#: (Float s) -> Style
|
|
308
|
+
def font_size(s)
|
|
309
|
+
@has_font_size = true
|
|
310
|
+
@font_size_val = s
|
|
311
|
+
self
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
#: () -> Style
|
|
315
|
+
def expanding
|
|
316
|
+
@has_expanding = true
|
|
317
|
+
@expanding_width_val = true
|
|
318
|
+
@expanding_height_val = true
|
|
319
|
+
self
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
#: () -> Style
|
|
323
|
+
def expanding_width
|
|
324
|
+
@has_expanding = true
|
|
325
|
+
@expanding_width_val = true
|
|
326
|
+
self
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
#: () -> Style
|
|
330
|
+
def expanding_height
|
|
331
|
+
@has_expanding = true
|
|
332
|
+
@expanding_height_val = true
|
|
333
|
+
self
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
# --- Typography setters ---
|
|
337
|
+
|
|
338
|
+
#: (Integer c) -> Style
|
|
339
|
+
def color(c)
|
|
340
|
+
@has_color = true
|
|
341
|
+
@color_val = c
|
|
342
|
+
self
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
#: (Integer c) -> Style
|
|
346
|
+
def text_color(c)
|
|
347
|
+
@has_text_color = true
|
|
348
|
+
@text_color_val = c
|
|
349
|
+
self
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
#: () -> Style
|
|
353
|
+
def bold
|
|
354
|
+
@bold_val = true
|
|
355
|
+
self
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
#: () -> Style
|
|
359
|
+
def italic
|
|
360
|
+
@italic_val = true
|
|
361
|
+
self
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
#: (Integer a) -> Style
|
|
365
|
+
def align(a)
|
|
366
|
+
@has_align = true
|
|
367
|
+
@align_val = a
|
|
368
|
+
self
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
#: (String f) -> Style
|
|
372
|
+
def font_family(f)
|
|
373
|
+
@has_font_family = true
|
|
374
|
+
@font_family_val = f
|
|
375
|
+
self
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
#: (Integer k) -> Style
|
|
379
|
+
def kind(k)
|
|
380
|
+
@has_kind = true
|
|
381
|
+
@kind_val = k
|
|
382
|
+
self
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
# --- Composition ---
|
|
386
|
+
|
|
387
|
+
#: (Style other) -> Style
|
|
388
|
+
def then(other)
|
|
389
|
+
result = Style.new
|
|
390
|
+
result.merge_from(self)
|
|
391
|
+
result.merge_from(other)
|
|
392
|
+
result
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
#: (Style other) -> Style
|
|
396
|
+
def +(other)
|
|
397
|
+
result = Style.new
|
|
398
|
+
result.merge_from(self)
|
|
399
|
+
result.merge_from(other)
|
|
400
|
+
result
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
#: (Style src) -> void
|
|
404
|
+
def merge_from(src)
|
|
405
|
+
if src.get_has_fixed_width
|
|
406
|
+
@has_fixed_width = true
|
|
407
|
+
@fixed_width_val = src.get_fixed_width
|
|
408
|
+
end
|
|
409
|
+
if src.get_has_fixed_height
|
|
410
|
+
@has_fixed_height = true
|
|
411
|
+
@fixed_height_val = src.get_fixed_height
|
|
412
|
+
end
|
|
413
|
+
if src.get_fit_content
|
|
414
|
+
@fit_content_val = true
|
|
415
|
+
end
|
|
416
|
+
if src.get_has_flex
|
|
417
|
+
@has_flex = true
|
|
418
|
+
@flex_val = src.get_flex
|
|
419
|
+
end
|
|
420
|
+
if src.get_has_padding
|
|
421
|
+
@has_padding = true
|
|
422
|
+
@pad_top = src.get_pad_top
|
|
423
|
+
@pad_right = src.get_pad_right
|
|
424
|
+
@pad_bottom = src.get_pad_bottom
|
|
425
|
+
@pad_left = src.get_pad_left
|
|
426
|
+
end
|
|
427
|
+
if src.get_has_spacing
|
|
428
|
+
@has_spacing = true
|
|
429
|
+
@spacing_val = src.get_spacing
|
|
430
|
+
end
|
|
431
|
+
if src.get_scrollable
|
|
432
|
+
@scrollable_val = true
|
|
433
|
+
end
|
|
434
|
+
if src.get_pin_bottom
|
|
435
|
+
@pin_bottom_val = true
|
|
436
|
+
end
|
|
437
|
+
if src.get_pin_end
|
|
438
|
+
@pin_end_val = true
|
|
439
|
+
end
|
|
440
|
+
if src.get_has_bg_color
|
|
441
|
+
@has_bg_color = true
|
|
442
|
+
@bg_color_val = src.get_bg_color
|
|
443
|
+
end
|
|
444
|
+
if src.get_has_border_color
|
|
445
|
+
@has_border_color = true
|
|
446
|
+
@border_color_val = src.get_border_color
|
|
447
|
+
end
|
|
448
|
+
if src.get_has_border_radius
|
|
449
|
+
@has_border_radius = true
|
|
450
|
+
@border_radius_val = src.get_border_radius
|
|
451
|
+
end
|
|
452
|
+
if src.get_has_font_size
|
|
453
|
+
@has_font_size = true
|
|
454
|
+
@font_size_val = src.get_font_size
|
|
455
|
+
end
|
|
456
|
+
if src.get_has_expanding
|
|
457
|
+
@has_expanding = true
|
|
458
|
+
@expanding_width_val = src.get_expanding_width
|
|
459
|
+
@expanding_height_val = src.get_expanding_height
|
|
460
|
+
end
|
|
461
|
+
# Typography
|
|
462
|
+
if src.get_has_color
|
|
463
|
+
@has_color = true
|
|
464
|
+
@color_val = src.get_color
|
|
465
|
+
end
|
|
466
|
+
if src.get_has_text_color
|
|
467
|
+
@has_text_color = true
|
|
468
|
+
@text_color_val = src.get_text_color
|
|
469
|
+
end
|
|
470
|
+
if src.get_bold
|
|
471
|
+
@bold_val = true
|
|
472
|
+
end
|
|
473
|
+
if src.get_italic
|
|
474
|
+
@italic_val = true
|
|
475
|
+
end
|
|
476
|
+
if src.get_has_align
|
|
477
|
+
@has_align = true
|
|
478
|
+
@align_val = src.get_align
|
|
479
|
+
end
|
|
480
|
+
if src.get_has_font_family
|
|
481
|
+
@has_font_family = true
|
|
482
|
+
@font_family_val = src.get_font_family
|
|
483
|
+
end
|
|
484
|
+
if src.get_has_kind
|
|
485
|
+
@has_kind = true
|
|
486
|
+
@kind_val = src.get_kind
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
# --- Getters (for merge_from) ---
|
|
491
|
+
|
|
492
|
+
#: () -> bool
|
|
493
|
+
def get_has_fixed_width
|
|
494
|
+
@has_fixed_width
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
#: () -> Float
|
|
498
|
+
def get_fixed_width
|
|
499
|
+
@fixed_width_val
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
#: () -> bool
|
|
503
|
+
def get_has_fixed_height
|
|
504
|
+
@has_fixed_height
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
#: () -> Float
|
|
508
|
+
def get_fixed_height
|
|
509
|
+
@fixed_height_val
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
#: () -> bool
|
|
513
|
+
def get_fit_content
|
|
514
|
+
@fit_content_val
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
#: () -> bool
|
|
518
|
+
def get_has_flex
|
|
519
|
+
@has_flex
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
#: () -> Integer
|
|
523
|
+
def get_flex
|
|
524
|
+
@flex_val
|
|
525
|
+
end
|
|
526
|
+
|
|
527
|
+
#: () -> bool
|
|
528
|
+
def get_has_padding
|
|
529
|
+
@has_padding
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
#: () -> Float
|
|
533
|
+
def get_pad_top
|
|
534
|
+
@pad_top
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
#: () -> Float
|
|
538
|
+
def get_pad_right
|
|
539
|
+
@pad_right
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
#: () -> Float
|
|
543
|
+
def get_pad_bottom
|
|
544
|
+
@pad_bottom
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
#: () -> Float
|
|
548
|
+
def get_pad_left
|
|
549
|
+
@pad_left
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
#: () -> bool
|
|
553
|
+
def get_has_spacing
|
|
554
|
+
@has_spacing
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
#: () -> Float
|
|
558
|
+
def get_spacing
|
|
559
|
+
@spacing_val
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
#: () -> bool
|
|
563
|
+
def get_scrollable
|
|
564
|
+
@scrollable_val
|
|
565
|
+
end
|
|
566
|
+
|
|
567
|
+
#: () -> bool
|
|
568
|
+
def get_pin_bottom
|
|
569
|
+
@pin_bottom_val
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
#: () -> bool
|
|
573
|
+
def get_pin_end
|
|
574
|
+
@pin_end_val
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
#: () -> bool
|
|
578
|
+
def get_has_bg_color
|
|
579
|
+
@has_bg_color
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
#: () -> Integer
|
|
583
|
+
def get_bg_color
|
|
584
|
+
@bg_color_val
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
#: () -> bool
|
|
588
|
+
def get_has_border_color
|
|
589
|
+
@has_border_color
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
#: () -> Integer
|
|
593
|
+
def get_border_color
|
|
594
|
+
@border_color_val
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
#: () -> bool
|
|
598
|
+
def get_has_border_radius
|
|
599
|
+
@has_border_radius
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
#: () -> Float
|
|
603
|
+
def get_border_radius
|
|
604
|
+
@border_radius_val
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
#: () -> bool
|
|
608
|
+
def get_has_font_size
|
|
609
|
+
@has_font_size
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
#: () -> Float
|
|
613
|
+
def get_font_size
|
|
614
|
+
@font_size_val
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
#: () -> bool
|
|
618
|
+
def get_has_expanding
|
|
619
|
+
@has_expanding
|
|
620
|
+
end
|
|
621
|
+
|
|
622
|
+
#: () -> bool
|
|
623
|
+
def get_expanding_width
|
|
624
|
+
@expanding_width_val
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
#: () -> bool
|
|
628
|
+
def get_expanding_height
|
|
629
|
+
@expanding_height_val
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
# Typography getters
|
|
633
|
+
|
|
634
|
+
#: () -> bool
|
|
635
|
+
def get_has_color
|
|
636
|
+
@has_color
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
#: () -> Integer
|
|
640
|
+
def get_color
|
|
641
|
+
@color_val
|
|
642
|
+
end
|
|
643
|
+
|
|
644
|
+
#: () -> bool
|
|
645
|
+
def get_has_text_color
|
|
646
|
+
@has_text_color
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
#: () -> Integer
|
|
650
|
+
def get_text_color
|
|
651
|
+
@text_color_val
|
|
652
|
+
end
|
|
653
|
+
|
|
654
|
+
#: () -> bool
|
|
655
|
+
def get_bold
|
|
656
|
+
@bold_val
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
#: () -> bool
|
|
660
|
+
def get_italic
|
|
661
|
+
@italic_val
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
#: () -> bool
|
|
665
|
+
def get_has_align
|
|
666
|
+
@has_align
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
#: () -> Integer
|
|
670
|
+
def get_align
|
|
671
|
+
@align_val
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
#: () -> bool
|
|
675
|
+
def get_has_font_family
|
|
676
|
+
@has_font_family
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
#: () -> String
|
|
680
|
+
def get_font_family
|
|
681
|
+
@font_family_val
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
#: () -> bool
|
|
685
|
+
def get_has_kind
|
|
686
|
+
@has_kind
|
|
687
|
+
end
|
|
688
|
+
|
|
689
|
+
#: () -> Integer
|
|
690
|
+
def get_kind
|
|
691
|
+
@kind_val
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
# --- Apply to widget (explicit dispatch, no send/method_missing) ---
|
|
695
|
+
|
|
696
|
+
#: (untyped widget) -> untyped
|
|
697
|
+
def apply_layout(widget)
|
|
698
|
+
if @has_fixed_width
|
|
699
|
+
widget.fixed_width(@fixed_width_val)
|
|
700
|
+
end
|
|
701
|
+
if @has_fixed_height
|
|
702
|
+
widget.fixed_height(@fixed_height_val)
|
|
703
|
+
end
|
|
704
|
+
if @fit_content_val
|
|
705
|
+
widget.fit_content
|
|
706
|
+
end
|
|
707
|
+
if @has_flex
|
|
708
|
+
widget.flex(@flex_val)
|
|
709
|
+
end
|
|
710
|
+
if @has_padding
|
|
711
|
+
widget.padding(@pad_top, @pad_right, @pad_bottom, @pad_left)
|
|
712
|
+
end
|
|
713
|
+
if @has_expanding
|
|
714
|
+
if @expanding_width_val
|
|
715
|
+
widget.set_width_policy(EXPANDING)
|
|
716
|
+
end
|
|
717
|
+
if @expanding_height_val
|
|
718
|
+
widget.set_height_policy(EXPANDING)
|
|
719
|
+
end
|
|
720
|
+
end
|
|
721
|
+
widget
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
#: (untyped widget) -> untyped
|
|
725
|
+
def apply_container(widget)
|
|
726
|
+
if @has_spacing
|
|
727
|
+
widget.spacing(@spacing_val)
|
|
728
|
+
end
|
|
729
|
+
if @scrollable_val
|
|
730
|
+
widget.scrollable
|
|
731
|
+
end
|
|
732
|
+
if @pin_bottom_val
|
|
733
|
+
widget.pin_to_bottom
|
|
734
|
+
end
|
|
735
|
+
if @pin_end_val
|
|
736
|
+
widget.pin_to_end
|
|
737
|
+
end
|
|
738
|
+
widget
|
|
739
|
+
end
|
|
740
|
+
|
|
741
|
+
#: (untyped widget) -> untyped
|
|
742
|
+
def apply_visual(widget)
|
|
743
|
+
if @has_bg_color
|
|
744
|
+
widget.bg_color(@bg_color_val)
|
|
745
|
+
end
|
|
746
|
+
if @has_border_color
|
|
747
|
+
widget.border_color(@border_color_val)
|
|
748
|
+
end
|
|
749
|
+
if @has_border_radius
|
|
750
|
+
widget.border_radius(@border_radius_val)
|
|
751
|
+
end
|
|
752
|
+
widget
|
|
753
|
+
end
|
|
754
|
+
|
|
755
|
+
#: (untyped widget) -> untyped
|
|
756
|
+
def apply_text(widget)
|
|
757
|
+
if @has_font_size
|
|
758
|
+
widget.font_size(@font_size_val)
|
|
759
|
+
end
|
|
760
|
+
widget
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
#: (untyped widget) -> untyped
|
|
764
|
+
def apply_typography(widget)
|
|
765
|
+
if @has_font_size
|
|
766
|
+
widget.font_size(@font_size_val)
|
|
767
|
+
end
|
|
768
|
+
if @has_color
|
|
769
|
+
widget.color(@color_val)
|
|
770
|
+
end
|
|
771
|
+
if @has_text_color
|
|
772
|
+
widget.text_color(@text_color_val)
|
|
773
|
+
end
|
|
774
|
+
if @bold_val
|
|
775
|
+
widget.bold
|
|
776
|
+
end
|
|
777
|
+
if @italic_val
|
|
778
|
+
widget.italic
|
|
779
|
+
end
|
|
780
|
+
if @has_align
|
|
781
|
+
widget.align(@align_val)
|
|
782
|
+
end
|
|
783
|
+
if @has_font_family
|
|
784
|
+
widget.font_family(@font_family_val)
|
|
785
|
+
end
|
|
786
|
+
if @has_kind
|
|
787
|
+
widget.kind(@kind_val)
|
|
788
|
+
end
|
|
789
|
+
widget
|
|
790
|
+
end
|
|
791
|
+
|
|
792
|
+
#: (untyped widget) -> untyped
|
|
793
|
+
def apply(widget)
|
|
794
|
+
apply_layout(widget)
|
|
795
|
+
apply_container(widget)
|
|
796
|
+
apply_visual(widget)
|
|
797
|
+
widget
|
|
798
|
+
end
|
|
799
|
+
end
|