Class: Dedalus::PatternLibrary::ApplicationScreen

Inherits:
Screen
  • Object
show all
Defined in:
lib/dedalus/pattern_library/screens/app_screen.rb

Instance Attribute Summary

Attributes inherited from Element

#background_color, #color, #height, #height_percent, #margin, #offset, #padding, #position, #shown, #width, #width_percent, #z_order

Instance Method Summary collapse

Methods inherited from Element

#big_font, #code_font, #draw_bounding_box, #font, #huge_font, #record?, #tiny_font, #view, #window

Constructor Details

#initialize(template) ⇒ ApplicationScreen

Returns a new instance of ApplicationScreen.



4
5
6
# File 'lib/dedalus/pattern_library/screens/app_screen.rb', line 4

def initialize(template)
  @template = template
end

Instance Method Details

#background_imageObject



20
21
22
# File 'lib/dedalus/pattern_library/screens/app_screen.rb', line 20

def background_image
  @bg_image ||= Elements::Image.new(path: "media/images/cosmos.jpg", z_order: -1)
end

#cursorObject



24
25
26
# File 'lib/dedalus/pattern_library/screens/app_screen.rb', line 24

def cursor
  @cursor ||= Elements::Icon.for :arrow_cursor
end

#hydrate(mouse_position:, library_section_tabs:, current_entry_name:, library_sections:, library_items:) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dedalus/pattern_library/screens/app_screen.rb', line 28

def hydrate(mouse_position:, library_section_tabs:, current_entry_name:, library_sections:, library_items:)
  @template.library_name = "Dedalus Pattern Library"
  @template.library_section_tabs = library_section_tabs
  @template.library_sections = library_sections
  @template.library_items = library_items
  @template.current_entry_name = current_entry_name

  cursor.position = mouse_position

  self
end

#layersObject



12
13
14
15
16
17
18
# File 'lib/dedalus/pattern_library/screens/app_screen.rb', line 12

def layers
  layer_stack = Dedalus::LayerStack.new
  layer_stack.push(Dedalus::Layer.new(background_image))
  layer_stack.push(Dedalus::Layer.new(@template))
  layer_stack.push(Dedalus::Layer.new(cursor, freeform: true))
  layer_stack
end

#showObject



8
9
10
# File 'lib/dedalus/pattern_library/screens/app_screen.rb', line 8

def show
  layers
end