Compare commits
No commits in common. "d5d9f3abfbcbf15271de354072766fda7728991b" and "2db501e66ce56cada428079d1bd00edbe0602fa6" have entirely different histories.
d5d9f3abfb
...
2db501e66c
@ -2,7 +2,6 @@ package nasin
|
|||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
import "image"
|
import "image"
|
||||||
import "strings"
|
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import "git.tebibyte.media/tomo/nasin/internal/registrar"
|
import "git.tebibyte.media/tomo/nasin/internal/registrar"
|
||||||
|
|
||||||
@ -77,15 +76,6 @@ type ApplicationRole string; const (
|
|||||||
RoleChecklist ApplicationRole = "Checklist"
|
RoleChecklist ApplicationRole = "Checklist"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Icon returns the icon ID for this role.
|
|
||||||
func (role ApplicationRole) Icon () tomo.Icon {
|
|
||||||
if role == "" {
|
|
||||||
return tomo.IconApplication
|
|
||||||
} else {
|
|
||||||
return tomo.Icon("Application" + strings.ReplaceAll(string(role), " ", ""))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RunApplication is like tomo.Run, but runs an application. If something fails
|
// RunApplication is like tomo.Run, but runs an application. If something fails
|
||||||
// to initialize, an error is written to the standard logger.
|
// to initialize, an error is written to the standard logger.
|
||||||
func RunApplication (application Application) {
|
func RunApplication (application Application) {
|
||||||
@ -100,37 +90,10 @@ func RunApplication (application Application) {
|
|||||||
|
|
||||||
// NewApplicationWindow creates a window for an application. It will
|
// NewApplicationWindow creates a window for an application. It will
|
||||||
// automatically set window information to signal to the OS that the window is
|
// automatically set window information to signal to the OS that the window is
|
||||||
// owned by the application. The window's icon will be automatically set by
|
// owned by the application.
|
||||||
// looking for an icon with the name of the application's ID. If that is not
|
|
||||||
// found, the default icon for the application's ApplicationRole will used.
|
|
||||||
func NewApplicationWindow (application Application, bounds image.Rectangle) (tomo.MainWindow, error) {
|
func NewApplicationWindow (application Application, bounds image.Rectangle) (tomo.MainWindow, error) {
|
||||||
window, err := tomo.NewWindow(bounds)
|
window, err := tomo.NewWindow(bounds)
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
description := application.Describe()
|
window.SetTitle(application.Describe().String())
|
||||||
window.SetTitle(description.Name)
|
|
||||||
setApplicationWindowIcon(window, description)
|
|
||||||
return window, nil
|
return window, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setApplicationWindowIcon (window tomo.Window, description ApplicationDescription) {
|
|
||||||
allSizes := func (icon tomo.Icon) (sizes []image.Image) {
|
|
||||||
small := icon.Texture(tomo.IconSizeSmall)
|
|
||||||
medium := icon.Texture(tomo.IconSizeMedium)
|
|
||||||
large := icon.Texture(tomo.IconSizeLarge)
|
|
||||||
if small != nil { sizes = append(sizes, small) }
|
|
||||||
if medium != nil { sizes = append(sizes, medium) }
|
|
||||||
if large != nil { sizes = append(sizes, large) }
|
|
||||||
return sizes
|
|
||||||
}
|
|
||||||
|
|
||||||
if sizes := allSizes(tomo.Icon(description.ID)); len(sizes) > 0 {
|
|
||||||
println("direct icon worked", tomo.Icon(description.ID))
|
|
||||||
window.SetIcon(sizes...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if sizes := allSizes(description.Role.Icon()); len(sizes) > 0 {
|
|
||||||
println("role icon worked", description.Role.Icon())
|
|
||||||
window.SetIcon(sizes...)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -10,8 +10,8 @@ func New () *dataTheme.Theme {
|
|||||||
Colors: map[tomo.Color] color.Color {
|
Colors: map[tomo.Color] color.Color {
|
||||||
tomo.ColorBackground: colorBackground,
|
tomo.ColorBackground: colorBackground,
|
||||||
tomo.ColorForeground: colorForeground,
|
tomo.ColorForeground: colorForeground,
|
||||||
tomo.ColorRaised: colorRaised,
|
tomo.ColorRaised: colorCarved,
|
||||||
tomo.ColorSunken: colorSunken,
|
tomo.ColorSunken: colorCarved,
|
||||||
tomo.ColorAccent: colorFocus,
|
tomo.ColorAccent: colorFocus,
|
||||||
},
|
},
|
||||||
Rules: rules,
|
Rules: rules,
|
||||||
|
@ -26,19 +26,15 @@ func border (top, right, bottom, left uint32, width ...int) tomo.Border {
|
|||||||
var colorDot = hex(0x7391c080)
|
var colorDot = hex(0x7391c080)
|
||||||
var colorFocus = hex(0x5f8bc4FF)
|
var colorFocus = hex(0x5f8bc4FF)
|
||||||
var colorHighlight = hex(0x5f8bc4FF)
|
var colorHighlight = hex(0x5f8bc4FF)
|
||||||
var colorBackground = hex(0xd4d4d4FF)
|
var colorBackground = hex(0xd6d6d6FF)
|
||||||
var colorForeground = color.Black
|
var colorForeground = color.Black
|
||||||
|
|
||||||
var colorOutline = color.Black
|
var colorOutline = color.Black
|
||||||
var colorGutter = hex(0xbfc6d1FF)
|
var colorGutter = hex(0xbfc6d1FF)
|
||||||
var colorGutterHovered = hex(0xc5cbd6FF)
|
var colorGutterHovered = hex(0xc5cbd6FF)
|
||||||
var colorRaised = hex(0xe9eaeaFF)
|
var colorCarved = hex(0xe9eaeaFF)
|
||||||
var colorRaisedPressed = hex(0xccd4ddFF)
|
var colorCarvedPressed = hex(0xe3e4e4FF)
|
||||||
var colorRaisedFocused = hex(0xcfd6ddFF)
|
var colorCarvedFocused = hex(0xe4e6e8FF)
|
||||||
var colorRaisedHovered = hex(0xf1f3f5FF)
|
var colorCarvedHovered = hex(0xf1f3f5FF)
|
||||||
var colorSunken = hex(0xe9eaeaFF)
|
|
||||||
var colorSunkenFocused = hex(0xe0e6eeFF)
|
|
||||||
var colorSunkenPressed = hex(0xe0e6eeFF)
|
|
||||||
|
|
||||||
var outline = tomo.Border {
|
var outline = tomo.Border {
|
||||||
Width: tomo.I(1),
|
Width: tomo.I(1),
|
||||||
@ -50,13 +46,12 @@ var outline = tomo.Border {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var borderEngraved = border(0xc3c3c5FF, 0xe3e3e3FF, 0xe9e9e9ff, 0xc2c2c2ff, 1)
|
var borderEngraved = border(0xc3c3c5FF, 0xe3e3e3FF, 0xe9e9e9ff, 0xc2c2c2ff, 1)
|
||||||
var borderGap = border(0x697c7cFF, 0x566767FF, 0x566767ff, 0x697c7cff, 1)
|
var borderGap = border(0x697c7cFF, 0x566767FF, 0x566767ff, 0x697c7cff, 1)
|
||||||
var borderLifted = border(0xf9fafcFF, 0xc2c8d3FF, 0xa4afc0ff, 0xf5f6f8ff, 1)
|
var borderLifted = border(0xf9fafcFF, 0xc2c8d3FF, 0xa4afc0ff, 0xf5f6f8ff, 1)
|
||||||
var borderLiftedFocused = border(0xf0f4f9FF, 0xb1bacaFF, 0x9aa6b7ff, 0xe4e9eeff, 1)
|
var borderFocused = border(0x5f8bc4FF, 0x5f8bc4FF, 0x5f8bc4ff, 0x5f8bc4ff, 1)
|
||||||
var borderFocused = border(0x5f8bc4FF, 0x5f8bc4FF, 0x5f8bc4ff, 0x5f8bc4ff, 1)
|
var borderInnerShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 1, 0, 0, 1)
|
||||||
var borderInnerShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 1, 0, 0, 1)
|
var borderOuterShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 0, 1, 1, 0)
|
||||||
var borderOuterShadow = border(0xa4afc0FF, 0xa4afc0FF, 0xa4afc0ff, 0xa4afc0ff, 0, 1, 1, 0)
|
|
||||||
|
|
||||||
var rules = []dataTheme.Rule {
|
var rules = []dataTheme.Rule {
|
||||||
// *.*[*]
|
// *.*[*]
|
||||||
@ -88,19 +83,19 @@ var rules = []dataTheme.Rule {
|
|||||||
borderInnerShadow,
|
borderInnerShadow,
|
||||||
},
|
},
|
||||||
dataTheme.AttrPadding(tomo.I(5, 8, 4, 9)),
|
dataTheme.AttrPadding(tomo.I(5, 8, 4, 9)),
|
||||||
dataTheme.AttrColor { Color: colorRaisedPressed },
|
dataTheme.AttrColor { Color: colorCarvedPressed },
|
||||||
),
|
),
|
||||||
Focused: dataTheme.AS (
|
Focused: dataTheme.AS (
|
||||||
dataTheme.AttrBorder {
|
dataTheme.AttrBorder {
|
||||||
borderEngraved,
|
borderEngraved,
|
||||||
borderGap,
|
borderFocused,
|
||||||
borderLiftedFocused,
|
borderLifted,
|
||||||
},
|
},
|
||||||
dataTheme.AttrPadding(tomo.I(4, 8)),
|
dataTheme.AttrPadding(tomo.I(4, 8)),
|
||||||
dataTheme.AttrColor { Color: colorRaisedFocused },
|
dataTheme.AttrColor { Color: colorCarvedFocused },
|
||||||
),
|
),
|
||||||
Hovered: dataTheme.AS (
|
Hovered: dataTheme.AS (
|
||||||
dataTheme.AttrColor { Color: colorRaisedHovered },
|
dataTheme.AttrColor { Color: colorCarvedHovered },
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -122,10 +117,6 @@ var rules = []dataTheme.Rule {
|
|||||||
borderFocused,
|
borderFocused,
|
||||||
borderInnerShadow,
|
borderInnerShadow,
|
||||||
},
|
},
|
||||||
dataTheme.AttrColor { Color: colorSunkenFocused },
|
|
||||||
),
|
|
||||||
Pressed: dataTheme.AS (
|
|
||||||
dataTheme.AttrColor { Color: colorSunkenPressed },
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -274,7 +265,6 @@ var rules = []dataTheme.Rule {
|
|||||||
borderInnerShadow,
|
borderInnerShadow,
|
||||||
},
|
},
|
||||||
dataTheme.AttrPadding(tomo.I(0)),
|
dataTheme.AttrPadding(tomo.I(0)),
|
||||||
dataTheme.AttrColor { Color: colorSunkenFocused },
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user