Class: Alexandria::UI::BarcodeAnimation
- Inherits:
-
Object
- Object
- Alexandria::UI::BarcodeAnimation
- Defined in:
- lib/alexandria/ui/barcode_animation.rb
Instance Attribute Summary collapse
-
#canvas ⇒ Object
readonly
Returns the value of attribute canvas.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize ⇒ BarcodeAnimation
constructor
A new instance of BarcodeAnimation.
- #manual_input ⇒ Object
- #scanner_input ⇒ Object
- #set_active ⇒ Object
- #set_passive ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ BarcodeAnimation
Returns a new instance of BarcodeAnimation.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 55 def initialize @canvas = GooCanvas::Canvas.new @canvas.set_size_request(300, 70) @canvas.set_bounds(0, 0, 350, 70) @root = @canvas.root_item @barcode_bars = [] @barcode_data = [] @hpos = 0 @scale = 3 @bar_left_edge = 0 @bar_top = 8 @bar_height = 50 @timeout = nil @index = 0 @fade_opacity = 255 set_active @canvas.show end |
Instance Attribute Details
#canvas ⇒ Object (readonly)
Returns the value of attribute canvas.
53 54 55 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 53 def canvas @canvas end |
Instance Method Details
#destroy ⇒ Object
88 89 90 91 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 88 def destroy @canvas.destroy @canvas = nil end |
#manual_input ⇒ Object
106 107 108 109 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 106 def manual_input # TODO: distinguish between scanner and manual input # @canvas.set_property(:background_color, "#FFF8C0") end |
#scanner_input ⇒ Object
111 112 113 114 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 111 def scanner_input # TODO: distinguish between scanner and manual input # @canvas.set_property(:background_color, "white") end |
#set_active ⇒ Object
93 94 95 96 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 93 def set_active @canvas.set_property(:background_color, "white") @barcode_bars.each { |rect| rect.set_property(:fill_color, "white") } end |
#set_passive ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 98 def set_passive if @canvas passive_bg = "#F4F4F4" @canvas.set_property(:background_color, passive_bg) @barcode_bars.each { |rect| rect.set_property(:fill_color, passive_bg) } end end |
#start ⇒ Object
81 82 83 84 85 86 |
# File 'lib/alexandria/ui/barcode_animation.rb', line 81 def start @timeout = GLib::Timeout.add(20) do scan_animation (@index >= 0) end end |