Class: APNGAsmGUI::FrameList

Inherits:
Object
  • Object
show all
Defined in:
lib/apngasm-gui/frame_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frame_hbox) ⇒ FrameList

Returns a new instance of FrameList.



6
7
8
9
# File 'lib/apngasm-gui/frame_list.rb', line 6

def initialize(frame_hbox)
  @frame_hbox = frame_hbox
  @list = []
end

Instance Attribute Details

#curObject

Returns the value of attribute cur.



4
5
6
# File 'lib/apngasm-gui/frame_list.rb', line 4

def cur
  @cur
end

#frame_hboxObject

Returns the value of attribute frame_hbox.



4
5
6
# File 'lib/apngasm-gui/frame_list.rb', line 4

def frame_hbox
  @frame_hbox
end

#listObject

Returns the value of attribute list.



4
5
6
# File 'lib/apngasm-gui/frame_list.rb', line 4

def list
  @list
end

Instance Method Details

#<<(data) ⇒ Object



11
12
13
14
# File 'lib/apngasm-gui/frame_list.rb', line 11

def <<(data)
  @list << data
  @cur = @list.size - 1
end

#delay(position = nil) ⇒ Object



32
33
34
35
36
# File 'lib/apngasm-gui/frame_list.rb', line 32

def delay(position = nil)
  return @list[@cur].delay if position.nil?
  return nil if position > @list.size
  return @list[position].delay
end

#delete(child) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/apngasm-gui/frame_list.rb', line 51

def delete(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_allObject



67
68
69
70
71
72
73
74
75
# File 'lib/apngasm-gui/frame_list.rb', line 67

def delete_all
  for i in 0..@list.size do
    child = @list[0]
    @list.delete(child)
    @frame_hbox.remove(child)
  end
  @cur == 0
  $preview.set_stock(Gtk::Stock::MISSING_IMAGE)
end

#delete_at(index) ⇒ Object



62
63
64
65
# File 'lib/apngasm-gui/frame_list.rb', line 62

def delete_at(index)
  child = @list[index]
  delete(child)
end

#filename(position = nil) ⇒ Object



20
21
22
23
24
# File 'lib/apngasm-gui/frame_list.rb', line 20

def filename(position = nil)
  return @list[@cur].filename if position.nil?
  return nil if position > @list.size
  return @list[position].filename
end

#focus(child) ⇒ Object



77
78
79
80
# File 'lib/apngasm-gui/frame_list.rb', line 77

def focus(child)
  @cur = @list.find_index(child)
  $preview.set_pixbuf(@list[@cur].pixbuf)
end

#pixbuf(position = nil) ⇒ Object



26
27
28
29
30
# File 'lib/apngasm-gui/frame_list.rb', line 26

def pixbuf(position = nil)
  return @list[@cur].pixbuf if position.nil?
  return nil if position > @list.size
  return @list[position].pixbuf
end

#sizeObject



16
17
18
# File 'lib/apngasm-gui/frame_list.rb', line 16

def size
  @list.size
end

#swap(old_position, new_position) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/apngasm-gui/frame_list.rb', line 38

def swap(old_position, new_position)
  case new_position
  when 0 then
    @list.insert(0, @list[old_position])
    @list.delete_at(old_position + 1)
  when @list.size - 1 then
    @list << @list[old_position]
    @list.delete_at(old_position)
  else
    @list[old_position], @list[new_position] = @list[new_position], @list[old_position]
  end
end

#view_reloadObject



82
83
84
85
86
87
# File 'lib/apngasm-gui/frame_list.rb', line 82

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