lib/rabbit/renderer/display/drawing-area-base.rb in rabbit-2.1.6 vs lib/rabbit/renderer/display/drawing-area-base.rb in rabbit-2.1.7
- old
+ new
@@ -1,7 +1,7 @@
require "rabbit/renderer/display/drawing-area-primitive"
-require 'rabbit/renderer/display/menu'
+require "rabbit/renderer/display/menu"
require "rabbit/renderer/display/progress"
require "rabbit/renderer/display/mask"
require "rabbit/renderer/display/search"
require "rabbit/renderer/display/gesture"
require "rabbit/renderer/display/graffiti"
@@ -237,14 +237,14 @@
def post_init_gui
end
private
def add_widgets_to_container(container)
- @hbox = Gtk::HBox.new
- @vbox = Gtk::VBox.new
- @vbox.pack_start(@area, true, true, 0)
- @hbox.pack_end(@vbox, true, true, 0)
+ @hbox = Gtk::Box.new(:horizontal)
+ @vbox = Gtk::Box.new(:vertical)
+ @vbox.pack_start(@area, :expand => true, :fill => true, :padding => 0)
+ @hbox.pack_end(@vbox, :expand => true, :fill => true, :padding => 0)
if block_given?
yield(container, @hbox)
else
container.add(@hbox)
end
@@ -257,51 +257,46 @@
@hbox = @vbox = nil
end
def init_drawing_area
super
- event_mask = Gdk::Event::BUTTON_PRESS_MASK
- event_mask |= Gdk::Event::BUTTON_RELEASE_MASK
- event_mask |= Gdk::Event::BUTTON1_MOTION_MASK
- event_mask |= Gdk::Event::BUTTON2_MOTION_MASK
- event_mask |= Gdk::Event::BUTTON3_MOTION_MASK
+ event_mask = Gdk::EventMask::BUTTON_PRESS_MASK
+ event_mask |= Gdk::EventMask::BUTTON_RELEASE_MASK
+ event_mask |= Gdk::EventMask::BUTTON1_MOTION_MASK
+ event_mask |= Gdk::EventMask::BUTTON2_MOTION_MASK
+ event_mask |= Gdk::EventMask::BUTTON3_MOTION_MASK
@area.add_events(event_mask)
set_key_press_event(@area)
set_button_event(@area)
set_motion_notify_event
set_scroll_event(@area)
end
- def mapped(widget)
- super
- @white = Gdk::GC.new(@drawable)
- @white.set_rgb_fg_color(Color.parse("white").to_gdk_color)
- @black = Gdk::GC.new(@drawable)
- @black.set_rgb_fg_color(Color.parse("black").to_gdk_color)
- end
-
def set_motion_notify_event
@area.signal_connect("motion_notify_event") do |widget, event|
call_hook_procs(@motion_notify_hook_procs, event)
end
end
- def exposed(widget, event)
+ def paint(color_name)
+ context = @drawable.create_cairo_context
+ context.set_source_rgb(*Color.parse(color_name).to_gdk_rgb)
+ context.paint
+ end
+
+ def draw(widget, context)
reload_source unless @caching
if whiteouting?
- @drawable.draw_rectangle(@white, true, 0, 0,
- @size.real_width, @size.real_height)
+ paint("white")
elsif blackouting?
- @drawable.draw_rectangle(@black, true, 0, 0,
- @size.real_width, @size.real_height)
+ paint("black")
else
super
draw_graffiti
draw_gesture
draw_spotlight
end
- true
end
def draw_slide(slide, simulation, &block)
super do |*args|
block.call(*args)