Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/editor/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import (
"kaijuengine.com/matrix"
"kaijuengine.com/platform/hid"
"kaijuengine.com/platform/profiler/tracing"
"kaijuengine.com/platform/windowing"
"kaijuengine.com/rendering"

// Built-in workspace packages register themselves with
Expand Down Expand Up @@ -109,6 +110,8 @@ type Editor struct {
contentPreviewer content_previews.ContentPreviewer
updateId engine.UpdateId
blurred bool
cursorUI ui.Manager
cursor *ui.Cursor
}

type globalUI struct {
Expand Down Expand Up @@ -160,6 +163,28 @@ func (ed *Editor) IsInputFocused() bool {
return ed.currentWorkspace.IsFocusedOnInput()
}

func (ed *Editor) ensureCursor() {
if ed.cursor != nil {
return
}

ed.cursorUI.Init(ed.host)

ed.cursor = ed.cursorUI.Add().ToCursor()
ed.cursor.Init(ui.CursorThemeByName(ed.settings.CursorTheme))
}

func cursorModeFromSetting(mode string) windowing.CursorMode {
switch mode {
case "virtual":
return windowing.CursorModeVirtual
case "auto":
return windowing.CursorModeAuto
default:
return windowing.CursorModeNative
}
}

func (ed *Editor) earlyLoadUI() {
defer tracing.NewRegion("Editor.earlyLoadUI").End()
ed.globalInterfaces.menuBar.Initialize(ed.host, ed)
Expand All @@ -172,6 +197,14 @@ func (ed *Editor) UpdateSettings() {
ed.settings.UIScrollSpeed = 1
}
ui.UIScrollSpeed = ed.settings.UIScrollSpeed

ed.ensureCursor()
ed.cursor.SetTheme(ui.CursorThemeByName(ed.settings.CursorTheme))

ed.host.Window.ResetCursor()
ed.host.Window.SetCursorMode(cursorModeFromSetting(ed.settings.CursorMode))
ed.cursor.SyncWithWindow()

if err := ed.settings.Save(); err != nil {
slog.Error("failed to save the editor settings", "error", err)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,28 @@ <h3>{{.Name}}</h3>
.workspaceRequired { color: #cc6; margin-right: 1em; }
.workspaceToggle { margin-right: 0.5em; }
.workspaceMoveBtn { margin-left: 0.25em; }
.cursorAutoTestGrid {
width: 100%;
margin-top: 1em;
}
.cursorAutoTestBox {
width: 150px;
height: 34px;
margin: 4px;
padding: 8px;
background-color: #313232;
color: white;
border: 1px solid #575757;
}
.cursorAutoDefault { cursor: default; }
.cursorAutoPointer { cursor: pointer; }
.cursorAutoText { cursor: text; }
.cursorAutoWait { cursor: wait; }
.cursorAutoProgress { cursor: progress; }
.cursorAutoResizeNWSE { cursor: nwse-resize; }
.cursorAutoResizeNESW { cursor: nesw-resize; }
.cursorAutoZoomIn { cursor: zoom-in; }
.cursorAutoZoomOut { cursor: zoom-out; }


.gitDownloadRow {
Expand Down Expand Up @@ -226,6 +248,18 @@ <h1>Project Settings</h1>
<div id="editorSettingsBox" class="settingsBox">
<h1>Editor Settings</h1>
{{template "section" .Editor}}
<h2>Cursor Auto Test</h2>
<div class="cursorAutoTestGrid">
<div class="cursorAutoTestBox cursorAutoDefault">default</div>
<div class="cursorAutoTestBox cursorAutoPointer">pointer</div>
<div class="cursorAutoTestBox cursorAutoText">text</div>
<div class="cursorAutoTestBox cursorAutoWait">wait</div>
<div class="cursorAutoTestBox cursorAutoProgress">progress</div>
<div class="cursorAutoTestBox cursorAutoResizeNWSE">nwse-resize</div>
<div class="cursorAutoTestBox cursorAutoResizeNESW">nesw-resize</div>
<div class="cursorAutoTestBox cursorAutoZoomIn">zoom-in</div>
<div class="cursorAutoTestBox cursorAutoZoomOut">zoom-out</div>
</div>
</div>
<div id="workspaceSettingsBox" class="settingsBox">
<h1>Workspaces</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


Cursor Pack (1.1)

Created/distributed by Kenney (www.kenney.nl)
Creation date: 05-06-2024

------------------------------

License: (Creative Commons Zero, CC0)
http://creativecommons.org/publicdomain/zero/1.0/

This content is free to use in personal, educational and commercial projects.
Support us by crediting Kenney or www.kenney.nl (this is not mandatory)

------------------------------

Donate: http://support.kenney.nl
Patreon: http://patreon.com/kenney/

Follow on Twitter for updates:
http://twitter.com/KenneyNL
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"kaijuengine.com/engine/ui/markup/document"
"kaijuengine.com/matrix"
"kaijuengine.com/platform/profiler/tracing"
"kaijuengine.com/platform/windowing"
)

type ColorPicker struct {
Expand Down Expand Up @@ -123,7 +124,7 @@ func Show(host *engine.Host, config Config) (*ColorPicker, error) {
func (p *ColorPicker) Close() {
defer tracing.NewRegion("ColorPicker.Close").End()
host := p.uiMan.Host
host.Window.CursorStandard()
host.Window.SetCursor(windowing.CursorKindDefault)
p.doc.Destroy()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"kaijuengine.com/engine/ui/markup/document"
"kaijuengine.com/platform/hid"
"kaijuengine.com/platform/profiler/tracing"
"kaijuengine.com/platform/windowing"
)

type ContentSelector struct {
Expand Down Expand Up @@ -126,7 +127,7 @@ func (o *ContentSelector) Close() {
}

func (o *ContentSelector) closeInternal() {
o.uiMan.Host.Window.CursorStandard()
o.uiMan.Host.Window.SetCursor(windowing.CursorKindDefault)
o.doc.Destroy()
o.uiMan.Host.Window.Keyboard.RemoveKeyCallback(o.keyKb)
}
Expand Down
4 changes: 4 additions & 0 deletions src/editor/editor_settings/editor_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Settings struct {
MeshEditor string
AudioEditor string
UIScrollSpeed float32 `default:"20" label:"UI Scroll Speed"`
CursorMode string `default:"virtual" label:"Cursor Mode"`
CursorTheme string `default:"kenney" label:"Cursor Theme"`
ShowGrid bool `default:"true" label:"Show Viewport Grid"`
EditorCamera EditorCameraSettings
Snapping SnapSettings
Expand Down Expand Up @@ -110,6 +112,8 @@ func (s *Settings) setDefaults() {
s.RefreshRate = 60
s.CodeEditor = "code"
s.UIScrollSpeed = 20
s.CursorMode = "virtual"
s.CursorTheme = "kenney"
s.ShowGrid = true
s.EditorCamera.ZoomSpeed = 120
s.EditorCamera.FlySpeed = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ type editorWorkspaceController interface {

type SettingsWorkspace struct {
common_workspace.CommonWorkspace
projectSettingsBox *document.Element
editorSettingsBox *document.Element
pluginSettingsBox *document.Element
projectSettingsBox *document.Element
editorSettingsBox *document.Element
pluginSettingsBox *document.Element
workspaceSettingsBox *document.Element
editor editor_workspace.WorkspaceEditorInterface
editorSettings *editor_settings.Settings
projectSettings *project.Settings
plugins []editor_plugin.PluginInfo
pluginInitStates []bool
reloadRequested bool
recompiling bool
downloadingPlugin bool
editor editor_workspace.WorkspaceEditorInterface
editorSettings *editor_settings.Settings
projectSettings *project.Settings
plugins []editor_plugin.PluginInfo
pluginInitStates []bool
reloadRequested bool
recompiling bool
downloadingPlugin bool
}

// workspaceRowData is the per-row data the Workspaces panel template loops over.
Expand Down Expand Up @@ -301,6 +301,7 @@ func (w *SettingsWorkspace) valueChanged(e *document.Element) {
defer tracing.NewRegion("SettingsWorkspace.valueChanged").End()
if w.editorSettingsBox.UI.Entity().IsActive() {
common_workspace.SetObjectValueFromUI(w.editorSettings, e)
w.editor.UpdateSettings()
} else if w.projectSettingsBox.UI.Entity().IsActive() {
common_workspace.SetObjectValueFromUI(w.projectSettings, e)
}
Expand Down Expand Up @@ -501,7 +502,16 @@ func (w *SettingsWorkspace) uiData() settingsWorkspaceData {
for i := range w.plugins {
w.pluginInitStates[i] = w.plugins[i].Config.Enabled
}
listings := map[string][]ui.SelectOption{}
listings := map[string][]ui.SelectOption{
"CursorMode": {
{Name: "Native", Value: "native"},
{Name: "Virtual", Value: "virtual"},
{Name: "Auto", Value: "auto"},
},
"CursorTheme": {
{Name: "Kenney", Value: "kenney"},
},
}
cache := w.editor.Project().CacheDatabase()
return settingsWorkspaceData{
Editor: common_workspace.ReflectUIStructure(cache,
Expand Down
Loading
Loading