Class: Plushie::Widget::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/plushie/widget/window.rb

Overview

Typed builder for the window widget (Layer 2 API).

Construct a Window, set properties via fluent +set_*+ methods, then call #build to produce a Node for the view tree.

Constant Summary collapse

PROPS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Supported property keys for this widget.

i[title size width height position min_size max_size
maximized fullscreen visible resizable closeable minimizable
decorations transparent blur level exit_on_close_request].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, **opts) ⇒ Window

Returns a new instance of Window.



20
21
22
23
24
# File 'lib/plushie/widget/window.rb', line 20

def initialize(id, **opts)
  @id = id.to_s
  @children = opts.delete(:children) || []
  PROPS.each { |k| instance_variable_set(:"@#{k}", opts[k]) if opts.key?(k) }
end

Instance Attribute Details

#blurObject (readonly)

Returns the value of attribute blur.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def blur
  @blur
end

#childrenObject (readonly)

Returns the value of attribute children.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def children
  @children
end

#closeableObject (readonly)

Returns the value of attribute closeable.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def closeable
  @closeable
end

#decorationsObject (readonly)

Returns the value of attribute decorations.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def decorations
  @decorations
end

#exit_on_close_requestObject (readonly)

Returns the value of attribute exit_on_close_request.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def exit_on_close_request
  @exit_on_close_request
end

#fullscreenObject (readonly)

Returns the value of attribute fullscreen.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def fullscreen
  @fullscreen
end

#heightObject (readonly)

Returns the value of attribute height.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def height
  @height
end

#idObject (readonly)

Returns the value of attribute id.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def id
  @id
end

#levelObject (readonly)

Returns the value of attribute level.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def level
  @level
end

#max_sizeObject (readonly)

Returns the value of attribute max_size.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def max_size
  @max_size
end

#maximizedObject (readonly)

Returns the value of attribute maximized.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def maximized
  @maximized
end

#min_sizeObject (readonly)

Returns the value of attribute min_size.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def min_size
  @min_size
end

#minimizableObject (readonly)

Returns the value of attribute minimizable.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def minimizable
  @minimizable
end

#positionObject (readonly)

Returns the value of attribute position.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def position
  @position
end

#resizableObject (readonly)

Returns the value of attribute resizable.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def resizable
  @resizable
end

#sizeObject (readonly)

Returns the value of attribute size.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def size
  @size
end

#titleObject (readonly)

Returns the value of attribute title.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def title
  @title
end

#transparentObject (readonly)

Returns the value of attribute transparent.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def transparent
  @transparent
end

#visibleObject (readonly)

Returns the value of attribute visible.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def visible
  @visible
end

#widthObject (readonly)

Returns the value of attribute width.



1
2
3
# File 'lib/plushie/widget/window.rb', line 1

def width
  @width
end

Instance Method Details

#buildPlushie::Node

Build a Node from the current property values.

Returns:



43
44
45
46
47
48
49
50
51
# File 'lib/plushie/widget/window.rb', line 43

def build
  props = {}
  PROPS.each do |key|
    val = instance_variable_get(:"@#{key}")
    Build.put_if(props, key, val)
  end
  Node.new(id: @id, type: "window", props: props,
    children: Build.children_to_nodes(@children))
end

#push(child) ⇒ self

Return a copy with the given child appended.

Parameters:

  • child (Object)

    a widget builder or Node to append

Returns:

  • (self)


36
37
38
# File 'lib/plushie/widget/window.rb', line 36

def push(child)
  dup.tap { _1.instance_variable_set(:@children, @children + [child]) }
end