class CanvasItem
Attributes
pixbuf[R]
x[RW]
y[RW]
Public Class Methods
new(widget, button, x, y)
click to toggle source
# File gtk3/sample/gtk-demo/toolpalette.rb, line 432 def initialize(widget, button, x, y) icon_name = button.icon_name icon_theme = Gtk::IconTheme.get_for_screen(widget.screen) width, _height = Gtk::IconSize.lookup(:dialog) @pixbuf = icon_theme.load_icon(icon_name, width, Gtk::IconLookupFlags::GENERIC_FALLBACK) return nil unless @pixbuf @x = x @y = y end
Public Instance Methods
draw(cr, preview)
click to toggle source
# File gtk3/sample/gtk-demo/toolpalette.rb, line 444 def draw(cr, preview) cx = @pixbuf.width cy = @pixbuf.height cr.set_source_pixbuf(@pixbuf, @x - cx * 0.5, @y - cy * 0.5) if preview cr.paint(0.6) else cr.paint end end