Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/samples/simple-menu.rb
blob: aba8788b4f0db648f1619bfe0f0c64754ce50043 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class MenuPanel < Shoes::Widget
  @@boxes = []
  def initialize(color, args)
    @@boxes << self
    background color
    para link("Box #{@@boxes.length}", :stroke => white, :fill => nil).
      click { visit "/" },
        :margin => 18, :align => "center", :size => 20
    hover { expand }
  end
  def expand
    if self.width < 170
      a = animate 30 do
        @@boxes.each do |b|
          b.width -= 5 if b != self and b.width > 140
        end
        self.width += 5
        a.stop if self.width >= 170
      end
    end
  end
end

Shoes.app :width => 400, :height => 130 do
  style(Link, :underline => nil)
  style(LinkHover, :fill => nil, :underline => nil)
  menu_panel green,  :width => 170, :height => 120, :margin => 4
  menu_panel blue,   :width => 140, :height => 120, :margin => 4
  menu_panel red,    :width => 140, :height => 120, :margin => 4
  menu_panel purple, :width => 140, :height => 120, :margin => 4
end