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.
10 class Item < Qt::GraphicsPixmapItem
11 attr_reader :name, :item
14 # name is whatever information the caller needs
15 # to recreate this piece with a different size
17 def initialize(name, pixmap, parent)
23 def paint(p, options, widget)
26 super p, options, widget
36 scene.remove_item self
41 BACKGROUND_ZVALUE = -10
44 def create_item(key, pix, opts = {})
45 name = opts[:name] || key.to_s
46 item = Item.new(name, pix, self)
47 item.pos = opts[:pos] || Qt::PointF.new(0, 0)
48 item.z_value = opts[:z] || 0
49 item.visible = false if opts[:hidden]
53 def destroy_item(item)
54 scene.remove_item item
58 item.z_value = TEMP_ZVALUE