Renamed fields of ColorPair

This commit is contained in:
Alexei Anoshenko 2026-10-19 18:36:01 +03:00
parent 0f409d37cf
commit be9dd57806
7 changed files with 26 additions and 26 deletions

View File

@ -80,9 +80,9 @@ func (point *BackgroundGradientAngle) color(session Session) (Color, bool) {
case ColorPair:
if session.DarkTheme() {
return color.Dark, true
return color.DarkMode, true
}
return color.Light, true
return color.LightMode, true
default:
if n, ok := isInt(color); ok {

View File

@ -207,9 +207,9 @@ func (point *BackgroundGradientPoint) color(session Session) (Color, bool) {
case ColorPair:
if session.DarkTheme() {
return color.Dark, true
return color.DarkMode, true
}
return color.Light, true
return color.LightMode, true
default:
if n, ok := isInt(point.Color); ok {

View File

@ -782,9 +782,9 @@ func (border *borderProperty) ViewBorders(session Session) ViewBorders {
result.Width = defaultWidth
}
if result.Color.Light, result.Color.Dark, ok = colorProperty(border, prefix+ColorTag, session); !ok {
result.Color.Light = defaultLightColor
result.Color.Dark = defaultDarkColor
if result.Color.LightMode, result.Color.DarkMode, ok = colorProperty(border, prefix+ColorTag, session); !ok {
result.Color.LightMode = defaultLightColor
result.Color.DarkMode = defaultDarkColor
}
return result
@ -833,7 +833,7 @@ func (border *borderProperty) cssColor(builder cssBuilder, session Session) {
if borders.Top.Color == borders.Right.Color &&
borders.Top.Color == borders.Left.Color &&
borders.Top.Color == borders.Bottom.Color {
if borders.Top.Color.Light != 0 || borders.Top.Color.Dark != 0 {
if borders.Top.Color.LightMode != 0 || borders.Top.Color.DarkMode != 0 {
builder.add("border-color", borders.Top.Color.cssString(session))
}
} else {
@ -883,9 +883,9 @@ type ViewBorders struct {
// CurrentColor returns the border color used in the current theme.
func (border *ViewBorder) CurrentColor(session Session) Color {
if session.DarkTheme() {
return border.Color.Dark
return border.Color.DarkMode
}
return border.Color.Light
return border.Color.LightMode
}
// AllTheSame returns true if all borders are the same

View File

@ -14,10 +14,10 @@ type Color uint32
// ColorPair represents the color pair in argb format
type ColorPair struct {
// Light is the color used in the light theme
Light Color
LightMode Color
// Dark is the color used in the light theme
Dark Color
DarkMode Color
}
// ARGB creates Color using alpha, red, green and blue components
@ -229,13 +229,13 @@ func parseColorPair(obj DataObject) (ColorPair, bool) {
switch tag {
case "light":
result.Light, err = stringToColor(property.String())
result.LightMode, err = stringToColor(property.String())
if err != nil {
return ColorPair{}, false
}
case "dark":
result.Dark, err = stringToColor(property.String())
result.DarkMode, err = stringToColor(property.String())
if err != nil {
return ColorPair{}, false
}
@ -249,7 +249,7 @@ func parseColorPair(obj DataObject) (ColorPair, bool) {
}
func (pair ColorPair) String() string {
return fmt.Sprintf("_{ light = %s, dark = %s }", pair.Light.String(), pair.Dark.String())
return fmt.Sprintf("_{ light = %s, dark = %s }", pair.LightMode.String(), pair.DarkMode.String())
}
func (pair ColorPair) cssString(session Session) string {
@ -257,12 +257,12 @@ func (pair ColorPair) cssString(session Session) string {
if session.lightDarkSupport() {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
writeColorCSS(buffer, pair.Light, pair.Dark, session)
writeColorCSS(buffer, pair.LightMode, pair.DarkMode, session)
return buffer.String()
}
if session.DarkTheme() {
return pair.Dark.cssString()
return pair.DarkMode.cssString()
}
return pair.Light.cssString()
return pair.LightMode.cssString()
}

View File

@ -134,7 +134,7 @@ func (separator *columnSeparatorProperty) ViewBorder(session Session) ViewBorder
return ViewBorder{
Style: style,
Width: width,
Color: ColorPair{Light: lightColor, Dark: darkColor},
Color: ColorPair{LightMode: lightColor, DarkMode: darkColor},
}
}

View File

@ -88,7 +88,7 @@ func valueToColor(value any, session Session) (Color, Color, bool) {
return value, value, true
case ColorPair:
return value.Light, value.Dark, true
return value.LightMode, value.DarkMode, true
case string:
if ok, constName := isConstantName(value); ok {
@ -103,7 +103,7 @@ func valueToColor(value any, session Session) (Color, Color, bool) {
if obj, err := ParseDataText(value); err == nil {
if colorPair, ok := parseColorPair(obj); ok {
return colorPair.Light, colorPair.Dark, true
return colorPair.LightMode, colorPair.DarkMode, true
}
}
}

View File

@ -782,11 +782,11 @@ func floatStyledProperty(view View, subviewID []string, tag PropertyName, defaul
func colorPairStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) ColorPair {
if view = getSubview(view, subviewID); view != nil {
if lightColor, darkColor, ok := colorProperty(view, tag, view.Session()); ok {
return ColorPair{Light: lightColor, Dark: darkColor}
return ColorPair{LightMode: lightColor, DarkMode: darkColor}
}
if value := valueFromStyle(view, tag); value != nil {
if lightColor, darkColor, ok := valueToColor(value, view.Session()); ok {
return ColorPair{Light: lightColor, Dark: darkColor}
return ColorPair{LightMode: lightColor, DarkMode: darkColor}
}
}
if inherit {
@ -795,15 +795,15 @@ func colorPairStyledProperty(view View, subviewID []string, tag PropertyName, in
}
}
}
return ColorPair{Light: Color(0), Dark: Color(0)}
return ColorPair{LightMode: Color(0), DarkMode: Color(0)}
}
func colorStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) Color {
color := colorPairStyledProperty(view, subviewID, tag, inherit)
if view.Session().DarkTheme() {
return color.Dark
return color.DarkMode
}
return color.Light
return color.LightMode
}
func transformStyledProperty(view View, subviewID []string, tag PropertyName) TransformProperty {