lib/dedalus/elements.rb in dedalus-0.2.17 vs lib/dedalus/elements.rb in dedalus-0.2.18
- old
+ new
@@ -5,19 +5,10 @@
def self.active_view
@active_view ||= nil
end
- class FontRepository
- def self.get_font(font_name='Helvetica',size: 20)
- @fonts ||= {}
- @fonts[font_name] ||= {}
- @fonts[font_name][size] ||= Gosu::Font.new(size, name: font_name)
- @fonts[font_name][size]
- end
- end
-
class Element
attr_accessor :position, :offset
# in % as 0.0-1.0 (hint to compositing engine for elements in columns/rows respectively)
attr_accessor :width_percent, :height_percent
@@ -26,14 +17,21 @@
attr_accessor :width, :height
attr_accessor :padding, :margin
attr_accessor :color, :background_color
+ attr_accessor :z_order #index
+
def initialize(attrs={})
attrs.each { |(k,v)| instance_variable_set(:"@#{k}",v) } unless attrs.nil?
end
+ attr_accessor :shown
+ def shown
+ @shown ||= show
+ end
+
def record?
false
end
def draw_bounding_box(origin:, dimensions:, color: Palette.gray)
@@ -44,11 +42,11 @@
c = color.to_gosu
window.draw_quad(x, y, c,
x, y+h, c,
x+w, y, c,
- x+w, y+h, c,ZOrder::Background)
+ x+w, y+h, c, ZOrder::Background)
end
def view
Dedalus.active_view
end
@@ -101,10 +99,12 @@
# layer is an abstract element...
# maybe should also pull out rows and columns?
# could cleanup traversal impl, and will be clearer ultimately
class Layer < Element
+ attr_accessor :elements
+
def initialize(elements, freeform: false)
@elements = elements
@freeform = freeform
end
@@ -116,10 +116,10 @@
@freeform == true
end
end
class LayerStack < Element
- attr_reader :layers
+ attr_accessor :layers
def initialize(layers: [])
@layers = []
end