Class: DrawioDsl::Schema::FlexLayout

Inherits:
Layout
  • Object
show all
Defined in:
lib/drawio_dsl/schema/layouts/flex_layout.rb

Overview

Provides flex style layouts

Instance Attribute Summary collapse

Attributes inherited from Layout

#anchor_x, #anchor_y

Attributes inherited from Node

#classification, #id, #key, #nodes, #page, #parent

Instance Method Summary collapse

Methods inherited from Layout

#after_init, #fire_after_init

Methods inherited from Node

#add_node, #debug, #debug_detail, #debug_row, #root?

Constructor Details

#initialize(page, **args) ⇒ FlexLayout

Returns a new instance of FlexLayout.



12
13
14
15
16
17
18
19
# File 'lib/drawio_dsl/schema/layouts/flex_layout.rb', line 12

def initialize(page, **args)
  @direction = args[:direction] || :horizontal
  @wrap_at = args[:wrap_at] || (direction == :horizontal ? 1000 : 800)
  @gap = args[:gap] || 20
  @perpendicular_max = 0

  super(page, **args.merge(key: :flex_layout))
end

Instance Attribute Details

#directionObject

Returns the value of attribute direction.



7
8
9
# File 'lib/drawio_dsl/schema/layouts/flex_layout.rb', line 7

def direction
  @direction
end

#gapObject (readonly)

Returns the value of attribute gap.



9
10
11
# File 'lib/drawio_dsl/schema/layouts/flex_layout.rb', line 9

def gap
  @gap
end

#perpendicular_maxObject (readonly)

Returns the value of attribute perpendicular_max.



10
11
12
# File 'lib/drawio_dsl/schema/layouts/flex_layout.rb', line 10

def perpendicular_max
  @perpendicular_max
end

#wrap_atObject

Returns the value of attribute wrap_at.



8
9
10
# File 'lib/drawio_dsl/schema/layouts/flex_layout.rb', line 8

def wrap_at
  @wrap_at
end

Instance Method Details

#position_shape(shape) ⇒ Object



21
22
23
24
25
26
# File 'lib/drawio_dsl/schema/layouts/flex_layout.rb', line 21

def position_shape(shape)
  fire_after_init

  position_shape_horizontally(shape) if direction == :horizontal
  position_shape_vertically(shape) if direction == :vertical
end

#to_hObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/drawio_dsl/schema/layouts/flex_layout.rb', line 28

def to_h
  fire_after_init

  super.merge(
    direction: direction,
    wrap_at: wrap_at,
    boundary: boundary,
    perpendicular_max: perpendicular_max
  )
end