ci-platforms / darwin arm64 smoke (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 12m19s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / windows amd64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / checks (push) Failing after 23m57s
ci / release (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: failure
GitHub / darwin arm64 native GitHub-hosted native CI: failure
GitHub / darwin amd64 native GitHub-hosted native CI: failure
GitHub / linux amd64 native GitHub-hosted native CI: success
88 lines
2.5 KiB
Go
88 lines
2.5 KiB
Go
package shell
|
|
|
|
import (
|
|
"aego/core/ids"
|
|
"aego/core/mathx"
|
|
"aego/editor/core/command"
|
|
"aego/editor/core/sceneops"
|
|
"aego/editor/core/templates"
|
|
"aego/editor/shell/addpalette"
|
|
"aego/platform/input"
|
|
)
|
|
|
|
func (a *App) wirePalette(sops *sceneops.Ops) {
|
|
a.addPal = addpalette.New(addpalette.Deps{Ctx: a.ctx, Meta: a.inspectors, Templates: a.templates, Root: a.opt.Project.Root, Actions: a.createActions})
|
|
sops.SetCreate(func(parent ids.NodeID, pl templates.Place, at *mathx.Vec2, created func([]ids.NodeID)) {
|
|
a.addPal.CreateNode(parent, pl, at, created)
|
|
})
|
|
}
|
|
|
|
func (a *App) createActions() []addpalette.Action {
|
|
var actions []addpalette.Action
|
|
if a.ctx.Doc() != nil {
|
|
actions = append(actions, a.animActions()...)
|
|
}
|
|
if a.assetsPanel != nil {
|
|
for _, action := range a.assetsPanel.FileCreateActions() {
|
|
actions = append(actions, addpalette.Action{Key: action.Key, Name: action.Name, Category: action.Category, Icon: action.Icon, Doc: action.Doc, Run: action.Run})
|
|
}
|
|
}
|
|
return actions
|
|
}
|
|
|
|
// AddPalette is the Add Component and Create palette, for tests and screenshots.
|
|
func (a *App) AddPalette() *addpalette.Service {
|
|
return a.addPal
|
|
}
|
|
|
|
func (a *App) openAdd(nodes []ids.NodeID, at *mathx.Vec2, query string) {
|
|
if len(a.modals) > 0 || a.search.Active() {
|
|
return
|
|
}
|
|
a.addPal.AddComponent(nodes, at)
|
|
if query != "" {
|
|
a.addPal.Palette().SetQuery(query)
|
|
}
|
|
}
|
|
|
|
func (a *App) registerPalette() error {
|
|
ctx := a.ctx
|
|
hasSel := func() bool { return ctx.Doc() != nil && len(ctx.Selected()) > 0 }
|
|
hasDoc := func() bool { return ctx.Doc() != nil }
|
|
if err := ctx.Commands.Register(command.Desc{
|
|
ID: command.EditAddComponent, Name: "Add Component…", Category: "Edit", Order: 420, Enabled: hasSel,
|
|
Shortcut: command.Key(input.KeyA, command.ModPrimary|command.ModShift),
|
|
Run: func() error {
|
|
a.openAdd(ctx.Selected(), nil, "")
|
|
return nil
|
|
},
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return ctx.Commands.Register(command.Desc{
|
|
ID: command.SceneCreate, Name: "Create…", Category: "Scene", Order: 399, Enabled: hasDoc,
|
|
Shortcut: command.Key(input.KeyN, command.ModPrimary|command.ModShift),
|
|
Run: func() error {
|
|
if len(a.modals) > 0 || a.search.Active() {
|
|
return nil
|
|
}
|
|
parent := ids.NodeID{}
|
|
if it, ok := ctx.Selection.Active(); ok && ctx.Doc() != nil && it.Doc == ctx.Doc().ID {
|
|
parent = it.Node
|
|
}
|
|
a.addPal.CreateNode(parent, templates.Place{}, nil, nil)
|
|
return nil
|
|
},
|
|
})
|
|
}
|
|
|
|
func (a *App) drawPalette() {
|
|
if a.full {
|
|
a.addPal.CloseCreateMenu()
|
|
}
|
|
if len(a.modals) > 0 && a.addPal.Active() {
|
|
a.addPal.Close()
|
|
}
|
|
a.addPal.Draw()
|
|
}
|