module Rabbit::Renderer::Base

Attributes

adjustment_x[RW]
adjustment_y[RW]
draw_scaled_image[RW]
gl_quaternion[RW]
gl_scale[RW]
graffiti_color[RW]
graffiti_line_width[RW]
margin_bottom[RW]
margin_left[RW]
margin_right[RW]
margin_top[RW]
page_margin_bottom[W]
page_margin_left[W]
page_margin_right[W]
page_margin_top[W]
paper_height[RW]
paper_width[RW]
progress_background[RW]
progress_foreground[RW]
slides_per_page[RW]
x_dpi[R]
y_dpi[R]

Public Class Methods

new(canvas) click to toggle source
Calls superclass method
# File lib/rabbit/renderer/base.rb, line 33
def initialize(canvas)
  super()
  @canvas = canvas
  @font_families = nil
  @paper_width = nil
  @paper_height = nil
  @slides_per_page = nil
  @margin_left = nil
  @margin_right = nil
  @margin_top = nil
  @margin_bottom = nil
  @page_margin_left = nil
  @page_margin_right = nil
  @page_margin_top = nil
  @page_margin_bottom = nil
  @whiteout = false
  @blackout = false
  @list_id = 0
  @adjustment_x = 0
  @adjustment_y = 0
  @progress_foreground = nil
  @progress_background = nil
  @graffiti_color = nil
  @graffiti_line_width = nil
  @draw_scaled_image = true
  clean
  init_dpi
  init_gl_parameters
end

Public Instance Methods

add_gesture_action(sequence, action, &block) click to toggle source
# File lib/rabbit/renderer/base.rb, line 257
def add_gesture_action(sequence, action, &block)
end
blackouting?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 189
def blackouting?
  @blackout
end
can_undo_graffiti?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 228
def can_undo_graffiti?
  false
end
change_graffiti_color() click to toggle source
# File lib/rabbit/renderer/base.rb, line 254
def change_graffiti_color
end
clean() click to toggle source
# File lib/rabbit/renderer/base.rb, line 169
def clean
  dirty_count_clean
end
clean_if_dirty() click to toggle source
# File lib/rabbit/renderer/base.rb, line 173
def clean_if_dirty
  clean if dirty?
end
clear_slide() click to toggle source
# File lib/rabbit/renderer/base.rb, line 106
def clear_slide
  current = @canvas.current_slide
  current.clear_waiting if current
end
clear_theme() click to toggle source
# File lib/rabbit/renderer/base.rb, line 177
def clear_theme
  init_color
  clear_keys
  clear_progress_color
  clear_graffiti_config
  clear_gesture_actions
end
confirm() click to toggle source
# File lib/rabbit/renderer/base.rb, line 152
def confirm
  true
end
connect_key(keyval, modifier, flags, &block) click to toggle source
# File lib/rabbit/renderer/base.rb, line 248
def connect_key(keyval, modifier, flags, &block)
end
create_pango_context() click to toggle source
# File lib/rabbit/renderer/base.rb, line 140
def create_pango_context
  Pango::Context.new
end
disconnect_key(keyval, modifier) click to toggle source
# File lib/rabbit/renderer/base.rb, line 251
def disconnect_key(keyval, modifier)
end
display?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 148
def display?
  false
end
each_slide_pixbuf() { |slide, to_pixbuf, i| ... } click to toggle source
# File lib/rabbit/renderer/base.rb, line 116
def each_slide_pixbuf
  canvas = off_screen_canvas
  previous_index = canvas.current_index
  pre_to_pixbuf(canvas.slide_size)
  canceled = false
  canvas.slides.each_with_index do |slide, i|
    if !to_pixbufing(i) or !yield(slide, canvas.to_pixbuf(i), i)
      canceled = true
      break
    end
  end
  post_to_pixbuf(canceled)
  canvas.move_to_if_can(previous_index)
  canvas.activate("Quit") if canvas != @canvas
end
expand_hole() click to toggle source
# File lib/rabbit/renderer/base.rb, line 232
def expand_hole
end
font_families() click to toggle source
# File lib/rabbit/renderer/base.rb, line 79
def font_families
  if @font_families.nil? or @font_families.empty?
    @font_families = create_pango_context.families
  end
  @font_families
end
gl_available?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 213
def gl_available?
  @canvas.use_gl? and gl_supported?
end
graffiti_mode?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 220
def graffiti_mode?
  false
end
have_graffiti?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 224
def have_graffiti?
  false
end
hiding?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 203
def hiding?
  @blackout or @whiteout
end
narrow_hole() click to toggle source
# File lib/rabbit/renderer/base.rb, line 235
def narrow_hole
end
off_screen_canvas() click to toggle source
# File lib/rabbit/renderer/base.rb, line 132
def off_screen_canvas
  if off_screen_renderer?
    @canvas
  else
    make_canvas_with_off_screen_renderer
  end
end
page_margin_bottom() click to toggle source
# File lib/rabbit/renderer/base.rb, line 75
def page_margin_bottom
  @page_margin_bottom || 0
end
page_margin_left() click to toggle source
# File lib/rabbit/renderer/base.rb, line 63
def page_margin_left
  @page_margin_left || 0
end
page_margin_right() click to toggle source
# File lib/rabbit/renderer/base.rb, line 67
def page_margin_right
  @page_margin_right || 0
end
page_margin_top() click to toggle source
# File lib/rabbit/renderer/base.rb, line 71
def page_margin_top
  @page_margin_top || 0
end
post_init_gui() click to toggle source
# File lib/rabbit/renderer/base.rb, line 217
def post_init_gui
end
print(&block) click to toggle source
printable?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 144
def printable?
  false
end
redraw() click to toggle source
# File lib/rabbit/renderer/base.rb, line 103
def redraw
end
reset_adjustment() click to toggle source
# File lib/rabbit/renderer/base.rb, line 111
def reset_adjustment
  @adjustment_x = 0
  @adjustment_y = 0
end
search_slide(forward=true) click to toggle source
# File lib/rabbit/renderer/base.rb, line 238
def search_slide(forward=true)
end
searching?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 244
def searching?
  false
end
setup_event(area) click to toggle source
# File lib/rabbit/renderer/base.rb, line 156
def setup_event(area)
end
to_attrs(hash) click to toggle source
# File lib/rabbit/renderer/base.rb, line 159
def to_attrs(hash)
  hash.collect do |key, value|
    if value
      "#{h key}='#{h value}'"
    else
      nil
    end
  end.compact.join(" ")
end
toggle_blackout() click to toggle source
# File lib/rabbit/renderer/base.rb, line 198
def toggle_blackout
  @blackout = !@blackout
  @whiteout = false
end
toggle_info_window() click to toggle source
# File lib/rabbit/renderer/base.rb, line 207
def toggle_info_window
end
toggle_spotlight() click to toggle source
# File lib/rabbit/renderer/base.rb, line 210
def toggle_spotlight
end
toggle_whiteout() click to toggle source
# File lib/rabbit/renderer/base.rb, line 193
def toggle_whiteout
  @blackout = false
  @whiteout = !@whiteout
end
whiteouting?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 185
def whiteouting?
  @whiteout
end

Private Instance Methods

clear_gesture_actions() click to toggle source
# File lib/rabbit/renderer/base.rb, line 424
def clear_gesture_actions
  init_gesture_actions
end
clear_graffiti_config() click to toggle source
# File lib/rabbit/renderer/base.rb, line 406
def clear_graffiti_config
  @graffiti_color = nil
  @graffiti_line_width = nil
end
clear_keys() click to toggle source
# File lib/rabbit/renderer/base.rb, line 403
def clear_keys
end
clear_progress_color() click to toggle source
# File lib/rabbit/renderer/base.rb, line 411
def clear_progress_color
  @progress_foreground = nil
  @progress_background = nil
end
do_print(&block) click to toggle source
# File lib/rabbit/renderer/base.rb, line 265
def do_print(&block)
  pre_print(@canvas.slide_size)
  canceled = false
  @canvas.slides.each_with_index do |slide, i|
    @canvas.move_to_if_can(i)
    current_slide = @canvas.current_slide
    current_slide.flush
    current_slide.draw(@canvas)
    if block and !block.call(i)
      canceled = true
      break
    end
  end
  post_print(canceled)
end
init_color() click to toggle source
# File lib/rabbit/renderer/base.rb, line 420
def init_color
  @background_color = "white"
end
init_dpi() click to toggle source
# File lib/rabbit/renderer/base.rb, line 382
def init_dpi
  @x_dpi = 72
  @y_dpi = 72
end
init_gesture_actions() click to toggle source
# File lib/rabbit/renderer/base.rb, line 428
def init_gesture_actions
end
init_gl_parameters() click to toggle source
# File lib/rabbit/renderer/base.rb, line 387
def init_gl_parameters
  angle = 0.0 * (Math::PI / 180.0)
  axis_x = 1.0
  axis_y = 0.0
  axis_z = 0.0
  sine = Math.sin(0.5 * angle)
  quaternion = [
                axis_x * sine,
                axis_y * sine,
                axis_z * sine,
                Math.cos(0.5 * angle)
               ]
  @gl_quaternion = TrackBall::Vector.new(quaternion)
  @gl_scale = 1.0
end
invert_y(y) click to toggle source
# File lib/rabbit/renderer/base.rb, line 416
def invert_y(y)
  height - y
end
make_canvas_with_off_screen_renderer() click to toggle source
# File lib/rabbit/renderer/base.rb, line 304
def make_canvas_with_off_screen_renderer
  make_canvas_with_renderer(Pixmap) do |canvas|
    canvas.width = @canvas.width
    canvas.height = @canvas.height
    setup_3d(canvas)
  end
end
make_canvas_with_printable_renderer() click to toggle source
# File lib/rabbit/renderer/base.rb, line 292
def make_canvas_with_printable_renderer
  renderer = Renderer.printable_renderer(@canvas.slides_per_page)
  make_canvas_with_renderer(renderer) do |canvas|
    canvas.filename = @canvas.filename
    setup_margin(canvas)
    setup_page_margin(canvas)
    setup_paper_size(canvas)
    setup_3d(canvas)
    canvas.slides_per_page = @canvas.slides_per_page
  end
end
make_canvas_with_renderer(renderer) { |canvas| ... } click to toggle source
# File lib/rabbit/renderer/base.rb, line 281
def make_canvas_with_renderer(renderer)
  canvas = Canvas.new(@canvas.logger, renderer)
  yield canvas
  canvas.apply_theme(@canvas.theme_name)
  @canvas.source_force_modified(true) do |source|
    canvas.parse(source)
  end
  canvas.toggle_index_mode if @canvas.index_mode?
  canvas
end
not_support_method(name) click to toggle source
# File lib/rabbit/renderer/base.rb, line 376
def not_support_method(name)
  format = _("%s does not support: %s")
  msg = format % [self.class.name, name]
  @canvas.logger.warn(msg)
end
off_screen_renderer?() click to toggle source
# File lib/rabbit/renderer/base.rb, line 261
def off_screen_renderer?
  false
end
setup_3d(canvas) click to toggle source
# File lib/rabbit/renderer/base.rb, line 336
def setup_3d(canvas)
  canvas.use_gl = @canvas.use_gl?
end
setup_flag_params(pole_height, default_flag_width_ratio, params) click to toggle source
# File lib/rabbit/renderer/base.rb, line 340
def setup_flag_params(pole_height, default_flag_width_ratio, params)
  params = params.dup

  text = params["text"]
  text_attrs = params["text_attributes"] || {}
  if text
    markupped_text = "<span #{to_attrs(text_attrs)}>#{text}</span>"
    layout = make_layout(markupped_text)
    text_width, text_height = layout.pixel_size
    params["layout"] = layout
    params["text_width"] = text_width
    params["text_height"] = text_height
    flag_width_default = [
      text_width * default_flag_width_ratio,
      pole_height / 2
    ].max
    flag_height_default = [text_height, flag_width_default].max
  else
    params["layout"] = nil
    flag_width_default = flag_height_default = nil
  end

  params["pole_width"] = params["pole_width"] || 2
  params["pole_color"] ||= "black"
  flag_height = params["flag_height"] ||
    flag_height_default || pole_height / 2
  flag_height = [flag_height, pole_height].min
  params["flag_height"] = flag_height
  params["flag_width"] ||= flag_width_default || flag_height
  params["flag_color"] ||= "red"
  params["flag_frame_width"] ||= params["pole_width"]
  params["flag_frame_color"] ||= params["pole_color"]

  params
end
setup_margin(canvas) click to toggle source
# File lib/rabbit/renderer/base.rb, line 312
def setup_margin(canvas)
  canvas.margin_left = @canvas.margin_left
  canvas.margin_right = @canvas.margin_right
  canvas.margin_top = @canvas.margin_top
  canvas.margin_bottom = @canvas.margin_bottom
end
setup_page_margin(canvas) click to toggle source
# File lib/rabbit/renderer/base.rb, line 319
def setup_page_margin(canvas)
  canvas.page_margin_left = @canvas.page_margin_left
  canvas.page_margin_right = @canvas.page_margin_right
  canvas.page_margin_top = @canvas.page_margin_top
  canvas.page_margin_bottom = @canvas.page_margin_bottom
end
setup_paper_size(canvas) click to toggle source
# File lib/rabbit/renderer/base.rb, line 326
def setup_paper_size(canvas)
  if @canvas.paper_width and @canvas.paper_height
    canvas.paper_width = @canvas.paper_width
    canvas.paper_height = @canvas.paper_height
  else
    canvas.paper_width = @canvas.width
    canvas.paper_height = @canvas.height
  end
end