Class: Rabbit::Element::Image
Constant Summary
Constants included
from GetText
GetText::DOMAIN
Instance Attribute Summary
#oh, #ow, #ox, #oy
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
-
#_compile ⇒ Object
-
#as_large_as_possible? ⇒ Boolean
-
#caption ⇒ Object
-
#caption_font_size ⇒ Object
-
#compile(canvas, x, y, w, h) ⇒ Object
-
#compile_for_horizontal_centering(canvas, x, y, w, h) ⇒ Object
-
#draw_element(canvas, x, y, w, h, simulation) ⇒ Object
-
#height ⇒ Object
-
#height_without_padding ⇒ Object
-
#initialize(filename, props, canvas: nil) ⇒ Image
constructor
-
#relative_height ⇒ Object
-
#relative_margin_bottom ⇒ Object
-
#relative_margin_left ⇒ Object
-
#relative_margin_right ⇒ Object
-
#relative_margin_top ⇒ Object
-
#relative_padding_bottom ⇒ Object
-
#relative_padding_left ⇒ Object
-
#relative_padding_right ⇒ Object
-
#relative_padding_top ⇒ Object
-
#relative_width ⇒ Object
-
#text ⇒ Object
-
#to_html(generator) ⇒ Object
-
#to_rd ⇒ Object
-
#width ⇒ Object
-
#width_without_padding ⇒ Object
#clear_theme, #do_horizontal_centering, #reset_horizontal_centering
#adjust_y_padding, #inline_element?
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, #clear_theme, #clone, #compile_element, #compile_horizontal, #default_prop, #dirty!, #dirty?, #do_horizontal_centering, #do_horizontal_centering?, #do_vertical_centering?, #font, #have_tag?, #have_wait_tag?, #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
#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
included
Constructor Details
#initialize(filename, props, canvas: nil) ⇒ Image
Returns a new instance of Image.
32
33
34
35
36
37
|
# File 'lib/rabbit/element/image.rb', line 32
def initialize(filename, props, canvas: nil)
super(filename, props, canvas: canvas)
setup_draw_parameters
resize(properties.get_size("width", @filename),
properties.get_size("height", @filename))
end
|
Instance Method Details
#_compile ⇒ Object
112
|
# File 'lib/rabbit/element/image.rb', line 112
alias _compile compile
|
#as_large_as_possible? ⇒ Boolean
132
133
134
|
# File 'lib/rabbit/element/image.rb', line 132
def as_large_as_possible?
properties.get_boolean("as_large_as_possible")
end
|
#caption ⇒ Object
45
46
47
|
# File 'lib/rabbit/element/image.rb', line 45
def caption
self["caption"]
end
|
#caption_font_size ⇒ Object
49
50
51
|
# File 'lib/rabbit/element/image.rb', line 49
def caption_font_size
properties.get_float("caption-font-size")
end
|
#compile(canvas, x, y, w, h) ⇒ Object
117
118
119
120
|
# File 'lib/rabbit/element/image.rb', line 117
def compile(canvas, x, y, w, h)
super
adjust_size(canvas, @x, @y, @w, @h)
end
|
#compile_for_horizontal_centering(canvas, x, y, w, h) ⇒ Object
113
114
115
|
# File 'lib/rabbit/element/image.rb', line 113
def compile_for_horizontal_centering(canvas, x, y, w, h)
_compile(canvas, x, y, w, h)
end
|
#draw_element(canvas, x, y, w, h, simulation) ⇒ Object
39
40
41
42
43
|
# File 'lib/rabbit/element/image.rb', line 39
def draw_element(canvas, x, y, w, h, simulation)
result = draw_image(canvas, x, y, w, h, simulation)
draw_properties(canvas, x, y, w, h) unless simulation
result
end
|
#height ⇒ Object
128
129
130
|
# File 'lib/rabbit/element/image.rb', line 128
def height
super + @padding_top + @padding_bottom
end
|
#height_without_padding ⇒ Object
127
|
# File 'lib/rabbit/element/image.rb', line 127
alias_method :height_without_padding, :height
|
#relative_height ⇒ Object
76
77
78
|
# File 'lib/rabbit/element/image.rb', line 76
def relative_height
properties.get_relative_size("relative_height", @filename)
end
|
#relative_margin_bottom ⇒ Object
84
85
86
|
# File 'lib/rabbit/element/image.rb', line 84
def relative_margin_bottom
properties.get_relative_size("relative_margin_bottom", @filename)
end
|
#relative_margin_left ⇒ Object
88
89
90
|
# File 'lib/rabbit/element/image.rb', line 88
def relative_margin_left
properties.get_relative_size("relative_margin_left", @filename)
end
|
#relative_margin_right ⇒ Object
92
93
94
|
# File 'lib/rabbit/element/image.rb', line 92
def relative_margin_right
properties.get_relative_size("relative_margin_right", @filename)
end
|
#relative_margin_top ⇒ Object
80
81
82
|
# File 'lib/rabbit/element/image.rb', line 80
def relative_margin_top
properties.get_relative_size("relative_margin_top", @filename)
end
|
#relative_padding_bottom ⇒ Object
100
101
102
|
# File 'lib/rabbit/element/image.rb', line 100
def relative_padding_bottom
properties.get_relative_size("relative_padding_bottom", @filename)
end
|
#relative_padding_left ⇒ Object
104
105
106
|
# File 'lib/rabbit/element/image.rb', line 104
def relative_padding_left
properties.get_relative_size("relative_padding_left", @filename)
end
|
#relative_padding_right ⇒ Object
108
109
110
|
# File 'lib/rabbit/element/image.rb', line 108
def relative_padding_right
properties.get_relative_size("relative_padding_right", @filename)
end
|
#relative_padding_top ⇒ Object
96
97
98
|
# File 'lib/rabbit/element/image.rb', line 96
def relative_padding_top
properties.get_relative_size("relative_padding_top", @filename)
end
|
#relative_width ⇒ Object
72
73
74
|
# File 'lib/rabbit/element/image.rb', line 72
def relative_width
properties.get_relative_size("relative_width", @filename)
end
|
#text ⇒ Object
53
54
55
|
# File 'lib/rabbit/element/image.rb', line 53
def text
caption.to_s
end
|
#to_html(generator) ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/rabbit/element/image.rb', line 61
def to_html(generator)
src = generator.save_pixbuf(pixbuf, File.basename(@filename))
html = "<img "
if @caption
alt = generator.h(@caption)
html << "title=\"#{alt}\" alt=\"#{alt}\" "
end
html << "src=\"#{src}\" />"
html
end
|
#to_rd ⇒ Object
57
58
59
|
# File 'lib/rabbit/element/image.rb', line 57
def to_rd
text
end
|
#width ⇒ Object
123
124
125
|
# File 'lib/rabbit/element/image.rb', line 123
def width
super + @padding_left + @padding_right
end
|
#width_without_padding ⇒ Object
122
|
# File 'lib/rabbit/element/image.rb', line 122
alias_method :width_without_padding, :width
|