Default elements compile
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package theme
|
||||
|
||||
import "image"
|
||||
import "image/color"
|
||||
import "golang.org/x/image/font"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||
@@ -32,18 +33,9 @@ func (Default) Icon (string, IconSize, Case) canvas.Image {
|
||||
|
||||
// Pattern returns a pattern from the default theme corresponding to the given
|
||||
// pattern ID.
|
||||
func (Default) Pattern (
|
||||
pattern Pattern,
|
||||
state PatternState,
|
||||
c Case,
|
||||
) artist.Pattern {
|
||||
switch pattern {
|
||||
case PatternAccent:
|
||||
return patterns.Uhex(0xFF8800FF)
|
||||
case PatternBackground:
|
||||
return patterns.Uhex(0x000000FF)
|
||||
case PatternForeground:
|
||||
return patterns.Uhex(0xFFFFFFFF)
|
||||
func (Default) Pattern (id Pattern, state State, c Case) artist.Pattern {
|
||||
switch id {
|
||||
case PatternBackground: return patterns.Uhex(0x000000FF)
|
||||
// case PatternDead:
|
||||
// case PatternRaised:
|
||||
// case PatternSunken:
|
||||
@@ -56,6 +48,14 @@ func (Default) Pattern (
|
||||
}
|
||||
}
|
||||
|
||||
func (Default) Color (id Color, state State, c Case) color.RGBA {
|
||||
switch id {
|
||||
case ColorAccent: return artist.Hex(0xFF8800FF)
|
||||
case ColorForeground: return artist.Hex(0xFFFFFFFF)
|
||||
default: return artist.Hex(0x888888FF)
|
||||
}
|
||||
}
|
||||
|
||||
// Padding returns the default padding value for the given pattern.
|
||||
func (Default) Padding (pattern Pattern, c Case) artist.Inset {
|
||||
return artist.Inset { 4, 4, 4, 4}
|
||||
|
||||
@@ -8,7 +8,7 @@ package theme
|
||||
// specific elements.
|
||||
type Case struct { Namespace, Element string }
|
||||
|
||||
// C can be used as shorthand to generate a case struct as used in PatternState.
|
||||
// C can be used as shorthand to generate a case struct as used in State.
|
||||
func C (namespace, element string) (c Case) {
|
||||
return Case {
|
||||
Namespace: namespace,
|
||||
@@ -16,14 +16,14 @@ func C (namespace, element string) (c Case) {
|
||||
}
|
||||
}
|
||||
|
||||
// PatternState lists parameters which can change the appearance of some
|
||||
// patterns. For example, passing a PatternState with Selected set to true may
|
||||
// result in a pattern that has a colored border within it.
|
||||
type PatternState struct {
|
||||
// State lists parameters which can change the appearance of some patterns and
|
||||
// colors. For example, passing a State with Selected set to true may result in
|
||||
// a pattern that has a colored border within it.
|
||||
type State struct {
|
||||
// On should be set to true if the element that is using this pattern is
|
||||
// in some sort of "on" state, such as if a checkbox is checked or a
|
||||
// switch is toggled on. This is only necessary if the element in
|
||||
// question is capable of being toggled.
|
||||
// in some sort of selected or "on" state, such as if a checkbox is
|
||||
// checked or a switch is toggled on. This is only necessary if the
|
||||
// element in question is capable of being toggled or selected.
|
||||
On bool
|
||||
|
||||
// Focused should be set to true if the element that is using this
|
||||
|
||||
@@ -18,17 +18,9 @@ const (
|
||||
// This allows custom elements to follow themes, even those that do not
|
||||
// explicitly support them.
|
||||
type Pattern int; const (
|
||||
// PatternAccent is the accent color of the theme. It is safe to assume
|
||||
// that this is, by default, a solid color.
|
||||
PatternAccent Pattern = iota
|
||||
|
||||
// PatternBackground is the background color of the theme. It is safe to
|
||||
// assume that this is, by default, a solid color.
|
||||
PatternBackground
|
||||
|
||||
// PatternForeground is the foreground text color of the theme. It is
|
||||
// safe to assume that this is, by default, a solid color.
|
||||
PatternForeground
|
||||
// PatternBackground is the window background of the theme. It appears
|
||||
// in things like containers and behind text.
|
||||
PatternBackground Pattern = iota
|
||||
|
||||
// PatternDead is a pattern that is displayed on a "dead area" where no
|
||||
// controls exist, but there still must be some indication of visual
|
||||
@@ -57,6 +49,14 @@ type Pattern int; const (
|
||||
PatternHandle
|
||||
)
|
||||
|
||||
type Color int; const (
|
||||
// ColorAccent is the accent color of the theme.
|
||||
ColorAccent Color = iota
|
||||
|
||||
// ColorForeground is the text/icon color of the theme.
|
||||
ColorForeground
|
||||
)
|
||||
|
||||
// Hints specifies rendering hints for a particular pattern. Elements can take
|
||||
// these into account in order to gain extra performance.
|
||||
type Hints struct {
|
||||
@@ -80,7 +80,11 @@ type Theme interface {
|
||||
|
||||
// Pattern returns an appropriate pattern given a pattern name, case,
|
||||
// and state.
|
||||
Pattern (Pattern, PatternState, Case) artist.Pattern
|
||||
Pattern (Pattern, State, Case) artist.Pattern
|
||||
|
||||
// Color returns an appropriate pattern given a color name, case, and
|
||||
// state.
|
||||
Color (Color, State, Case) color.RGBA
|
||||
|
||||
// Padding returns how much space should be between the bounds of a
|
||||
// pattern whatever an element draws inside of it.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package theme
|
||||
|
||||
import "image"
|
||||
import "image/color"
|
||||
import "golang.org/x/image/font"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||
@@ -26,11 +27,17 @@ func (wrapped Wrapped) Icon (name string, size IconSize) canvas.Image {
|
||||
}
|
||||
|
||||
// Pattern returns an appropriate pattern given a pattern name and state.
|
||||
func (wrapped Wrapped) Pattern (id Pattern, state PatternState) artist.Pattern {
|
||||
func (wrapped Wrapped) Pattern (id Pattern, state State) artist.Pattern {
|
||||
real := wrapped.ensure()
|
||||
return real.Pattern(id, state, wrapped.Case)
|
||||
}
|
||||
|
||||
// Color returns an appropriate color given a color name and state.
|
||||
func (wrapped Wrapped) Color (id Color, state State) color.RGBA {
|
||||
real := wrapped.ensure()
|
||||
return real.Color(id, state, wrapped.Case)
|
||||
}
|
||||
|
||||
// Padding returns how much space should be between the bounds of a
|
||||
// pattern whatever an element draws inside of it.
|
||||
func (wrapped Wrapped) Padding (id Pattern) artist.Inset {
|
||||
|
||||
Reference in New Issue
Block a user