2018-08-05 19:54:57 +00:00
|
|
|
package doodle
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"git.kirsle.net/apps/doodle/balance"
|
|
|
|
"git.kirsle.net/apps/doodle/events"
|
|
|
|
"git.kirsle.net/apps/doodle/render"
|
|
|
|
"git.kirsle.net/apps/doodle/ui"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EditorUI manages the user interface for the Editor Scene.
|
|
|
|
type EditorUI struct {
|
2018-08-11 00:19:47 +00:00
|
|
|
d *Doodle
|
|
|
|
Scene *EditorScene
|
2018-08-05 19:54:57 +00:00
|
|
|
|
|
|
|
// Variables
|
2018-08-11 00:19:47 +00:00
|
|
|
StatusMouseText string
|
|
|
|
StatusPaletteText string
|
|
|
|
StatusFilenameText string
|
2018-08-17 03:37:19 +00:00
|
|
|
selectedSwatch string // name of selected swatch in palette
|
2018-08-05 19:54:57 +00:00
|
|
|
|
|
|
|
// Widgets
|
|
|
|
Supervisor *ui.Supervisor
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
MenuBar *ui.Frame
|
2018-08-11 00:19:47 +00:00
|
|
|
Palette *ui.Window
|
2018-08-05 19:54:57 +00:00
|
|
|
StatusBar *ui.Frame
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewEditorUI initializes the Editor UI.
|
2018-08-11 00:19:47 +00:00
|
|
|
func NewEditorUI(d *Doodle, s *EditorScene) *EditorUI {
|
2018-08-05 19:54:57 +00:00
|
|
|
u := &EditorUI{
|
2018-08-11 00:19:47 +00:00
|
|
|
d: d,
|
|
|
|
Scene: s,
|
|
|
|
Supervisor: ui.NewSupervisor(),
|
|
|
|
StatusMouseText: "Cursor: (waiting)",
|
|
|
|
StatusPaletteText: "Swatch: <none>",
|
|
|
|
StatusFilenameText: "Filename: <none>",
|
2018-08-05 19:54:57 +00:00
|
|
|
}
|
2018-08-17 03:37:19 +00:00
|
|
|
|
|
|
|
// Select the first swatch of the palette.
|
|
|
|
if u.Scene.drawing.Palette.ActiveSwatch != nil {
|
|
|
|
u.selectedSwatch = u.Scene.drawing.Palette.ActiveSwatch.Name
|
|
|
|
}
|
|
|
|
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
u.MenuBar = u.SetupMenuBar(d)
|
2018-08-05 19:54:57 +00:00
|
|
|
u.StatusBar = u.SetupStatusBar(d)
|
2018-08-11 00:19:47 +00:00
|
|
|
u.Palette = u.SetupPalette(d)
|
2018-08-05 19:54:57 +00:00
|
|
|
return u
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loop to process events and update the UI.
|
|
|
|
func (u *EditorUI) Loop(ev *events.State) {
|
2018-08-11 00:19:47 +00:00
|
|
|
u.Supervisor.Loop(ev)
|
|
|
|
|
2018-08-05 19:54:57 +00:00
|
|
|
u.StatusMouseText = fmt.Sprintf("Mouse: (%d,%d)",
|
|
|
|
ev.CursorX.Now,
|
|
|
|
ev.CursorY.Now,
|
|
|
|
)
|
2018-08-11 00:19:47 +00:00
|
|
|
u.StatusPaletteText = fmt.Sprintf("Swatch: %s",
|
2018-08-17 03:37:19 +00:00
|
|
|
u.Scene.drawing.Palette.ActiveSwatch,
|
2018-08-11 00:19:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Statusbar filename label.
|
|
|
|
filename := "untitled.map"
|
|
|
|
if u.Scene.filename != "" {
|
|
|
|
filename = u.Scene.filename
|
|
|
|
}
|
|
|
|
u.StatusFilenameText = fmt.Sprintf("Filename: %s",
|
|
|
|
filename,
|
|
|
|
)
|
|
|
|
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
u.MenuBar.Compute(u.d.Engine)
|
2018-08-05 19:54:57 +00:00
|
|
|
u.StatusBar.Compute(u.d.Engine)
|
2018-08-11 00:19:47 +00:00
|
|
|
u.Palette.Compute(u.d.Engine)
|
2018-08-05 19:54:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Present the UI to the screen.
|
|
|
|
func (u *EditorUI) Present(e render.Engine) {
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
// TODO: if I don't Compute() the palette window, then, whenever the dev console
|
|
|
|
// is open the window will blank out its contents leaving only the outermost Frame.
|
|
|
|
// The title bar and borders are gone. But other UI widgets don't do this.
|
|
|
|
// FIXME: Scene interface should have a separate ComputeUI() from Loop()?
|
|
|
|
u.Palette.Compute(u.d.Engine)
|
|
|
|
|
2018-08-11 00:19:47 +00:00
|
|
|
u.Palette.Present(e, u.Palette.Point())
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
u.MenuBar.Present(e, u.MenuBar.Point())
|
2018-08-05 19:54:57 +00:00
|
|
|
u.StatusBar.Present(e, u.StatusBar.Point())
|
|
|
|
}
|
|
|
|
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
// SetupMenuBar sets up the menu bar.
|
|
|
|
func (u *EditorUI) SetupMenuBar(d *Doodle) *ui.Frame {
|
|
|
|
frame := ui.NewFrame("MenuBar")
|
|
|
|
frame.Configure(ui.Config{
|
|
|
|
Width: d.width,
|
|
|
|
Background: render.Black,
|
|
|
|
})
|
|
|
|
|
|
|
|
type menuButton struct {
|
|
|
|
Text string
|
|
|
|
Click func(render.Point)
|
|
|
|
}
|
|
|
|
buttons := []menuButton{
|
|
|
|
menuButton{
|
|
|
|
Text: "New Level",
|
|
|
|
Click: func(render.Point) {
|
|
|
|
d.NewMap()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
menuButton{
|
|
|
|
Text: "New Doodad",
|
|
|
|
Click: func(render.Point) {
|
|
|
|
d.NewMap()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
menuButton{
|
|
|
|
Text: "Save",
|
|
|
|
Click: func(render.Point) {
|
|
|
|
if u.Scene.filename != "" {
|
|
|
|
u.Scene.SaveLevel(u.Scene.filename)
|
|
|
|
d.Flash("Saved: %s", u.Scene.filename)
|
|
|
|
} else {
|
|
|
|
d.Prompt("Save filename>", func(answer string) {
|
|
|
|
if answer != "" {
|
|
|
|
u.Scene.SaveLevel("./maps/" + answer) // TODO: maps path
|
|
|
|
d.Flash("Saved: %s", answer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
menuButton{
|
|
|
|
Text: "Save as...",
|
|
|
|
Click: func(render.Point) {
|
|
|
|
d.Prompt("Save as filename>", func(answer string) {
|
|
|
|
if answer != "" {
|
|
|
|
u.Scene.SaveLevel("./maps/" + answer) // TODO: maps path
|
|
|
|
d.Flash("Saved: %s", answer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
menuButton{
|
|
|
|
Text: "Load",
|
|
|
|
Click: func(render.Point) {
|
|
|
|
d.Prompt("Open filename>", func(answer string) {
|
|
|
|
if answer != "" {
|
|
|
|
u.d.EditLevel("./maps/" + answer) // TODO: maps path
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, btn := range buttons {
|
|
|
|
w := ui.NewButton(btn.Text, ui.NewLabel(ui.Label{
|
|
|
|
Text: btn.Text,
|
|
|
|
Font: balance.MenuFont,
|
|
|
|
}))
|
|
|
|
w.Configure(ui.Config{
|
|
|
|
BorderSize: 1,
|
|
|
|
OutlineSize: 0,
|
|
|
|
})
|
2018-08-17 03:37:19 +00:00
|
|
|
w.Handle(ui.MouseUp, btn.Click)
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
u.Supervisor.Add(w)
|
|
|
|
frame.Pack(w, ui.Pack{
|
|
|
|
Anchor: ui.W,
|
|
|
|
PadX: 1,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
frame.Compute(d.Engine)
|
|
|
|
return frame
|
|
|
|
}
|
|
|
|
|
2018-08-11 00:19:47 +00:00
|
|
|
// SetupPalette sets up the palette panel.
|
|
|
|
func (u *EditorUI) SetupPalette(d *Doodle) *ui.Window {
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
log.Error("SetupPalette Window")
|
2018-08-11 00:19:47 +00:00
|
|
|
window := ui.NewWindow("Palette")
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
window.ConfigureTitle(balance.TitleConfig)
|
|
|
|
window.TitleBar().Font = balance.TitleFont
|
2018-08-11 00:19:47 +00:00
|
|
|
window.Configure(ui.Config{
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
Width: 150,
|
|
|
|
Height: u.d.height - u.StatusBar.Size().H,
|
|
|
|
Background: balance.WindowBackground,
|
|
|
|
BorderColor: balance.WindowBorder,
|
2018-08-11 00:19:47 +00:00
|
|
|
})
|
|
|
|
window.MoveTo(render.NewPoint(
|
|
|
|
u.d.width-window.BoxSize().W,
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
u.MenuBar.BoxSize().H,
|
2018-08-11 00:19:47 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
// Handler function for the radio buttons being clicked.
|
|
|
|
onClick := func(p render.Point) {
|
2018-08-17 03:37:19 +00:00
|
|
|
name := u.selectedSwatch
|
|
|
|
swatch, ok := u.Scene.drawing.Palette.Get(name)
|
2018-08-11 00:19:47 +00:00
|
|
|
if !ok {
|
|
|
|
log.Error("Palette onClick: couldn't get swatch named '%s' from palette", name)
|
|
|
|
return
|
|
|
|
}
|
2018-08-17 03:37:19 +00:00
|
|
|
log.Info("Set swatch: %s", swatch)
|
|
|
|
u.Scene.drawing.SetSwatch(swatch)
|
2018-08-11 00:19:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the radio buttons for the palette.
|
2018-08-17 03:37:19 +00:00
|
|
|
for _, swatch := range u.Scene.drawing.Palette.Swatches {
|
2018-08-11 00:19:47 +00:00
|
|
|
label := ui.NewLabel(ui.Label{
|
|
|
|
Text: swatch.Name,
|
|
|
|
Font: balance.StatusFont,
|
|
|
|
})
|
|
|
|
label.Font.Color = swatch.Color.Darken(40)
|
|
|
|
|
2018-08-17 03:37:19 +00:00
|
|
|
btn := ui.NewRadioButton("palette", &u.selectedSwatch, swatch.Name, label)
|
|
|
|
btn.Handle(ui.Click, onClick)
|
2018-08-11 00:19:47 +00:00
|
|
|
u.Supervisor.Add(btn)
|
|
|
|
|
|
|
|
window.Pack(btn, ui.Pack{
|
|
|
|
Anchor: ui.N,
|
|
|
|
Fill: true,
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
PadY: 4,
|
2018-08-11 00:19:47 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return window
|
|
|
|
}
|
|
|
|
|
2018-08-05 19:54:57 +00:00
|
|
|
// SetupStatusBar sets up the status bar widget along the bottom of the window.
|
|
|
|
func (u *EditorUI) SetupStatusBar(d *Doodle) *ui.Frame {
|
|
|
|
frame := ui.NewFrame("Status Bar")
|
|
|
|
frame.Configure(ui.Config{
|
|
|
|
BorderStyle: ui.BorderRaised,
|
|
|
|
Background: render.Grey,
|
|
|
|
BorderSize: 2,
|
|
|
|
Width: d.width,
|
|
|
|
})
|
|
|
|
|
2018-08-11 00:19:47 +00:00
|
|
|
style := ui.Config{
|
2018-08-05 19:54:57 +00:00
|
|
|
Background: render.Grey,
|
|
|
|
BorderStyle: ui.BorderSunken,
|
|
|
|
BorderColor: render.Grey,
|
|
|
|
BorderSize: 1,
|
2018-08-11 00:19:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cursorLabel := ui.NewLabel(ui.Label{
|
|
|
|
TextVariable: &u.StatusMouseText,
|
|
|
|
Font: balance.StatusFont,
|
2018-08-05 19:54:57 +00:00
|
|
|
})
|
2018-08-11 00:19:47 +00:00
|
|
|
cursorLabel.Configure(style)
|
2018-08-05 19:54:57 +00:00
|
|
|
cursorLabel.Compute(d.Engine)
|
|
|
|
frame.Pack(cursorLabel, ui.Pack{
|
|
|
|
Anchor: ui.W,
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
PadX: 1,
|
2018-08-05 19:54:57 +00:00
|
|
|
})
|
|
|
|
|
2018-08-11 00:19:47 +00:00
|
|
|
paletteLabel := ui.NewLabel(ui.Label{
|
|
|
|
TextVariable: &u.StatusPaletteText,
|
|
|
|
Font: balance.StatusFont,
|
2018-08-05 19:54:57 +00:00
|
|
|
})
|
2018-08-11 00:19:47 +00:00
|
|
|
paletteLabel.Configure(style)
|
|
|
|
paletteLabel.Compute(d.Engine)
|
|
|
|
frame.Pack(paletteLabel, ui.Pack{
|
|
|
|
Anchor: ui.W,
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
PadX: 1,
|
2018-08-05 19:54:57 +00:00
|
|
|
})
|
2018-08-11 00:19:47 +00:00
|
|
|
|
|
|
|
filenameLabel := ui.NewLabel(ui.Label{
|
|
|
|
TextVariable: &u.StatusFilenameText,
|
|
|
|
Font: balance.StatusFont,
|
|
|
|
})
|
|
|
|
filenameLabel.Configure(style)
|
2018-08-05 19:54:57 +00:00
|
|
|
filenameLabel.Compute(d.Engine)
|
|
|
|
frame.Pack(filenameLabel, ui.Pack{
|
|
|
|
Anchor: ui.W,
|
Menu Toolbar for Editor + Shell Prompts + Theme
* Added a "menu toolbar" to the top of the Edit Mode with useful buttons
that work: New Level, New Doodad (same thing), Save, Save as, Open.
* Added ability for the dev console to prompt the user for a question,
which opens the console automatically. "Save", "Save as" and "Load"
ask for their filenames this way.
* Started groundwork for theming the app. The palette window is a light
brown with an orange title bar, the Menu Toolbar has a black
background, etc.
* Added support for multiple fonts instead of just monospace. DejaVu
Sans (normal and bold) are used now for most labels and window titles,
respectively. The dev console uses DejaVu Sans Mono as before.
* Update ui.Label to accept PadX and PadY separately instead of only
having the Padding option which did both.
* Improvements to Frame packing algorithm.
* Set the SDL draw mode to BLEND so we can use alpha colors properly,
so now the dev console is semi-translucent.
2018-08-12 00:30:00 +00:00
|
|
|
PadX: 1,
|
2018-08-05 19:54:57 +00:00
|
|
|
})
|
|
|
|
|
2018-08-11 00:19:47 +00:00
|
|
|
// TODO: right-aligned labels clip out of bounds
|
|
|
|
// extraLabel := ui.NewLabel(ui.Label{
|
|
|
|
// Text: "blah",
|
|
|
|
// Font: balance.StatusFont,
|
|
|
|
// })
|
|
|
|
// extraLabel.Configure(ui.Config{
|
|
|
|
// Background: render.Grey,
|
|
|
|
// BorderStyle: ui.BorderSunken,
|
|
|
|
// BorderColor: render.Grey,
|
|
|
|
// BorderSize: 1,
|
|
|
|
// })
|
|
|
|
// extraLabel.Compute(d.Engine)
|
|
|
|
// frame.Pack(extraLabel, ui.Pack{
|
|
|
|
// Anchor: ui.E,
|
|
|
|
// })
|
2018-08-05 19:54:57 +00:00
|
|
|
|
|
|
|
frame.Resize(render.Rect{
|
|
|
|
W: d.width,
|
|
|
|
H: cursorLabel.BoxSize().H + frame.BoxThickness(1),
|
|
|
|
})
|
|
|
|
frame.Compute(d.Engine)
|
|
|
|
frame.MoveTo(render.Point{
|
|
|
|
X: 0,
|
|
|
|
Y: d.height - frame.Size().H,
|
|
|
|
})
|
|
|
|
|
|
|
|
return frame
|
|
|
|
}
|