lib/rabbit/renderer/display/base.rb in rabbit-2.1.5 vs lib/rabbit/renderer/display/base.rb in rabbit-2.1.6
- old
+ new
@@ -9,24 +9,27 @@
include HookHandler
def initialize(*args, &block)
@drawable = nil
@size = nil
+ @size_dirty = true
@default_size_ratio = nil
@size_ratio = nil
super
end
def width
+ refresh_size
if @size
@size.logical_width
else
nil
end
end
def height
+ refresh_size
if @size
@size.logical_height
else
nil
end
@@ -154,19 +157,27 @@
h = @size.real_height
@size_ratio = ratio
@size = Size.new(w, h, @size_ratio)
end
+ def refresh_size
+ return unless @size_dirty
+
+ w, h = @drawable.size
+ @size = Size.new(w, h, @size.ratio)
+ @size_dirty = false
+ end
+
def set_configure_event
id = @window.signal_connect("configure_event") do |widget, event|
configured(event.x, event.y, event.width, event.height)
false
end
@configure_signal_id = id
end
def configured(x, y, w, h)
- set_size(*@drawable.size)
+ @size_dirty = true
end
def queue_draw
widget.queue_draw
end