1 require 'plugins/plugin'
6 plugin :name => 'Layouts/Cool',
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 players = @game.players
42 players = players.reverse unless @flipped
43 players.each do |player|
44 r_pool, r_clock = if flip
46 board_rect.right + margin,
49 pool_height - clock_height - margin),
51 board_rect.right + margin,
52 offy + margin + pool_height - clock_height,
57 board_rect.right + margin,
58 offy + margin * 2 + clock_height,
60 pool_height - clock_height - margin),
62 board_rect.right + margin,
67 unless elements[:pools].empty?
68 elements[:pools][player].flip(flip)
69 elements[:pools][player].set_geometry(r_pool)
71 elements[:clocks][player].set_geometry(r_clock)
72 offy = offy + margin + pool_height