From 32ed5a2d05b8266b2dd00844dc7b52b3cb91114d Mon Sep 17 00:00:00 2001 From: Nikolaus Gotsche Date: Sun, 27 Jan 2019 00:55:41 +0100 Subject: Fenestra 0.1 --- nucuwin.go | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100644 nucuwin.go (limited to 'nucuwin.go') diff --git a/nucuwin.go b/nucuwin.go new file mode 100644 index 0000000..3cde330 --- /dev/null +++ b/nucuwin.go @@ -0,0 +1,221 @@ +package main + +import ( + //"fmt" + "os" + + + "github.com/aarzilli/nucular" + "github.com/aarzilli/nucular/label" + nstyle "github.com/aarzilli/nucular/style" + "github.com/aarzilli/nucular/rect" + //ncommand "github.com/aarzilli/nucular/command" + + //"golang.org/x/mobile/event/key" + //"golang.org/x/mobile/event/mouse" +) + + +type nucularWindow struct { + ShowMenu bool + Titlebar bool + Border bool + Resize bool + Movable bool + NoScrollbar bool + Minimizable bool + Close bool + + HeaderAlign nstyle.HeaderAlign + + // Menu status + Mprog int + Mslider int + Mcheck bool + Prog int + Slider int + Check bool + + Theme nstyle.Theme +} + +func newNucularWindow() (nw *nucularWindow) { + nw = &nucularWindow{} + nw.ShowMenu = true + nw.Titlebar = true + nw.Border = true + nw.Resize = true + nw.Movable = true + nw.NoScrollbar = false + nw.Close = true + + nw.HeaderAlign = nstyle.HeaderRight + nw.Mprog = 60 + nw.Mslider = 8 + nw.Mcheck = true + + return nw +} + +// Master Window +func (nw *nucularWindow) nucularWindow(w *nucular.Window) { + //keybindings(w) + mw := w.Master() + + style := mw.Style() + style.NormalWindow.Header.Align = nw.HeaderAlign + if nw.ShowMenu { + nw.nucularMenubar(w) + } + w.Row(30).Dynamic(1) + w.Label(hea,"CC") + //w.Spacing(2) + for _,d := range(dat) { + if w.TreePush(nucular.TreeTab, d.title, true) { + w.Row(20).Dynamic(2) + //w.Row(20).Dynamic(3) + //w.Row(20).Static(100) + for i,_ := range(d.textl){ + w.Label(d.textl[i], "RC") + w.Label(d.textr[i], "LC") + //w.Label("", "LC") + } + + w.TreePop() + } + } + w.Row(30).Static(300, 100, 100) + w.Label("", "LC") + if w.ButtonText("Exit") { + os.Exit(0) + } +} + + +func (nw *nucularWindow) nucularMenubar(w *nucular.Window) { + w.MenubarBegin() + w.Row(25).Static(45, 70, 45, 70, 70) + if w := w.Menu(label.TA("Menu", "CC"), 120, nil); w != nil { + w.Row(25).Dynamic(1) + /*if w.MenuItem(label.TA("Hide", "LC")) { + w.Label("You Wish","LC") + //nw.ShowMenu = false + }*/ + if w.MenuItem(label.TA("About", "LC")) { + nw.showAppAbout(w.Master()) + } + if w.MenuItem(label.TA("Quit", "LC")) { + nw.showQuestion(w.Master()) //,"Do You want to Quit?") { + //os.Exit(0) + //} + } + } + if w := w.Menu(label.TA("Theme", "CC"), 180, nil); w != nil { + w.Row(25).Dynamic(1) + newtheme := nw.Theme + if w.OptionText("Default Theme", newtheme == nstyle.DefaultTheme) { + newtheme = nstyle.DefaultTheme + } + if w.OptionText("White Theme", newtheme == nstyle.WhiteTheme) { + newtheme = nstyle.WhiteTheme + } + if w.OptionText("Red Theme", newtheme == nstyle.RedTheme) { + newtheme = nstyle.RedTheme + } + if w.OptionText("Dark Theme", newtheme == nstyle.DarkTheme) { + newtheme = nstyle.DarkTheme + } + if newtheme != nw.Theme { + nw.Theme = newtheme + w.Master().SetStyle(nstyle.FromTheme(nw.Theme, w.Master().Style().Scaling)) + w.Close() + } + } + w.MenubarEnd() +} + +func (nw *nucularWindow) errorPopup(w *nucular.Window) { + w.Row(25).Dynamic(1) + w.Label("A terrible error has occured", "LC") + w.Row(25).Dynamic(2) + if w.Button(label.T("OK"), false) { + w.Close() + } + if w.Button(label.T("Cancel"), false) { + w.Close() + } +} + +func (nw *nucularWindow) questionPopup(w *nucular.Window) { + w.Row(25).Dynamic(1) + w.Label("Are You Sure?", "LC") + w.Row(25).Dynamic(2) + if w.Button(label.T("OK"), false) { + os.Exit(0) + } + if w.Button(label.T("Cancel"), false) { + w.Close() + } +} + +func (nw *nucularWindow) aboutPopup(w *nucular.Window) { + w.Row(20).Dynamic(1) + w.Label("Fenestra", "LC") + w.Row(40).Dynamic(1) + w.LabelWrap("A viewer for my text based Cheatsheets.") + w.Row(15).Dynamic(1) + w.Label("Usind Nucular by Alessandro Arzilli", "LC") + w.Label("based on Nuklear by Micha Mettke", "LC") + + if w.Button(label.T("OK"), false) { + w.Close() + } +} + +func (nw *nucularWindow) showAppAbout(mw nucular.MasterWindow) { + var wf nucular.WindowFlags + + if nw.Border { + wf |= nucular.WindowBorder + } + if nw.Resize { + wf |= nucular.WindowScalable + } + if nw.Movable { + wf |= nucular.WindowMovable + } + if nw.NoScrollbar { + wf |= nucular.WindowNoScrollbar + } + if nw.Close { + wf |= nucular.WindowClosable + } + if nw.Titlebar { + wf |= nucular.WindowTitle + } + mw.PopupOpen("About", wf, rect.Rect{20, 100, 300, 190}, true, nw.aboutPopup) +} + +func (nw *nucularWindow) showQuestion(mw nucular.MasterWindow) { + var wf nucular.WindowFlags + + if nw.Border { + wf |= nucular.WindowBorder + } + if nw.Resize { + wf |= nucular.WindowScalable + } + if nw.Movable { + wf |= nucular.WindowMovable + } + if nw.NoScrollbar { + wf |= nucular.WindowNoScrollbar + } + if nw.Close { + wf |= nucular.WindowClosable + } + if nw.Titlebar { + wf |= nucular.WindowTitle + } + mw.PopupOpen("QUIT", wf, rect.Rect{20, 100, 300, 190}, true, nw.questionPopup) +} -- cgit v1.2.3