Class: Alexandria::UI::BarcodeAnimation

Inherits:
Object
  • Object
show all
Defined in:
lib/alexandria/ui/barcode_animation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBarcodeAnimation

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

  create_ean_barcode_data
  draw_barcode_bars

  @timeout = nil
  @index = 0
  @fade_opacity = 255
  set_active
  @canvas.show
end

Instance Attribute Details

#canvasObject (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

#destroyObject



88
89
90
91
# File 'lib/alexandria/ui/barcode_animation.rb', line 88

def destroy
  @canvas.destroy
  @canvas = nil
end

#manual_inputObject



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_inputObject



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_activeObject



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_passiveObject



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

#startObject



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