Module: Rabbit::Element::SlideElement

Includes:
BlockElement, ContainerElement
Included in:
IndexSlide, Slide, TitleSlide
Defined in:
lib/rabbit/element/slide-element.rb

Constant Summary

Constants included from GetText

GetText::DOMAIN

Instance Attribute Summary collapse

Attributes included from ContainerElement

#elements

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

Methods included from BlockElement

#adjust_y_padding, #inline_element?

Methods included from ContainerElement

#<<, #[], #[]=, #_width, #compile, #compile_elements, #compile_horizontal, #compile_horizontal_element, #delete, #dirty?, #draw_element, #draw_elements, #have_tag?, #have_wait_tag?, #height, #inspect, #prop_delete, #prop_get, #prop_set, #replace_element, #substitute_text, #text, #to_html, #to_rd, #unshift, #width

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?, #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, #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, drawable_to_pixbuf, 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

Instance Attribute Details

#drawing_indexObject

Returns the value of attribute drawing_index.



9
10
11
# File 'lib/rabbit/element/slide-element.rb', line 9

def drawing_index
  @drawing_index
end

#indexObject

Returns the value of attribute index.



9
10
11
# File 'lib/rabbit/element/slide-element.rb', line 9

def index
  @index
end

#transitionObject

Returns the value of attribute transition.



9
10
11
# File 'lib/rabbit/element/slide-element.rb', line 9

def transition
  @transition
end

Instance Method Details

#clear_themeObject



53
54
55
56
57
58
# File 'lib/rabbit/element/slide-element.rb', line 53

def clear_theme
  super
  clear_waiting
  clear_transition
  @waited_draw_procs = @default_waited_draw_procs.dup
end

#clear_transitionObject



49
50
51
# File 'lib/rabbit/element/slide-element.rb', line 49

def clear_transition
  @transition = nil
end

#clear_waitingObject



45
46
47
# File 'lib/rabbit/element/slide-element.rb', line 45

def clear_waiting
  @drawing_index = 0
end

#draw(canvas, simulation = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rabbit/element/slide-element.rb', line 28

def draw(canvas, simulation=nil)
  if simulation.nil?
    begin
      draw(canvas, true)
      draw(canvas, false)
    rescue StandardError, LoadError
      canvas.logger.warn($!)
    end
  else
    canvas.draw_slide(self, simulation) do
      compile(canvas, 0, 0, canvas.width, canvas.height)
      super(simulation)
    end
    run_gc unless simulation
  end
end

#first?(index = nil) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/rabbit/element/slide-element.rb', line 60

def first?(index=nil)
  (index || @drawing_index).zero?
end

#flushObject



84
85
86
# File 'lib/rabbit/element/slide-element.rb', line 84

def flush
  @drawing_index = @waited_draw_procs.size
end

#initialize(title_element) ⇒ Object



10
11
12
13
14
# File 'lib/rabbit/element/slide-element.rb', line 10

def initialize(title_element)
  @index = -1
  @default_waited_draw_procs = []
  super(title_element)
end

#last?(index = nil) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/rabbit/element/slide-element.rb', line 64

def last?(index=nil)
  @waited_draw_procs.size == (index || @drawing_index)
end

#move_to_nextObject



68
69
70
# File 'lib/rabbit/element/slide-element.rb', line 68

def move_to_next
  @drawing_index += 1 unless last?
end

#move_to_previousObject



72
73
74
# File 'lib/rabbit/element/slide-element.rb', line 72

def move_to_previous
  @drawing_index -= 1 unless first?
end

#register_default_wait_proc(target, exact = false, &proc) ⇒ Object



76
77
78
# File 'lib/rabbit/element/slide-element.rb', line 76

def register_default_wait_proc(target, exact=false, &proc)
  @default_waited_draw_procs << [target, exact, proc]
end

#register_wait_proc(target, exact = false, &proc) ⇒ Object



80
81
82
# File 'lib/rabbit/element/slide-element.rb', line 80

def register_wait_proc(target, exact=false, &proc)
  @waited_draw_procs << [target, exact, proc]
end

#size_ratioObject



24
25
26
# File 'lib/rabbit/element/slide-element.rb', line 24

def size_ratio
  self["size-ratio"]
end

#slideObject



16
17
18
# File 'lib/rabbit/element/slide-element.rb', line 16

def slide
  self
end

#titleObject



20
21
22
# File 'lib/rabbit/element/slide-element.rb', line 20

def title
  @elements.first.text
end

#waited_draw_procs(target) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rabbit/element/slide-element.rb', line 88

def waited_draw_procs(target)
  procs = []
  candidates = @waited_draw_procs[0, @drawing_index]
  candidates.each_with_index do |(t, exact, proc), i|
    next unless target == t
    if exact
      procs << proc if i == @drawing_index - 1
    else
      procs << proc
    end
  end
  procs
end