Class: Rabbit::Element::Video
- Inherits:
-
Object
- Object
- Rabbit::Element::Video
- Includes:
- Base, BlockElement, BlockHorizontalCentering, TextRenderer
- Defined in:
- lib/rabbit/element/video.rb
Constant Summary
Constants included from GetText
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#relative_height ⇒ Object
readonly
Returns the value of attribute relative_height.
-
#relative_margin_bottom ⇒ Object
readonly
Returns the value of attribute relative_margin_bottom.
-
#relative_margin_left ⇒ Object
readonly
Returns the value of attribute relative_margin_left.
-
#relative_margin_right ⇒ Object
readonly
Returns the value of attribute relative_margin_right.
-
#relative_margin_top ⇒ Object
readonly
Returns the value of attribute relative_margin_top.
-
#relative_padding_bottom ⇒ Object
readonly
Returns the value of attribute relative_padding_bottom.
-
#relative_padding_left ⇒ Object
readonly
Returns the value of attribute relative_padding_left.
-
#relative_padding_right ⇒ Object
readonly
Returns the value of attribute relative_padding_right.
-
#relative_padding_top ⇒ Object
readonly
Returns the value of attribute relative_padding_top.
-
#relative_width ⇒ Object
readonly
Returns the value of attribute relative_width.
Attributes included from TextRenderer
#first_line_height, #first_line_width, #indent, #layout, #original_height, #original_width, #wrap_mode
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
Attributes included from BlockHorizontalCentering
Instance Method Summary collapse
- #_compile ⇒ Object
- #as_large_as_possible? ⇒ Boolean
- #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
-
#initialize(filename, prop) ⇒ Video
constructor
A new instance of Video.
- #text ⇒ Object
- #to_rd ⇒ Object
- #width ⇒ Object
Methods included from TextRenderer
#align=, #as_large_as_possible, #clear_theme, #dirty!, #dirty?, #do_horizontal_centering, #do_horizontal_centering?, #font_size, #have_numerical_font_size?, #justify=, #keep_in_size, #markuped_text, #pixel_font_size, #reset_horizontal_centering, #spacing=, #text_clear_theme, #text_compile, #text_dirty?, #text_props, #text_renderer?, #text_to_html
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?, #draw, #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
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
Methods included from BlockHorizontalCentering
#clear_theme, #do_horizontal_centering, #reset_horizontal_centering
Methods included from BlockElement
#adjust_y_padding, #inline_element?
Constructor Details
#initialize(filename, prop) ⇒ Video
Returns a new instance of Video.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rabbit/element/video.rb', line 23 def initialize(filename, prop) @filename = filename prop = Utils.stringify_hash_key(prop) super() normalized_prop = {} prop.each do |name, value| normalized_prop[name.gsub(/-/, '_')] = value end prop = normalized_prop %w(as_large_as_possible).each do |name| instance_variable_set("@#{name}", true_value?(prop[name])) end %w(width height relative_width relative_height relative_margin_top relative_margin_bottom relative_margin_left relative_margin_right relative_padding_top relative_padding_bottom relative_padding_left relative_padding_right ).each do |name| begin instance_variable_set("@#{name}", prop[name] && Integer(prop[name])) rescue ArgumentError raise InvalidSizeError.new(filename, name, prop[name]) end end resize(@width, @height) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
16 17 18 |
# File 'lib/rabbit/element/video.rb', line 16 def filename @filename end |
#relative_height ⇒ Object (readonly)
Returns the value of attribute relative_height.
17 18 19 |
# File 'lib/rabbit/element/video.rb', line 17 def relative_height @relative_height end |
#relative_margin_bottom ⇒ Object (readonly)
Returns the value of attribute relative_margin_bottom.
18 19 20 |
# File 'lib/rabbit/element/video.rb', line 18 def relative_margin_bottom @relative_margin_bottom end |
#relative_margin_left ⇒ Object (readonly)
Returns the value of attribute relative_margin_left.
19 20 21 |
# File 'lib/rabbit/element/video.rb', line 19 def relative_margin_left @relative_margin_left end |
#relative_margin_right ⇒ Object (readonly)
Returns the value of attribute relative_margin_right.
19 20 21 |
# File 'lib/rabbit/element/video.rb', line 19 def relative_margin_right @relative_margin_right end |
#relative_margin_top ⇒ Object (readonly)
Returns the value of attribute relative_margin_top.
18 19 20 |
# File 'lib/rabbit/element/video.rb', line 18 def relative_margin_top @relative_margin_top end |
#relative_padding_bottom ⇒ Object (readonly)
Returns the value of attribute relative_padding_bottom.
20 21 22 |
# File 'lib/rabbit/element/video.rb', line 20 def relative_padding_bottom @relative_padding_bottom end |
#relative_padding_left ⇒ Object (readonly)
Returns the value of attribute relative_padding_left.
21 22 23 |
# File 'lib/rabbit/element/video.rb', line 21 def relative_padding_left @relative_padding_left end |
#relative_padding_right ⇒ Object (readonly)
Returns the value of attribute relative_padding_right.
21 22 23 |
# File 'lib/rabbit/element/video.rb', line 21 def relative_padding_right @relative_padding_right end |
#relative_padding_top ⇒ Object (readonly)
Returns the value of attribute relative_padding_top.
20 21 22 |
# File 'lib/rabbit/element/video.rb', line 20 def relative_padding_top @relative_padding_top end |
#relative_width ⇒ Object (readonly)
Returns the value of attribute relative_width.
17 18 19 |
# File 'lib/rabbit/element/video.rb', line 17 def relative_width @relative_width end |
Instance Method Details
#_compile ⇒ Object
52 |
# File 'lib/rabbit/element/video.rb', line 52 alias _compile compile |
#as_large_as_possible? ⇒ Boolean
70 71 72 |
# File 'lib/rabbit/element/video.rb', line 70 def as_large_as_possible? @as_large_as_possible end |
#compile(canvas, x, y, w, h) ⇒ Object
57 58 59 60 |
# File 'lib/rabbit/element/video.rb', line 57 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
53 54 55 |
# File 'lib/rabbit/element/video.rb', line 53 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
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rabbit/element/video.rb', line 74 def draw_element(canvas, x, y, w, h, simulation) unless simulation if canvas.display? require "rabbit/video-window" VideoWindow.show(canvas.window, self) else draw_layout(canvas, x, y) end end [x, y + height, w, h - height] end |
#height ⇒ Object
66 67 68 |
# File 'lib/rabbit/element/video.rb', line 66 def height @height.to_i + @padding_top + @padding_bottom end |
#text ⇒ Object
86 87 88 |
# File 'lib/rabbit/element/video.rb', line 86 def text "video : #{File.basename(@filename)}" end |
#to_rd ⇒ Object
90 91 92 |
# File 'lib/rabbit/element/video.rb', line 90 def to_rd text end |
#width ⇒ Object
62 63 64 |
# File 'lib/rabbit/element/video.rb', line 62 def width @width.to_i + @padding_left + @padding_right end |