class Rabbit::Element::IndexThumbnail

Attributes

number[R]
number_of_slides[R]
pixbuf[R]
title[R]

Public Class Methods

new(pixbuf, title, number, number_of_slides) click to toggle source
Calls superclass method Rabbit::Element::Base::new
# File lib/rabbit/element/index-slide.rb, line 130
def initialize(pixbuf, title, number, number_of_slides)
  @pixbuf = pixbuf
  @title = title
  @number = number
  @number_of_slides = number_of_slides
  @layout = nil
  super()
end

Public Instance Methods

clear_theme() click to toggle source
Calls superclass method Rabbit::Element::Base#clear_theme
# File lib/rabbit/element/index-slide.rb, line 139
def clear_theme
  super
  @width = @pixbuf.width
  @height = @pixbuf.height
end
draw_element(canvas, x, y, w, h, simulation) click to toggle source
# File lib/rabbit/element/index-slide.rb, line 145
def draw_element(canvas, x, y, w, h, simulation)
  width = @pixbuf.width
  height = @pixbuf.height
  side_margin = parent.margin_left + parent.margin_right
  unless simulation
    if @layout.nil?
      margin_bottom = parent.margin_bottom
      text_size = (margin_bottom * Pango::SCALE).ceil
      text = "#{@number}/#{@number_of_slides}"
      text = %Q[<span size="#{text_size}">#{text}</span>]
      @layout, _, _ = canvas.make_layout(text)
      @layout.set_width(width * Pango::SCALE)
      @layout.set_alignment(Pango::Alignment::CENTER)
    end
    canvas.draw_pixbuf(@pixbuf, x, y)
    canvas.draw_rectangle(false, x, y, width, height)
    canvas.draw_layout(@layout, x, y + height)
  end
  [x + width + side_margin, y, w - width - side_margin, h]
end
text() click to toggle source
# File lib/rabbit/element/index-slide.rb, line 166
def text
  @title
end
to_html(generator) click to toggle source
# File lib/rabbit/element/index-slide.rb, line 174
def to_html(generator)
  number_of_places = generator.number_of_places(@number_of_slides)
  format = "thumbnail%0#{number_of_places}d"
  src = generator.save_pixbuf(@pixbuf, format % @number)
  title = generator.slide_image_title(@number)
  img = "<img title=\"#{title}\" src=\"#{src}\" />"

  if generator.output_slide_html?
    href = generator.slide_href(@number)
    "<a href=\"#{href}\">\n#{img}\n</a>"
  else
    img
  end
end
to_rd() click to toggle source
# File lib/rabbit/element/index-slide.rb, line 170
def to_rd
  "* #{text}"
end