Skip to content

Commit

Permalink
more kit things
Browse files Browse the repository at this point in the history
  • Loading branch information
vizicist committed Nov 26, 2023
1 parent 643462f commit 889be92
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 205 deletions.
14 changes: 7 additions & 7 deletions tool/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"fmt"
"image"

"github.com/vizicist/palette/engine"
"github.com/vizicist/palette/kit"
w "github.com/vizicist/palette/twinsys"
)

func init() {
w.RegisterWindow("Console", NewConsole)
// engine.RegisterBlock("Console", NewConsole)
// kit.RegisterBlock("Console", NewConsole)
}

// Console is a window that has a couple of buttons
Expand Down Expand Up @@ -48,15 +48,15 @@ func (console *Console) Context() *w.WinContext {
}

// Do xxx
func (console *Console) Do(cmd engine.Cmd) string {
func (console *Console) Do(cmd kit.Cmd) string {
switch cmd.Subj {
case "mouse":
pos := cmd.ValuesPos(engine.PointZero)
pos := cmd.ValuesPos(kit.PointZero)
child, relpos := w.WinFindWindowUnder(console, pos)
if child != nil {
// Note that we update the value in cmd.Values
cmd.ValuesSetPos(relpos)
engine.LogOfType("mouse", "Console Do mouse", "cmd", cmd)
kit.LogOfType("mouse", "Console Do mouse", "cmd", cmd)
child.Do(cmd)
}

Expand Down Expand Up @@ -84,7 +84,7 @@ func (console *Console) Do(cmd engine.Cmd) string {
case "Three":
console.addLine("Three!\n")
case "Clear":
console.TextArea.Do(engine.NewSimpleCmd("clear"))
console.TextArea.Do(kit.NewSimpleCmd("clear"))
default:
lbl := cmd.ValuesString("label", "")
console.addLine(fmt.Sprintf("Unknown button: %s\n", lbl))
Expand All @@ -93,7 +93,7 @@ func (console *Console) Do(cmd engine.Cmd) string {
default:
w.WinDoUpstream(console, cmd)
}
return engine.OkResult()
return kit.OkResult()
}

func (console *Console) addLine(s string) {
Expand Down
10 changes: 5 additions & 5 deletions tool/riff.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"image"

"github.com/vizicist/palette/engine"
"github.com/vizicist/palette/kit"
w "github.com/vizicist/palette/twinsys"
)

Expand Down Expand Up @@ -41,7 +41,7 @@ func (riff *Riff) Context() *w.WinContext {
}

// Do xxx
func (riff *Riff) Do(cmd engine.Cmd) string {
func (riff *Riff) Do(cmd kit.Cmd) string {

// Things that should be handled the same for all tools?
// "mouse" forwarding downstream
Expand All @@ -60,15 +60,15 @@ func (riff *Riff) Do(cmd engine.Cmd) string {
case "close":
// do anything?
case "getstate":
ret := riff.TextArea.Do(engine.NewSimpleCmd("getstate"))
ret := riff.TextArea.Do(kit.NewSimpleCmd("getstate"))
return ret

case "buttondown":
// Clear is the only button
lbl := cmd.ValuesString("label", "")
switch lbl {
case "Clear":
riff.TextArea.Do(engine.NewSimpleCmd("clear"))
riff.TextArea.Do(kit.NewSimpleCmd("clear"))
default:
riff.addLine(fmt.Sprintf("Unknown button: %s\n", lbl))
}
Expand All @@ -79,7 +79,7 @@ func (riff *Riff) Do(cmd engine.Cmd) string {
default:
w.WinDoUpstream(riff, cmd)
}
return engine.OkResult()
return kit.OkResult()
}

func (riff *Riff) addLine(line string) {
Expand Down
10 changes: 5 additions & 5 deletions twinsys/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package twinsys
import (
"image"

"github.com/vizicist/palette/engine"
"github.com/vizicist/palette/kit"
)

// Button xxx
Expand Down Expand Up @@ -36,11 +36,11 @@ func (button *Button) Context() *WinContext {
}

// Do xxx
func (button *Button) Do(cmd engine.Cmd) string {
func (button *Button) Do(cmd kit.Cmd) string {

switch cmd.Subj {
case "resize":
sz := cmd.ValuesXY("size", engine.PointZero)
sz := cmd.ValuesXY("size", kit.PointZero)
toPoint := image.Point{X: sz.X, Y: sz.Y}
minSize := WinMinSize(button)
if toPoint.X < minSize.X || toPoint.Y < minSize.Y {
Expand Down Expand Up @@ -68,9 +68,9 @@ func (button *Button) Do(cmd engine.Cmd) string {
case "mouse":
currSize := WinGetSize(button)
currRect := image.Rect(0, 0, currSize.X, currSize.Y)
pos := cmd.ValuesPos(engine.PointZero)
pos := cmd.ValuesPos(kit.PointZero)
if !pos.In(currRect) {
engine.LogWarn("button: pos not in Rect?")
kit.LogWarn("button: pos not in Rect?")
break
}
ddu := cmd.ValuesString("ddu", "")
Expand Down
16 changes: 8 additions & 8 deletions twinsys/menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"image/color"
"strings"

"github.com/vizicist/palette/engine"
"github.com/vizicist/palette/kit"
)

// Menu xxx
Expand Down Expand Up @@ -33,7 +33,7 @@ type MenuItem struct {
Label string
posX int
posY int
Cmd engine.Cmd
Cmd kit.Cmd
}

var lastMenuX int
Expand Down Expand Up @@ -155,12 +155,12 @@ func (menu *Menu) redraw() {
}

// If mouseHandler return value is true, the menu should be removed
func (menu *Menu) mouseHandler(cmd engine.Cmd) (removeMenu bool) {
func (menu *Menu) mouseHandler(cmd kit.Cmd) (removeMenu bool) {

parent := WinParent(menu)
menu.itemSelected = -1

pos := cmd.ValuesPos(engine.PointZero)
pos := cmd.ValuesPos(kit.PointZero)
ddu := cmd.ValuesString("ddu", "")
// If it's in the handle area...
if pos.Y <= menu.handleHeight {
Expand Down Expand Up @@ -210,15 +210,15 @@ func (menu *Menu) mouseHandler(cmd engine.Cmd) (removeMenu bool) {
}

// Do xxx
func (menu *Menu) Do(cmd engine.Cmd) string {
func (menu *Menu) Do(cmd kit.Cmd) string {

switch cmd.Subj {

case "close":
engine.LogWarn("menu.Do: close needs work? Maybe not")
kit.LogWarn("menu.Do: close needs work? Maybe not")

case "resize":
size := cmd.ValuesXY("size", engine.PointZero)
size := cmd.ValuesXY("size", kit.PointZero)
menu.resize(size)

case "redraw":
Expand Down Expand Up @@ -246,5 +246,5 @@ func (menu *Menu) Do(cmd engine.Cmd) string {
// }
}
}
return engine.OkResult()
return kit.OkResult()
}
6 changes: 3 additions & 3 deletions twinsys/menus.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package twinsys

import "github.com/vizicist/palette/engine"
import "github.com/vizicist/palette/kit"

// NewPageMenu xxx
func NewPageMenu(parent Window) WindowData {

items := []MenuItem{
{Label: "About", Cmd: engine.NewSimpleCmd("about")},
{Label: "About", Cmd: kit.NewSimpleCmd("about")},
{Label: "Dump", Cmd: NewDumpFileCmd("homepage.json")},
{Label: "Restore", Cmd: NewRestoreFileCmd("homepage.json")},
{Label: "Tools ->", Cmd: NewSubMenuCmd("ToolsMenu")},
Expand All @@ -28,7 +28,7 @@ func NewToolsMenu(parent Window) WindowData {
func NewWindowMenu(parent Window) WindowData {
items := []MenuItem{
{Label: "Resize", Cmd: NewPickToolCmd("resize")},
{Label: "Move", Cmd: engine.NewSimpleCmd("movetool")},
{Label: "Move", Cmd: kit.NewSimpleCmd("movetool")},
{Label: "Delete", Cmd: NewPickToolCmd("delete")},
{Label: "More ->", Cmd: NewSubMenuCmd("ToolsMenu")},
}
Expand Down
Loading

0 comments on commit 889be92

Please sign in to comment.