Class: Moon::RenderContainer

Inherits:
RenderContext show all
Defined in:
lib/moon/packages/render_primitives/render_container.rb,
lib/moon/packages/debug/render_container.rb

Overview

Inspired by dev.chromium.org/developers/design-documents/aura

RenderContainers are as there name says, Render Containers, they can contain other RenderContainers or RenderContext objects, they serve the purpose of constructing Render Trees

Direct Known Subclasses

DebugShell, DebugShell::Caret, RenderArray

Instance Attribute Summary

Attributes inherited from RenderContext

#id

Attributes included from Moon::RenderPrimitive::DataAttributes

#data_attrs

Attributes included from Moon::RenderPrimitive::Rectangular

#position

Attributes included from Moon::RenderPrimitive::Containable

#parent

Instance Method Summary collapse

Methods inherited from RenderContext

#apply_position_modifier, #initialize, #post_initialize, #pre_initialize, #render?, #render_abs, #render_content, #screen_bounds, #screen_position, #update

Methods included from Moon::RenderPrimitive::DataAttributes

#initialize_data_attrs

Methods included from Moon::RenderPrimitive::Rectangular

#align!, #bounds, #contains?, #cx, #cx=, #cy, #cy=, #move, #resize, #to_rect, #x, #x2, #x2=, #x=, #y, #y2, #y2=, #y=, #z, #z=

Methods included from Moon::RenderPrimitive::Containable

#containerize, #disown

Methods included from Moon::RenderPrimitive::Visibility

#hide, #invisible?, #show, #visible?

Methods included from Moon::RenderPrimitive::Renderable

#render, #render?

Methods included from Moon::RenderPrimitive::ScreenElement

#contains_pos?, #relative_contains_pos?, #relative_to_screen, #screen_to_relative

Methods included from Eventable

#allow_event?, #clear_events, #each_listener, #each_typed_listener, filter_from_options, #has_events?, #initialize_eventable, #off, #on, #ppd_ev, #trigger, #typing

Methods included from Transitionable

#key_transition, #remove_transitions, #transition

Methods included from TransitionHost

#add_transition, #finish_transitions, #remove_transition, #remove_transitions, #update_transitions

Constructor Details

This class inherits a constructor from Moon::RenderContext

Instance Method Details

#add(element) ⇒ Object

Parameters:


202
203
204
205
206
207
208
209
# File 'lib/moon/packages/render_primitives/render_container.rb', line 202

def add(element)
  @elements.push(element)
  element.parent = self

  refresh_size

  element
end

#clear_elementsObject


224
225
226
227
# File 'lib/moon/packages/render_primitives/render_container.rb', line 224

def clear_elements
  @elements.clear
  refresh_size
end

#each { ... } ⇒ Object

Yields:


196
197
198
# File 'lib/moon/packages/render_primitives/render_container.rb', line 196

def each(&block)
  @elements.each(&block)
end

#hInteger

Returns:


174
175
176
# File 'lib/moon/packages/render_primitives/render_container.rb', line 174

def h
  @h ||= compute_h
end

#h=(h) ⇒ Object

Sets the containers h. This will trigger a ResizeEvent.

Parameters:


182
183
184
185
# File 'lib/moon/packages/render_primitives/render_container.rb', line 182

def h=(h)
  @h = h
  on_resize :h
end

#on_resize(*attrs) ⇒ Object


127
128
129
# File 'lib/moon/packages/render_primitives/render_container.rb', line 127

def on_resize(*attrs)
  trigger ResizeEvent.new(self)
end

#ppd_rc(depth = 0) ⇒ Object


23
24
25
26
# File 'lib/moon/packages/debug/render_container.rb', line 23

def ppd_rc(depth=0)
  Debug::RenderContainer.pretty_print(self, depth)
  self
end

#remove(element) ⇒ Object

Parameters:


213
214
215
216
217
218
219
220
# File 'lib/moon/packages/render_primitives/render_container.rb', line 213

def remove(element)
  @elements.delete(element)
  element.parent = nil

  refresh_size

  element
end

#wInteger

Returns:


147
148
149
# File 'lib/moon/packages/render_primitives/render_container.rb', line 147

def w
  @w ||= compute_w
end

#w=(w) ⇒ Object

Sets the containers w. This will trigger a ResizeEvent.

Parameters:


155
156
157
158
# File 'lib/moon/packages/render_primitives/render_container.rb', line 155

def w=(w)
  @w = w
  on_resize :w
end