1 require 'plugins/plugin'
6 plugin :name => 'Layouts/Cool',
7 :keywords => %w(layout)
9 # values relative to unit = 1
12 CLOCK_HEIGHT_RATIO = 0.4
20 def layout(rect, elements)
21 xrel = @size.x + MARGIN * 3 + CLOCK_WIDTH
22 yrel = @size.y + MARGIN * 2
23 unit = [rect.width / xrel, rect.height / yrel].min.floor
24 margin = MARGIN * unit
25 clock_width = CLOCK_WIDTH * unit
26 clock_height = clock_width * CLOCK_HEIGHT_RATIO
28 base = Qt::Point.new((rect.width - xrel * unit) / 2,
29 (rect.height - yrel * unit) / 2)
31 board_rect = Qt::Rect.new(
32 base.x + margin, base.y + margin,
33 @size.x * unit, @size.y * unit)
34 elements[:board].flip(@flipped)
35 elements[:board].set_geometry(board_rect)
37 pool_height = (board_rect.height - margin * (@game.players.size - 1)) /
41 @game.players.reverse.each do |player|
42 r_pool, r_clock = if flip
44 board_rect.right + margin,
47 pool_height - clock_height - margin),
49 board_rect.right + margin,
50 offy + margin + pool_height - clock_height,
55 board_rect.right + margin,
56 offy + margin * 2 + clock_height,
58 pool_height - clock_height - margin),
60 board_rect.right + margin,
65 unless elements[:pools].empty?
66 elements[:pools][player].flip(flip)
67 elements[:pools][player].set_geometry(r_pool)
69 elements[:clocks][player].set_geometry(r_clock)
70 offy = offy + margin + pool_height