Class: Glimmer::SWT::RowLayoutProxy

Inherits:
LayoutProxy show all
Includes:
Glimmer
Defined in:
lib/glimmer/swt/row_layout_proxy.rb

Constant Summary collapse

STYLE =
<<~CSS
  .row-layout {
    display: flex;
    align-items: flex-start;
  }
          
  .row-layout-pack-false {
    align-items: stretch;
  }
          
  .row-layout-horizontal {
    flex-direction: row;
  }
  
  .row-layout-horizontal.row-layout-pack-false {
    flex-direction: unset;
  }
  
  .row-layout-vertical {
    flex-direction: column;
  }
  
  .row-layout-vertical.row-layout-pack {
    flex-direction: none;
  }
CSS

Instance Attribute Summary collapse

Attributes inherited from LayoutProxy

#args, #parent

Instance Method Summary collapse

Methods inherited from LayoutProxy

#css_class, for, layout_class, layout_exists?, #reapply

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

#initialize(parent, args) ⇒ RowLayoutProxy

Returns a new instance of RowLayoutProxy.



37
38
39
40
41
42
43
44
45
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 37

def initialize(parent, args)
  super(parent, args)
  @type = @args.first || :horizontal
  @marign_width = 15
  @margin_height = 15
  self.pack = true
  @parent.dom_element.add_class('row-layout')
  @parent.dom_element.add_class(horizontal? ? 'row-layout-horizontal' : 'row-layout-vertical')
end

Instance Attribute Details

#margin_bottomObject

Returns the value of attribute margin_bottom.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def margin_bottom
  @margin_bottom
end

#margin_heightObject

Returns the value of attribute margin_height.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def margin_height
  @margin_height
end

#margin_leftObject

Returns the value of attribute margin_left.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def margin_left
  @margin_left
end

#margin_rightObject

Returns the value of attribute margin_right.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def margin_right
  @margin_right
end

#margin_topObject

Returns the value of attribute margin_top.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def margin_top
  @margin_top
end

#margin_widthObject

Returns the value of attribute margin_width.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def margin_width
  @margin_width
end

#packObject

Returns the value of attribute pack.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def pack
  @pack
end

#spacingObject

Returns the value of attribute spacing.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def spacing
  @spacing
end

#typeObject (readonly)

Returns the value of attribute type.



35
36
37
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 35

def type
  @type
end

Instance Method Details

#dom(widget_dom) ⇒ Object



55
56
57
58
59
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 55

def dom(widget_dom)
  dom_result = widget_dom
  dom_result += '<br />' if vertical? && @pack
  dom_result
end

#horizontal?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 47

def horizontal?
  @type == :horizontal
end

#vertical?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/glimmer/swt/row_layout_proxy.rb', line 51

def vertical?
  @type == :vertical
end