1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
9 require 'plugins/plugin'
10 require 'board/item_bag'
11 require 'observer_utils'
12 require_bundle 'clocks', 'clock_display'
14 class XBoardClock < Qt::GraphicsItemGroup
21 plugin :name => 'XBoard Clock Skin',
24 attr_reader :items, :rect, :clock, :translate
28 def initialize(scene, translate)
29 super(nil, @scene = scene)
30 @translate = translate
31 @items = create_display_items
39 :z => BACKGROUND_ZVALUE
40 text_color = Qt::Color.new(@active ? Qt::white : Qt::black)
41 @items[:time].constraint = Qt::RectF.new(
42 @rect.width * 0.4, @rect.height * 0.05,
43 @rect.width * 0.7, @rect.height * 0.8)
44 @items[:caption].constraint = Qt::RectF.new(
45 0, @rect.height * 0.1,
46 @rect.width * 0.5, @rect.height * 0.7)
47 @items[:player].constraint = Qt::RectF.new(
48 0, @rect.height * 0.68,
49 @rect.width, @rect.height * 0.28)
51 @items.each do |name, item|
52 if item.respond_to? 'color='
53 item.color = text_color
60 color = Qt::Color.new(@active ? Qt::black : Qt::white)
61 Qt::Image.painted(@rect.size) do |p|
62 p.fill_rect(Qt::RectF.new(Qt::PointF.new(0, 0), @rect.size),
64 p.alter(:pen) {|pen| pen.style = Qt::SolidLine }
65 p.draw_line(0, 0, @rect.width, 0)
66 p.draw_line(0, 0, 0, @rect.height)
67 p.draw_line(@rect.width - 1, 0, @rect.width - 1, @rect.height)
68 p.draw_line(0, @rect.height - 1, @rect.width, @rect.height - 1)