Class: DrawioDsl::Schema::GridLayout
- Defined in:
- lib/drawio_dsl/schema/layouts/grid_layout.rb
Overview
Provides grid style layouts
Instance Attribute Summary collapse
-
#cell_no ⇒ Object
Returns the value of attribute cell_no.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#grid_h ⇒ Object
Returns the value of attribute grid_h.
-
#grid_size ⇒ Object
this is an alternative to grid_w/grid_h.
-
#grid_w ⇒ Object
Returns the value of attribute grid_w.
-
#h_align ⇒ Object
Returns the value of attribute h_align.
-
#v_align ⇒ Object
Returns the value of attribute v_align.
-
#wrap_at ⇒ Object
Returns the value of attribute wrap_at.
Attributes inherited from Layout
Attributes inherited from Node
#classification, #id, #key, #nodes, #page, #parent
Instance Method Summary collapse
-
#initialize(page, **args) ⇒ GridLayout
constructor
rubocop:disable Metrics/CyclomaticComplexity.
-
#position_shape(shape) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity.
- #to_h ⇒ Object
Methods inherited from Layout
Methods inherited from Node
#add_node, #debug, #debug_detail, #debug_row, #root?
Constructor Details
#initialize(page, **args) ⇒ GridLayout
rubocop:disable Metrics/CyclomaticComplexity
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 17 def initialize(page, **args) @direction = args[:direction] || :horizontal @wrap_at = args[:wrap_at] || 5 @grid_size = args[:grid_size] || 220 @grid_w = args[:grid_w] || grid_size @grid_h = args[:grid_h] || grid_size @h_align = args[:h_align] || :center @v_align = args[:v_align] || :center @cell_no = 1 super(page, **args.merge(key: :grid_layout)) end |
Instance Attribute Details
#cell_no ⇒ Object
Returns the value of attribute cell_no.
12 13 14 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 12 def cell_no @cell_no end |
#direction ⇒ Object
Returns the value of attribute direction.
7 8 9 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 7 def direction @direction end |
#grid_h ⇒ Object
Returns the value of attribute grid_h.
11 12 13 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 11 def grid_h @grid_h end |
#grid_size ⇒ Object
this is an alternative to grid_w/grid_h
9 10 11 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 9 def grid_size @grid_size end |
#grid_w ⇒ Object
Returns the value of attribute grid_w.
10 11 12 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 10 def grid_w @grid_w end |
#h_align ⇒ Object
Returns the value of attribute h_align.
13 14 15 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 13 def h_align @h_align end |
#v_align ⇒ Object
Returns the value of attribute v_align.
14 15 16 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 14 def v_align @v_align end |
#wrap_at ⇒ Object
Returns the value of attribute wrap_at.
8 9 10 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 8 def wrap_at @wrap_at end |
Instance Method Details
#position_shape(shape) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 31 def position_shape(shape) fire_after_init shape.x = horizontal_shape_alignment(shape) shape.y = vertical_shape_alignment(shape) # puts '------------------' # puts "cell: #{cell_no}" # puts "wrap_at: #{wrap_at}" # puts "shape-x: #{shape.x}" # puts "shape-y: #{shape.y}" # puts "page-x: #{page.position_x}" # puts "page-y: #{page.position_y}" # puts "anchor-x: #{anchor_x}" # puts "anchor-y: #{anchor_y}" move_cell_horizontally if direction == :horizontal move_cell_vertically if direction == :vertical end |
#to_h ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/drawio_dsl/schema/layouts/grid_layout.rb', line 51 def to_h super.merge( direction: direction, wrap_at: wrap_at, grid_w: grid_w, grid_h: grid_h, cell_no: cell_no ) end |