Class: MittensUi::Grid

Inherits:
Object
  • Object
show all
Defined in:
lib/mittens_ui/grid.rb

Instance Method Summary collapse

Constructor Details

#initialize(window) {|_self| ... } ⇒ Grid

Returns a new instance of Grid.

Yields:

  • (_self)

Yield Parameters:



3
4
5
6
7
# File 'lib/mittens_ui/grid.rb', line 3

def initialize(window, &block)
  @grid = Gtk::Grid.new
  yield(self)
  window.add_child(@grid)
end

Instance Method Details

#attach(widget, options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mittens_ui/grid.rb', line 9

def attach(widget, options)
  grid_height   = options[:height]
  grid_width    = options[:width]
  grid_top      = options[:top]
  grid_left     = options[:left]

  # Place widget next to each other in the direction determined by the “orientation” property
  # defaults to :horizontal.
  if options.size >= 1
    @grid.add(widget)
  end

  unless options[:attach_to].nil?
    return
    @grid.attach_next_to()
  else
    @grid.attach(widget, grid_left, grid_top, grid_width, grid_height)
  end
end