Class: Hokusai::Blocks::Panel
Instance Attribute Summary collapse
#node, #provides, #publisher
Instance Method Summary
collapse
#children, #children?, compile, computed, computed!, #draw, #draw_with, #dump, #emit, inject, inject!, #method_missing, mount, #on_resize, provide, provides, style, styles_get, template, template_from_file, template_get, #update, use, uses
Constructor Details
#initialize(**args) ⇒ Panel
Returns a new instance of Panel.
45
46
47
48
49
50
51
52
53
54
55
|
# File 'ui/src/hokusai/blocks/panel.rb', line 45
def initialize(**args)
@top = nil
@panel_height = 0.0
@scroll_y = 0.0
@scroll_percent = 0.0
@scroll_goto_y = nil
@clipped_offset = 0.0
@clipped_content_height = 0.0
super(**args)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hokusai::Block
Instance Attribute Details
#clipped_content_height ⇒ Object
Returns the value of attribute clipped_content_height.
42
43
44
|
# File 'ui/src/hokusai/blocks/panel.rb', line 42
def clipped_content_height
@clipped_content_height
end
|
#clipped_offset ⇒ Object
Returns the value of attribute clipped_offset.
42
43
44
|
# File 'ui/src/hokusai/blocks/panel.rb', line 42
def clipped_offset
@clipped_offset
end
|
#panel_height ⇒ Object
Returns the value of attribute panel_height.
42
43
44
|
# File 'ui/src/hokusai/blocks/panel.rb', line 42
def panel_height
@panel_height
end
|
Returns the value of attribute scroll_goto_y.
42
43
44
|
# File 'ui/src/hokusai/blocks/panel.rb', line 42
def scroll_goto_y
@scroll_goto_y
end
|
Returns the value of attribute scroll_percent.
42
43
44
|
# File 'ui/src/hokusai/blocks/panel.rb', line 42
def scroll_percent
@scroll_percent
end
|
Returns the value of attribute scroll_y.
42
43
44
|
# File 'ui/src/hokusai/blocks/panel.rb', line 42
def scroll_y
@scroll_y
end
|
#top ⇒ Object
Returns the value of attribute top.
42
43
44
|
# File 'ui/src/hokusai/blocks/panel.rb', line 42
def top
@top
end
|
Instance Method Details
#content_height ⇒ Object
88
89
90
|
# File 'ui/src/hokusai/blocks/panel.rb', line 88
def content_height
clipped_content_height
end
|
#offset ⇒ Object
84
85
86
|
# File 'ui/src/hokusai/blocks/panel.rb', line 84
def offset
((panel_content_height * scroll_percent) - (panel_height * scroll_percent))
end
|
#panel_content_height ⇒ Object
92
93
94
|
# File 'ui/src/hokusai/blocks/panel.rb', line 92
def panel_content_height
clipped_content_height < panel_height ? panel_height : clipped_content_height
end
|
#panel_top ⇒ Object
73
74
75
|
# File 'ui/src/hokusai/blocks/panel.rb', line 73
def panel_top
top || 0.0
end
|
#render(canvas) {|canvas| ... } ⇒ Object
120
121
122
123
124
125
|
# File 'ui/src/hokusai/blocks/panel.rb', line 120
def render(canvas)
self.top = canvas.y
self.panel_height = canvas.height
yield canvas
end
|
96
97
98
|
# File 'ui/src/hokusai/blocks/panel.rb', line 96
def scroll_active
clipped_content_height > panel_height
end
|
100
101
102
103
104
105
106
107
108
|
# File 'ui/src/hokusai/blocks/panel.rb', line 100
def scroll_complete(y, percent:)
self.scroll_y = y
self.scroll_percent = percent
self.scroll_goto_y = nil
emit("scroll", y, percent: percent)
end
|
114
115
116
117
118
|
# File 'ui/src/hokusai/blocks/panel.rb', line 114
def scroll_control_height
return 20.0 if panel_height <= 0.0
(panel_height / panel_content_height) * panel_height
end
|
110
111
112
|
# File 'ui/src/hokusai/blocks/panel.rb', line 110
def scrollbar_goto
scroll_goto_y || scroll_goto
end
|
#set_size(_, height) ⇒ Object
77
78
79
80
81
82
|
# File 'ui/src/hokusai/blocks/panel.rb', line 77
def set_size(_, height)
if panel_height != clipped_content_height || clipped_content_height.zero?
self.clipped_content_height = height
end
end
|
#wheel_handle(event) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'ui/src/hokusai/blocks/panel.rb', line 57
def wheel_handle(event)
return if clipped_content_height <= panel_height
new_scroll_y = scroll_y + event.scroll * 20
if y = top
if new_scroll_y < y
self.scroll_goto_y = y
elsif new_scroll_y > panel_height
self.scroll_goto_y = panel_height
else
self.scroll_goto_y = new_scroll_y
end
end
end
|