glimmer-dsl-libui 0.3.1 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,79 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ class BasicScrollingArea
4
+ include Glimmer
5
+
6
+ SCROLLING_AREA_WIDTH = 800
7
+ SCROLLING_AREA_HEIGHT = 400
8
+ SCROLLING_AREA_PADDING_X = 20
9
+ SCROLLING_AREA_PADDING_Y = 20
10
+
11
+ def initialize
12
+ @x = SCROLLING_AREA_PADDING_X
13
+ @y = SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y
14
+ create_gui
15
+ Glimmer::LibUI.timer(0.01) do
16
+ @x += SCROLLING_AREA_PADDING_X
17
+ @y = [[@y + rand(SCROLLING_AREA_PADDING_Y*4)*(rand(2) == 0 ? -1 : 1), SCROLLING_AREA_PADDING_Y].max, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y].min
18
+ @graph.content { # re-open @graph's content and add a line
19
+ line(@x, @y)
20
+ }
21
+ # if there is a need to enlarge scrolling area, call `@scrolling_area.set_size(new_width, new_height)`
22
+ # Note that `#scroll_to` does not seem to work on Linux, but normal scrolling does.
23
+ @scrolling_area.scroll_to(@x - (SCROLLING_AREA_WIDTH/2), @y) # 3rd and 4th arguments for width and height are assumed as those of main window by default if not supplied
24
+ # return false to stop timer once @x exceeds scrolling area width - padding
25
+ false if @x >= (SCROLLING_AREA_WIDTH - SCROLLING_AREA_PADDING_X*2)
26
+ end
27
+ end
28
+
29
+ def launch
30
+ @main_window.show
31
+ end
32
+
33
+ def x_axis
34
+ polyline(SCROLLING_AREA_PADDING_X, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y, SCROLLING_AREA_WIDTH - SCROLLING_AREA_PADDING_X*2, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y) {
35
+ stroke :black, thickness: 3
36
+ }
37
+
38
+ ((SCROLLING_AREA_WIDTH - SCROLLING_AREA_PADDING_X*4) / SCROLLING_AREA_PADDING_X).times do |x_multiplier|
39
+ x = x_multiplier*SCROLLING_AREA_PADDING_X + SCROLLING_AREA_PADDING_X*2
40
+ y = SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y
41
+
42
+ polyline(x, y, x, y + SCROLLING_AREA_PADDING_Y/2) {
43
+ stroke :black, thickness: 2
44
+ }
45
+ end
46
+ end
47
+
48
+ def y_axis
49
+ polyline(SCROLLING_AREA_PADDING_X, SCROLLING_AREA_PADDING_Y, SCROLLING_AREA_PADDING_X, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y) {
50
+ stroke :black, thickness: 3
51
+ }
52
+
53
+ ((SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y*3) / SCROLLING_AREA_PADDING_Y).times do |y_multiplier|
54
+ x = SCROLLING_AREA_PADDING_X
55
+ y = y_multiplier*SCROLLING_AREA_PADDING_Y + SCROLLING_AREA_PADDING_Y*2
56
+
57
+ polyline(x, y, x - SCROLLING_AREA_PADDING_X/2, y) {
58
+ stroke :black, thickness: 2
59
+ }
60
+ end
61
+ end
62
+
63
+ def create_gui
64
+ @main_window = window('Basic Scrolling Area', SCROLLING_AREA_WIDTH / 2, SCROLLING_AREA_HEIGHT) {
65
+ resizable false
66
+
67
+ @scrolling_area = scrolling_area(SCROLLING_AREA_WIDTH, SCROLLING_AREA_HEIGHT) { # double width of window enables horizontal scrolling
68
+ x_axis
69
+ y_axis
70
+
71
+ @graph = figure(SCROLLING_AREA_PADDING_X, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y) {
72
+ stroke :blue, thickness: 2
73
+ }
74
+ }
75
+ }
76
+ end
77
+ end
78
+
79
+ BasicScrollingArea.new.launch
@@ -4,17 +4,14 @@ include Glimmer
4
4
 
5
5
  window('Basic Transform', 350, 350) {
6
6
  area {
7
- path {
8
- square(0, 0, 350)
9
-
7
+ square(0, 0, 350) {
10
8
  fill r: 255, g: 255, b: 0
11
9
  }
12
10
  40.times do |n|
13
- path {
14
- square(0, 0, 100)
15
-
11
+ square(0, 0, 100) {
16
12
  fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
17
13
  stroke :black, thickness: 2
14
+
18
15
  transform {
19
16
  unless OS.windows?
20
17
  skew 0.15, 0.15
@@ -0,0 +1,34 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ include Glimmer
4
+
5
+ window('Basic Transform', 350, 350) {
6
+ area {
7
+ path {
8
+ square(0, 0, 350)
9
+
10
+ fill r: 255, g: 255, b: 0
11
+ }
12
+ 40.times do |n|
13
+ path {
14
+ square(0, 0, 100)
15
+
16
+ fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
17
+ stroke :black, thickness: 2
18
+
19
+ transform {
20
+ unless OS.windows?
21
+ skew 0.15, 0.15
22
+ translate 50, 50
23
+ end
24
+ rotate 100, 100, -9 * n
25
+ scale 1.1, 1.1
26
+ if OS.windows?
27
+ skew 0.15, 0.15
28
+ translate 50, 50
29
+ end
30
+ }
31
+ }
32
+ end
33
+ }
34
+ }.show
@@ -201,9 +201,7 @@ class ColorTheCircles
201
201
  }
202
202
 
203
203
  @circles_data.each do |circle_data|
204
- path {
205
- circle_data[:circle] = circle(*circle_data[:args])
206
-
204
+ circle_data[:circle] = circle(*circle_data[:args]) {
207
205
  fill circle_data[:fill]
208
206
  stroke circle_data[:stroke]
209
207
  }
@@ -88,9 +88,7 @@ window('Dynamic Area', 240, 600) {
88
88
 
89
89
  @area = area {
90
90
  on_draw do |area_draw_params|
91
- path { # a dynamic path is added semi-declaratively inside on_draw block
92
- rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value)
93
-
91
+ rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value) { # a dynamic path is added semi-declaratively inside on_draw block
94
92
  fill r: @red_spinbox.value, g: @green_spinbox.value, b: @blue_spinbox.value, a: @alpha_spinbox.value / 100.0
95
93
  }
96
94
  end
@@ -54,7 +54,7 @@ window('Dynamic Area', 240, 600) {
54
54
  value 102
55
55
 
56
56
  on_changed do
57
- @path.fill[:r] = @red_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
57
+ @rectangle.fill[:r] = @red_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
58
58
  end
59
59
  }
60
60
 
@@ -63,7 +63,7 @@ window('Dynamic Area', 240, 600) {
63
63
  value 102
64
64
 
65
65
  on_changed do
66
- @path.fill[:g] = @green_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
66
+ @rectangle.fill[:g] = @green_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
67
67
  end
68
68
  }
69
69
 
@@ -72,7 +72,7 @@ window('Dynamic Area', 240, 600) {
72
72
  value 204
73
73
 
74
74
  on_changed do
75
- @path.fill[:b] = @blue_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
75
+ @rectangle.fill[:b] = @blue_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
76
76
  end
77
77
  }
78
78
 
@@ -81,15 +81,13 @@ window('Dynamic Area', 240, 600) {
81
81
  value 100
82
82
 
83
83
  on_changed do
84
- @path.fill[:a] = @alpha_spinbox.value / 100.0 # updating hash properties automatically triggers area.queue_redraw_all
84
+ @rectangle.fill[:a] = @alpha_spinbox.value / 100.0 # updating hash properties automatically triggers area.queue_redraw_all
85
85
  end
86
86
  }
87
87
  }
88
88
 
89
89
  area {
90
- @path = path { # stable path
91
- @rectangle = rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value)
92
-
90
+ @rectangle = rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value) { # stable path
93
91
  fill r: @red_spinbox.value, g: @green_spinbox.value, b: @blue_spinbox.value, a: @alpha_spinbox.value / 100.0
94
92
  }
95
93
  }
@@ -22,15 +22,19 @@ window('Contacts', 600, 600) { |w|
22
22
  @name_entry = entry {
23
23
  label 'Name'
24
24
  }
25
+
25
26
  @email_entry = entry {
26
27
  label 'Email'
27
28
  }
29
+
28
30
  @phone_entry = entry {
29
31
  label 'Phone'
30
32
  }
33
+
31
34
  @city_entry = entry {
32
35
  label 'City'
33
36
  }
37
+
34
38
  @state_entry = entry {
35
39
  label 'State'
36
40
  }
data/examples/grid.rb CHANGED
@@ -8,16 +8,16 @@ window('Grid') {
8
8
  tab {
9
9
  tab_item('Span') {
10
10
  grid {
11
- 4.times { |top_value|
12
- 4.times { |left_value|
11
+ 4.times do |top_value|
12
+ 4.times do |left_value|
13
13
  label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
14
14
  left left_value
15
15
  top top_value
16
16
  hexpand true
17
17
  vexpand true
18
18
  }
19
- }
20
- }
19
+ end
20
+ end
21
21
  label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
22
22
  left 0
23
23
  top 4
@@ -79,19 +79,15 @@ window('histogram example', 640, 480) {
79
79
 
80
80
  @area = area {
81
81
  on_draw do |area_draw_params|
82
- path {
83
- rectangle(0, 0, area_draw_params[:area_width], area_draw_params[:area_height])
84
-
82
+ rectangle(0, 0, area_draw_params[:area_width], area_draw_params[:area_height]) {
85
83
  fill 0xFFFFFF
86
84
  }
87
85
 
88
86
  graph_width, graph_height = *graph_size(area_draw_params[:area_width], area_draw_params[:area_height])
89
87
 
90
- path {
91
- figure(X_OFF_LEFT, Y_OFF_TOP) {
92
- line(X_OFF_LEFT, Y_OFF_TOP + graph_height)
93
- line(X_OFF_LEFT + graph_width, Y_OFF_TOP + graph_height)
94
- }
88
+ figure(X_OFF_LEFT, Y_OFF_TOP) {
89
+ line(X_OFF_LEFT, Y_OFF_TOP + graph_height)
90
+ line(X_OFF_LEFT + graph_width, Y_OFF_TOP + graph_height)
95
91
 
96
92
  stroke 0x000000, thickness: 2, miter_limit: 10
97
93
  }
@@ -5,8 +5,10 @@ require 'fileutils'
5
5
  class MetaExample
6
6
  include Glimmer
7
7
 
8
+ ADDITIONAL_BASIC_EXAMPLES = ['Color Button', 'Font Button', 'Form', 'Date Time Picker', 'Simple Notepad']
9
+
8
10
  def initialize
9
- @selected_example_index = 0
11
+ @selected_example_index = examples_with_versions.index(basic_examples_with_versions.first)
10
12
  end
11
13
 
12
14
  def examples
@@ -25,6 +27,14 @@ class MetaExample
25
27
  end
26
28
  end
27
29
 
30
+ def basic_examples_with_versions
31
+ examples_with_versions.select {|example| example.start_with?('Basic') || ADDITIONAL_BASIC_EXAMPLES.include?(example) }
32
+ end
33
+
34
+ def advanced_examples_with_versions
35
+ examples_with_versions - basic_examples_with_versions
36
+ end
37
+
28
38
  def file_path_for(example)
29
39
  File.join(File.expand_path('.', __dir__), "#{example.underscore}.rb")
30
40
  end
@@ -66,17 +76,47 @@ class MetaExample
66
76
  vertical_box {
67
77
  stretchy false
68
78
 
69
- @example_radio_buttons = radio_buttons {
79
+ tab {
70
80
  stretchy false
71
- items examples_with_versions
72
- selected @selected_example_index
73
81
 
74
- on_selected do
75
- @selected_example_index = @example_radio_buttons.selected
76
- example = selected_example
77
- @code_entry.text = File.read(file_path_for(example))
78
- @version_spinbox.value = 1
79
- end
82
+ tab_item('Basic') {
83
+ vertical_box {
84
+ @basic_example_radio_buttons = radio_buttons {
85
+ stretchy false
86
+ items basic_examples_with_versions
87
+ selected basic_examples_with_versions.index(examples_with_versions[@selected_example_index])
88
+
89
+ on_selected do
90
+ @selected_example_index = examples_with_versions.index(basic_examples_with_versions[@basic_example_radio_buttons.selected])
91
+ example = selected_example
92
+ @code_entry.text = File.read(file_path_for(example))
93
+ @version_spinbox.value = 1
94
+ end
95
+ }
96
+
97
+ label # filler
98
+ label # filler
99
+ }
100
+ }
101
+
102
+ tab_item('Advanced') {
103
+ vertical_box {
104
+ @advanced_example_radio_buttons = radio_buttons {
105
+ stretchy false
106
+ items advanced_examples_with_versions
107
+
108
+ on_selected do
109
+ @selected_example_index = examples_with_versions.index(advanced_examples_with_versions[@advanced_example_radio_buttons.selected])
110
+ example = selected_example
111
+ @code_entry.text = File.read(file_path_for(example))
112
+ @version_spinbox.value = 1
113
+ end
114
+ }
115
+
116
+ label # filler
117
+ label # filler
118
+ }
119
+ }
80
120
  }
81
121
 
82
122
  horizontal_box {
data/examples/snake.rb CHANGED
@@ -61,9 +61,7 @@ class Snake
61
61
 
62
62
  @game.width.times do |column|
63
63
  area {
64
- @cell_grid.last << path {
65
- square(0, 0, CELL_SIZE)
66
-
64
+ @cell_grid.last << square(0, 0, CELL_SIZE) {
67
65
  fill Presenter::Cell::COLOR_CLEAR
68
66
  }
69
67
 
data/examples/tetris.rb CHANGED
@@ -203,34 +203,31 @@ class Tetris
203
203
  bevel_pixel_size = 0.16 * block_size.to_f
204
204
  color = Glimmer::LibUI.interpret_color(Model::Block::COLOR_CLEAR)
205
205
  area {
206
- block[:background_square] = path {
207
- square(0, 0, block_size)
208
-
206
+ block[:background_square] = square(0, 0, block_size) {
209
207
  fill color
210
208
  }
211
- block[:top_bevel_edge] = path {
212
- polygon(0, 0, block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size)
213
-
209
+
210
+ block[:top_bevel_edge] = polygon {
211
+ point_array 0, 0, block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size
214
212
  fill r: color[:r] + 4*BEVEL_CONSTANT, g: color[:g] + 4*BEVEL_CONSTANT, b: color[:b] + 4*BEVEL_CONSTANT
215
213
  }
216
- block[:right_bevel_edge] = path {
217
- polygon(block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size, block_size)
218
-
214
+
215
+ block[:right_bevel_edge] = polygon {
216
+ point_array block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size, block_size
219
217
  fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
220
218
  }
221
- block[:bottom_bevel_edge] = path {
222
- polygon(block_size, block_size, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size)
223
-
219
+
220
+ block[:bottom_bevel_edge] = polygon {
221
+ point_array block_size, block_size, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size
224
222
  fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
225
223
  }
226
- block[:left_bevel_edge] = path {
227
- polygon(0, 0, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size)
228
-
224
+
225
+ block[:left_bevel_edge] = polygon {
226
+ point_array 0, 0, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size
229
227
  fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
230
228
  }
231
- block[:border_square] = path {
232
- square(0, 0, block_size)
233
-
229
+
230
+ block[:border_square] = square(0, 0, block_size) {
234
231
  stroke COLOR_GRAY
235
232
  }
236
233
 
@@ -38,8 +38,10 @@ class TicTacToe
38
38
 
39
39
  #row and column numbers are 1-based
40
40
  def mark(row, column)
41
- self[row, column].mark(current_sign)
42
- game_over? #updates winning sign
41
+ if self[row, column].empty
42
+ self[row, column].mark(current_sign)
43
+ game_over? #updates winning sign
44
+ end
43
45
  end
44
46
 
45
47
  def current_sign
@@ -45,9 +45,7 @@ class TicTacToe
45
45
 
46
46
  3.times.map do |column|
47
47
  area {
48
- path {
49
- square(0, 0, 60)
50
-
48
+ square(0, 0, 60) {
51
49
  stroke :black, thickness: 2
52
50
  }
53
51
  text(23, 19) {
Binary file
@@ -21,6 +21,9 @@
21
21
 
22
22
  require 'glimmer/dsl/expression'
23
23
  require 'glimmer/dsl/parent_expression'
24
+ require 'glimmer/libui/control_proxy/path_proxy'
25
+ require 'glimmer/libui/shape'
26
+ require 'glimmer/libui/control_proxy/area_proxy'
24
27
 
25
28
  module Glimmer
26
29
  module DSL
@@ -32,7 +35,9 @@ module Glimmer
32
35
  Glimmer::LibUI::Shape.exists?(keyword) and
33
36
  (
34
37
  parent.is_a?(Glimmer::LibUI::ControlProxy::PathProxy) or
35
- parent.is_a?(Glimmer::LibUI::Shape)
38
+ parent.is_a?(Glimmer::LibUI::Shape) or
39
+ parent.is_a?(Glimmer::LibUI::ControlProxy::AreaProxy) or
40
+ (parent.nil? && Glimmer::LibUI::ControlProxy::AreaProxy.current_area_draw_params)
36
41
  )
37
42
  end
38
43
 
@@ -31,8 +31,43 @@ module Glimmer
31
31
  class ScrollingAreaProxy < AreaProxy
32
32
  def build_control
33
33
  @area_handler = ::LibUI::FFI::AreaHandler.malloc
34
+ @args[0] ||= Glimmer::LibUI::ControlProxy.main_window_proxy.width
35
+ @args[1] ||= Glimmer::LibUI::ControlProxy.main_window_proxy.height
34
36
  @libui = ::LibUI.new_scrolling_area(@area_handler, *@args)
35
37
  end
38
+
39
+ def width(value = nil)
40
+ if value.nil?
41
+ @args[0]
42
+ else
43
+ @args[0] = value
44
+ set_size(width, height)
45
+ end
46
+ end
47
+ alias width= width
48
+ alias set_width width
49
+
50
+ def height(value = nil)
51
+ if value.nil?
52
+ @args[1]
53
+ else
54
+ @args[1] = value
55
+ set_size(width, height)
56
+ end
57
+ end
58
+ alias height= height
59
+ alias set_height height
60
+
61
+ def set_size(width, height)
62
+ @args[0] = width
63
+ @args[1] = height
64
+ super(width, height)
65
+ end
66
+
67
+ def scroll_to(scroll_x, scroll_y, scroll_width = nil, scroll_height = nil)
68
+ scroll_width, scroll_height = Glimmer::LibUI::ControlProxy.main_window_proxy.content_size
69
+ super(scroll_x, scroll_y, scroll_width, scroll_height)
70
+ end
36
71
  end
37
72
  end
38
73
  end
@@ -123,8 +123,7 @@ module Glimmer
123
123
  end
124
124
 
125
125
  def area_image?
126
- @parent_proxy&.is_a?(AreaProxy) or
127
- AreaProxy.current_area_draw_params
126
+ @area_image ||= !!(@parent_proxy&.is_a?(AreaProxy) || AreaProxy.current_area_draw_params)
128
127
  end
129
128
 
130
129
  def destroy
@@ -113,6 +113,26 @@ module Glimmer
113
113
  alias content_size= content_size
114
114
  alias set_content_size content_size
115
115
 
116
+ def width(value = nil)
117
+ if value.nil?
118
+ content_size.first
119
+ else
120
+ set_content_size(value, height)
121
+ end
122
+ end
123
+ alias width= width
124
+ alias set_width width
125
+
126
+ def height(value = nil)
127
+ if value.nil?
128
+ content_size.last
129
+ else
130
+ set_content_size(width, value)
131
+ end
132
+ end
133
+ alias height= height
134
+ alias set_height height
135
+
116
136
  def resizable(value = nil)
117
137
  if value.nil?
118
138
  @resizable = true if @resizable.nil?
@@ -73,12 +73,27 @@ module Glimmer
73
73
  @args = args
74
74
  @block = block
75
75
  set_parameter_defaults
76
+ build_control if implicit_path?
76
77
  post_add_content if @block.nil?
77
78
  end
78
79
 
79
80
  # Subclasses may override to perform post add_content work (normally must call super)
80
81
  def post_add_content
81
82
  @parent&.post_initialize_child(self)
83
+ @parent.post_add_content if implicit_path? && dynamic?
84
+ end
85
+
86
+ def post_initialize_child(child, add_child: true)
87
+ if child.is_a?(ControlProxy::MatrixProxy)
88
+ path_proxy.post_initialize_child(child, add_child: add_child)
89
+ else
90
+ super(child, add_child: add_child)
91
+ end
92
+ end
93
+
94
+ def content(&block)
95
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::ShapeExpression.new, @keyword, &block)
96
+ request_auto_redraw
82
97
  end
83
98
 
84
99
  # Subclasses must override to perform draw work and call super afterwards to ensure calling destroy when semi-declarative in an on_draw method
@@ -105,6 +120,24 @@ module Glimmer
105
120
  def path_proxy
106
121
  find_parent_in_ancestors { |parent| parent.nil? || parent.is_a?(ControlProxy::PathProxy) }
107
122
  end
123
+
124
+ def fill(*args)
125
+ path_proxy.fill(*args)
126
+ end
127
+ alias fill= fill
128
+ alias set_fill fill
129
+
130
+ def stroke(*args)
131
+ path_proxy.stroke(*args)
132
+ end
133
+ alias stroke= stroke
134
+ alias set_stroke stroke
135
+
136
+ def transform(matrix = nil)
137
+ path_proxy.transform(matrix)
138
+ end
139
+ alias transform= transform
140
+ alias set_transform transform
108
141
 
109
142
  def respond_to?(method_name, *args, &block)
110
143
  self.class.parameters.include?(method_name.to_s.sub(/=$/, '').sub(/^set_/, '').to_sym) or
@@ -117,6 +150,7 @@ module Glimmer
117
150
  method_name = method_name.to_s
118
151
  parameter_index = self.class.parameters.index(method_name_parameter)
119
152
  if method_name.start_with?('set_') || method_name.end_with?('=') || !args.empty?
153
+ args = [args] if args.size > 1
120
154
  if args.first != @args[parameter_index]
121
155
  @args[parameter_index] = args.first
122
156
  request_auto_redraw
@@ -124,13 +158,27 @@ module Glimmer
124
158
  else
125
159
  @args[parameter_index]
126
160
  end
127
- else
161
+ else # TODO consider if there is a need to redirect anything to path proxy or delete this TODO
128
162
  super
129
163
  end
130
164
  end
131
165
 
132
166
  private
133
167
 
168
+ def build_control
169
+ block = Proc.new {} if dynamic?
170
+ @parent = Glimmer::LibUI::ControlProxy::PathProxy.new('path', @parent, [], &block)
171
+ end
172
+
173
+ # indicates if nested directly under area or on_draw event (having an implicit path not an explicit path parent)
174
+ def implicit_path?
175
+ @implicit_path ||= !!(@parent.is_a?(Glimmer::LibUI::ControlProxy::AreaProxy) || (@parent.nil? && Glimmer::LibUI::ControlProxy::AreaProxy.current_area_draw_params))
176
+ end
177
+
178
+ def dynamic?
179
+ ((@parent.nil? || (@parent.is_a?(ControlProxy::PathProxy) && @parent.parent_proxy.nil?)) && Glimmer::LibUI::ControlProxy::AreaProxy.current_area_draw_params)
180
+ end
181
+
134
182
  def set_parameter_defaults
135
183
  self.class.parameter_defaults.each_with_index do |default, i|
136
184
  @args[i] ||= default