|
| 1 | +import figuro/widgets/[horizontal, vertical, button] |
| 2 | +import figuro/ui/animations |
| 3 | +import figuro |
| 4 | + |
| 5 | +import sugar |
| 6 | + |
| 7 | +type |
| 8 | + Main* = ref object of Figuro |
| 9 | + bkgFade* = Fader(minMax: 0.0..1.0, |
| 10 | + inTimeMs: 200, outTimeMs: 200) |
| 11 | + |
| 12 | +proc initialize*(self: Main) {.slot.} = |
| 13 | + self.setTitle("Click Test!") |
| 14 | + self.bkgFade.addTarget(self) |
| 15 | + |
| 16 | +proc activateSlider*(self: Main) {.slot.} = |
| 17 | + ## activate fading on hover, deactive when not hovering |
| 18 | + self.bkgFade.fadeIn() |
| 19 | +proc deactivateSlider*(self: Main) {.slot.} = |
| 20 | + ## activate fading on hover, deactive when not hovering |
| 21 | + self.bkgFade.fadeOut() |
| 22 | + |
| 23 | +proc draw*(self: Main) {.slot.} = |
| 24 | + let node = self |
| 25 | + rectangle "body": |
| 26 | + with node: |
| 27 | + fill blackColor.lighten(0.7) |
| 28 | + zlevel 20.ZLevel |
| 29 | + box ux(140*self.bkgFade.amount - 140), 0'ux, 140'ux, 100'pp |
| 30 | + cornerRadius 0.0 |
| 31 | + Vertical.new "menu": |
| 32 | + box node, 0'ux, 10'ux, 100'pp, 95'pp |
| 33 | + itemHeight node, cx"min-content", gap = 20'ui |
| 34 | + Button.new "close": |
| 35 | + size node, 120'ux, 60'ux |
| 36 | + connect(node, doClicked, self, deactivateSlider) |
| 37 | + text "text": |
| 38 | + fill node, blackColor |
| 39 | + setText(node, {defaultFont: "Close Menu"}, Center, Middle) |
| 40 | + Horizontal.new "horiz": |
| 41 | + offset node, 30'pp, 0'ux |
| 42 | + itemWidth node, cx"min-content", gap = 20'ui |
| 43 | + Button.new "pen": |
| 44 | + size node, 120'ux, 60'ux |
| 45 | + connect(node, doClicked, self, activateSlider) |
| 46 | + text "text": |
| 47 | + fill node, blackColor |
| 48 | + setText(node, {defaultFont: "Open Menu"}, Center, Middle) |
| 49 | + |
| 50 | + Button.new "close": |
| 51 | + size node, 120'ux, 60'ux |
| 52 | + connect(node, doClicked, self, deactivateSlider) |
| 53 | + text "text": |
| 54 | + fill node, blackColor |
| 55 | + setText(node, {defaultFont: "Close Menu"}, Center, Middle) |
| 56 | + |
| 57 | +var main = Main.new() |
| 58 | +var frame = newAppFrame(main, size=(500'ui, 300'ui)) |
| 59 | +startFiguro(frame) |
0 commit comments