Class: APNGAsmGUI::Frame
- Inherits:
-
Gtk::Frame
- Object
- Gtk::Frame
- APNGAsmGUI::Frame
- Defined in:
- lib/apngasm-gui/frame.rb
Constant Summary collapse
- THUMBNAIL_SIZE =
100
Instance Attribute Summary collapse
-
#apngframe ⇒ Object
Returns the value of attribute apngframe.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#pixbuf ⇒ Object
Returns the value of attribute pixbuf.
Instance Method Summary collapse
- #delay ⇒ Object
-
#initialize(filename, parent, apngframe = nil) ⇒ Frame
constructor
A new instance of Frame.
- #resize(pixbuf, size) ⇒ Object
- #set_delay(value) ⇒ Object
Constructor Details
#initialize(filename, parent, apngframe = nil) ⇒ Frame
Returns a new instance of Frame.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 51 52 |
# File 'lib/apngasm-gui/frame.rb', line 8 def initialize(filename, parent, apngframe = nil) super() @filename = filename @parent = parent @apngframe = apngframe if @apngframe.nil? image = Gtk::Image.new(file: @filename) else Dir::mktmpdir(nil, File.dirname(__FILE__)) do |dir| @apngframe.save("#{dir}/#{@filename}") image = Gtk::Image.new(file: "#{dir}/#{@filename}") end end if image.pixbuf != nil if image.pixbuf.width > THUMBNAIL_SIZE || image.pixbuf.height > THUMBNAIL_SIZE image.pixbuf = resize(image.pixbuf, THUMBNAIL_SIZE) end end @pixbuf = image.pixbuf = Gtk::Button.new .set_relief(Gtk::ReliefStyle::NONE) .add(image) .signal_connect('clicked') do @parent.focus(self) end box = Gtk::Box.new(:vertical) box.pack_start(, expand: true, fill: false, padding: 10) adjustment = Gtk::Adjustment.new(100, 1, 999, 1, 1, 0) @delay_spinner = Gtk::SpinButton.new(adjustment, 1, 0) set_delay(@apngframe.nil? ? 100 : @apngframe.delay_numerator) box.pack_start(@delay_spinner, expand: false, fill: false) = Gtk::Button.new(label: 'Delete') .signal_connect('clicked') do @parent.delete(self) end box.pack_start(, expand: false, fill: false) add(box) end |
Instance Attribute Details
#apngframe ⇒ Object
Returns the value of attribute apngframe.
6 7 8 |
# File 'lib/apngasm-gui/frame.rb', line 6 def apngframe @apngframe end |
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/apngasm-gui/frame.rb', line 6 def filename @filename end |
#pixbuf ⇒ Object
Returns the value of attribute pixbuf.
6 7 8 |
# File 'lib/apngasm-gui/frame.rb', line 6 def pixbuf @pixbuf end |
Instance Method Details
#delay ⇒ Object
65 66 67 |
# File 'lib/apngasm-gui/frame.rb', line 65 def delay @delay_spinner.value end |
#resize(pixbuf, size) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/apngasm-gui/frame.rb', line 54 def resize(pixbuf, size) if pixbuf.width >= pixbuf.height scale = pixbuf.height.to_f / pixbuf.width.to_f pixbuf = pixbuf.scale(size, size * scale, Gdk::Pixbuf::INTERP_BILINEAR) else scale = pixbuf.width.to_f / pixbuf.height.to_f pixbuf = pixbuf.scale(size * scale, size, Gdk::Pixbuf::INTERP_BILINEAR) end pixbuf end |
#set_delay(value) ⇒ Object
69 70 71 |
# File 'lib/apngasm-gui/frame.rb', line 69 def set_delay(value) @delay_spinner.set_value(value) end |