Class: Rabbit::Element::IndexThumbnail
- Inherits:
-
Object
- Object
- Rabbit::Element::IndexThumbnail
- Includes:
- Base
- Defined in:
- lib/rabbit/element/index-slide.rb
Constant Summary
Constants included from GetText
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#number_of_slides ⇒ Object
readonly
Returns the value of attribute number_of_slides.
-
#pixbuf ⇒ Object
readonly
Returns the value of attribute pixbuf.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Attributes included from Base
#base_h, #base_w, #base_x, #base_y, #default_margin_bottom, #default_margin_left, #default_margin_right, #default_margin_top, #default_padding_bottom, #default_padding_left, #default_padding_right, #default_padding_top, #default_visible, #h, #horizontal_centering, #margin_bottom, #margin_left, #margin_right, #margin_top, #padding_bottom, #padding_left, #padding_right, #padding_top, #parent, #ph, #pw, #px, #py, #real_simulation, #user_property, #vertical_centering, #w, #x, #y
Instance Method Summary collapse
- #clear_theme ⇒ Object
- #draw_element(canvas, x, y, w, h, simulation) ⇒ Object
-
#initialize(pixbuf, title, number, number_of_slides) ⇒ IndexThumbnail
constructor
A new instance of IndexThumbnail.
- #text ⇒ Object
- #to_html(generator) ⇒ Object
- #to_rd ⇒ Object
Methods included from Base
#[], #[]=, #add_default_prop, #adjust_x_centering, #adjust_y_margin, #adjust_y_padding, #available_w, #centering_adjusted_height, #centering_adjusted_width, #clear_margin, #clear_padding, #clone, #compile, #compile_element, #compile_for_horizontal_centering, #compile_horizontal, #default_prop, #dirty!, #dirty?, #do_horizontal_centering, #do_horizontal_centering?, #do_vertical_centering?, #draw, #font, #have_tag?, #have_wait_tag?, #height, #hide, #if_dirty, #init_default_margin, #init_default_padding, #init_default_visible, #inline_element?, #inspect, #margin_set, #margin_with, #match?, #next_element, #padding_set, #padding_with, #previous_element, #prop_delete, #prop_get, #prop_set, #prop_value, #reset_horizontal_centering, #restore_x_margin, #restore_x_padding, #setup_margin, #setup_padding, #show, #slide, #substitute_newline, #substitute_text, #text_renderer?, #visible?, #wait, #width
Methods included from Base::DrawHook
#clear_draw_procs, def_draw_hook, def_draw_hooks
Methods included from Utils
arg_list, collect_classes_under_module, collect_modules_under_module, collect_under_module, combination, compute_bottom_y, compute_left_x, compute_right_x, compute_top_y, corresponding_class_under_module, corresponding_module_under_module, corresponding_objects, ensure_time, events_pending_available?, extract_four_way, find_path_in_load_path, init_by_constants_as_default_value, move_to, move_to_bottom_left, move_to_bottom_right, move_to_top_left, move_to_top_right, parse_four_way, process_pending_events, process_pending_events_proc, quartz?, require_files_under_directory_in_load_path, require_safe, split_number_to_minute_and_second, stringify_hash_key, support_console_input?, support_console_output?, syntax_highlighting_debug?, time, to_class_name, unescape_title, windows?
Methods included from GetText
Constructor Details
#initialize(pixbuf, title, number, number_of_slides) ⇒ IndexThumbnail
Returns a new instance of IndexThumbnail.
130 131 132 133 134 135 136 137 |
# File 'lib/rabbit/element/index-slide.rb', line 130 def initialize(pixbuf, title, number, ) @pixbuf = pixbuf @title = title @number = number @number_of_slides = @layout = nil super() end |
Instance Attribute Details
#number ⇒ Object (readonly)
Returns the value of attribute number.
129 130 131 |
# File 'lib/rabbit/element/index-slide.rb', line 129 def number @number end |
#number_of_slides ⇒ Object (readonly)
Returns the value of attribute number_of_slides.
129 130 131 |
# File 'lib/rabbit/element/index-slide.rb', line 129 def @number_of_slides end |
#pixbuf ⇒ Object (readonly)
Returns the value of attribute pixbuf.
129 130 131 |
# File 'lib/rabbit/element/index-slide.rb', line 129 def pixbuf @pixbuf end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
129 130 131 |
# File 'lib/rabbit/element/index-slide.rb', line 129 def title @title end |
Instance Method Details
#clear_theme ⇒ Object
139 140 141 142 143 |
# 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) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# 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 ⇒ Object
166 167 168 |
# File 'lib/rabbit/element/index-slide.rb', line 166 def text @title end |
#to_html(generator) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# 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.(@number) img = "<img title=\"#{title}\" src=\"#{src}\" />" if generator. href = generator.(@number) "<a href=\"#{href}\">\n#{img}\n</a>" else img end end |
#to_rd ⇒ Object
170 171 172 |
# File 'lib/rabbit/element/index-slide.rb', line 170 def to_rd "* #{text}" end |