class PhantomAnimationEditor::FrameList
Attributes
cur[RW]
frame_hbox[RW]
list[RW]
phantom_svg[RW]
Public Class Methods
new(frame_hbox)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 8 def initialize(frame_hbox) @frame_hbox = frame_hbox @list = [] @phantom_svg = Phantom::SVG::Base.new end
Public Instance Methods
<<(data)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 14 def <<(data) @list << data @cur = @list.size - 1 @phantom_svg.add_frame_from_file(data.filename) if File.exist?(data.filename) end
delay(position = nil)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 36 def delay(position = nil) return @list[@cur].delay if position.nil? return nil if position > @list.size return @list[position].delay end
delete(child)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 70 def delete(child) @phantom_svg.frames.delete_at(@list.find_index(child)) @list.delete(child) @frame_hbox.remove(child) @cur -= 1 unless @cur == 0 if @list.size == 0 $preview.set_stock(Gtk::Stock::MISSING_IMAGE) else $preview.set_pixbuf(@list[@cur].pixbuf) end end
delete_all()
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 88 def delete_all @list.size.times do child = @list[0] @list.delete(child) @frame_hbox.remove(child) end @phantom_svg.reset @cur = 0 $preview.set_stock(Gtk::Stock::MISSING_IMAGE) end
delete_at(index)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 83 def delete_at(index) child = @list[index] delete(child) end
filename(position = nil)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 24 def filename(position = nil) return @list[@cur].filename if position.nil? return nil if position > @list.size return @list[position].filename end
focus(child)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 99 def focus(child) @cur = @list.find_index(child) $preview.set_pixbuf(@list[@cur].pixbuf) end
insert_first(list, old_position)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 56 def insert_first(list, old_position) list.insert(0, list[old_position]) list.delete_at(old_position + 1) end
insert_last(list, old_position)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 61 def insert_last(list, old_position) list << list[old_position] list.delete_at(old_position) end
pixbuf(position = nil)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 30 def pixbuf(position = nil) return @list[@cur].pixbuf if position.nil? return nil if position > @list.size return @list[position].pixbuf end
size()
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 20 def size @list.size end
swap(old_position, new_position)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 42 def swap(old_position, new_position) case new_position when 0 then insert_first(@list, old_position) insert_first(@phantom_svg.frames, old_position) when @list.size - 1 then insert_last(@list, old_position) insert_last(@phantom_svg.frames, old_position) else swap_pos(@list, old_position, new_position) swap_pos(@phantom_svg.frames, old_position, new_position) end end
swap_pos(list, old_position, new_position)
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 66 def swap_pos(list, old_position, new_position) list[old_position], list[new_position] = list[new_position], list[old_position] end
view_reload()
click to toggle source
# File lib/phantom_animation_editor/frame_list.rb, line 104 def view_reload @list.each { |frame| @frame_hbox.remove(frame) } @list.each do |frame| @frame_hbox.pack_start(frame, expand: false, fill: false, padding: 10) end end