Sha256: 0b572895f86c0c6a9e1c3e51f5f6cd3e1a3a61550a2f6a1a13f5971a88af9d4d

Contents?: true

Size: 1.67 KB

Versions: 43

Compression:

Stored size: 1.67 KB

Contents

proc_name = "powered-by"

@powered_by_props ||= {
  "size" => screen_size(1.5 * Pango::SCALE),
  "font_family" => @font_family,
}

@powered_by_text_color ||= nil

@powered_by_images ||= []

add_powered_by = proc do |slide|
  space = screen_x(1)
  text = nil
  tw = th = 0

  loaders = @powered_by_images.collect do |image|
    ImageLoader.new(find_file(image))
  end

  slide.delete_post_draw_proc_by_name(proc_name)

  slide.add_post_draw_proc(proc_name) do |canvas, x, y, w, h, simulation|
    if simulation
      if @powered_by_text
        text = Text.new(@powered_by_text)
        set_font_family(text)
        text.font @powered_by_props
        text.compile(canvas, x, y, w, h)
      end

      image_height = canvas.height / 12
      loaders.each do |loader|
        slide_space = canvas.height - y - slide.margin_bottom - space
        request_height = [image_height, slide_space].min
        request_height = image_height if request_height <= 0
        loader.resize(nil, request_height) if loader.height > request_height
      end
    else
      new_x = slide.margin_left
      new_y = canvas.height - slide.margin_bottom

      if text
        layout = text.layout
        tw, th = layout.pixel_size
        canvas.draw_layout(layout, new_x, new_y - th, @powered_by_text_color)
      end

      new_x += tw
      loaders.each do |loader|
        px = new_x + space
        py = new_y - loader.height
        loader.draw(canvas, px, py)
        new_x = px + loader.width
      end
    end
    [x, y, w, h]
  end
end

match(TitleSlide) do |slides|
  add_powered_by.call(slides.first) unless slides.empty?
end

match(Slide) do |slides|
  add_powered_by.call(slides.last) unless slides.empty?
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
rabbit-3.0.3 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-3.0.2 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-3.0.1 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-3.0.0 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.2.1 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.2.0 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.9 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.8 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.7 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.6 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.5 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.4 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.3 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.2 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.1 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.1.0 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.0.9 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.0.8 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.0.7 lib/rabbit/theme/powered-by/powered-by.rb
rabbit-2.0.6 lib/rabbit/theme/powered-by/powered-by.rb