From 06ccffa900f79c56a8596e5973ea2b47028b5dc0 Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko Date: Sat, 20 Aug 2022 19:13:51 +0300 Subject: [PATCH] Added "accent-color" property --- CHANGELOG.md | 4 ++-- defaultTheme.rui | 1 + propertyNames.go | 4 ++++ view.go | 1 + viewStyle.go | 1 + viewUtils.go | 6 ++++++ 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc36a77..590d2e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ * Requires go 1.18 or higher * The "interface{}" type replaced by "any" -* Added "overflow", "arrow", "arrow-align", "arrow-size", "arrow-width", and "arrow-offset" properties +* Added "accent-color", "overflow", "arrow", "arrow-align", "arrow-size", "arrow-width", and "arrow-offset" properties * Added "@ruiArrowSize" and "@ruiArrowWidth" constants to the default theme * Added Transition, Transitions, and SetTransition functions to the ViewStyle interface -* Added GetOverflow, IsTimingFunctionValid, and GetTransitions functions +* Added GetAccentColor, GetOverflow, IsTimingFunctionValid, and GetTransitions functions * Changed GetTransition functions * Added the OpenURL function to the Session interface diff --git a/defaultTheme.rui b/defaultTheme.rui index 4f96c87..524481a 100644 --- a/defaultTheme.rui +++ b/defaultTheme.rui @@ -74,6 +74,7 @@ theme { text-size = 10pt, text-color = @ruiTextColor, background-color = @ruiBackgroundColor, + accent-color = @ruiHighlightColor, }, ruiButton { align = center, diff --git a/propertyNames.go b/propertyNames.go index 5943223..d810039 100644 --- a/propertyNames.go +++ b/propertyNames.go @@ -147,6 +147,10 @@ const ( // The "padding-bottom" SizeUnit property sets the height of the padding area to the bottom of a view. PaddingBottom = "padding-bottom" + // AccentColor is the constant for the "accent-color" property tag. + // The "accent-color" property sets sets the accent color for UI controls generated by some elements. + AccentColor = "accent-color" + // BackgroundColor is the constant for the "background-color" property tag. // The "background-color" property sets the background color of a view. BackgroundColor = "background-color" diff --git a/view.go b/view.go index 81c8b5f..54cb833 100644 --- a/view.go +++ b/view.go @@ -637,6 +637,7 @@ func viewPropertyChanged(view *viewData, tag string) { TextColor: "color", TextLineColor: "text-decoration-color", CaretColor: CaretColor, + AccentColor: AccentColor, } if cssTag, ok := colorTags[tag]; ok { if color, ok := colorProperty(view, tag, session); ok { diff --git a/viewStyle.go b/viewStyle.go index dd63835..608680c 100644 --- a/viewStyle.go +++ b/viewStyle.go @@ -224,6 +224,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) { {TextColor, "color"}, {TextLineColor, "text-decoration-color"}, {CaretColor, CaretColor}, + {AccentColor, AccentColor}, } for _, p := range colorProperties { if color, ok := colorProperty(style, p.property, session); ok && color != 0 { diff --git a/viewUtils.go b/viewUtils.go index ace84a7..a37b490 100644 --- a/viewUtils.go +++ b/viewUtils.go @@ -326,6 +326,12 @@ func GetBackgroundColor(view View, subviewID string) Color { return colorStyledProperty(view, subviewID, BackgroundColor, false) } +// GetAccentColor returns the accent color for UI controls generated by some elements. +// If the second argument (subviewID) is "" then a value from the first argument (view) is returned. +func GetAccentColor(view View, subviewID string) Color { + return colorStyledProperty(view, subviewID, AccentColor, false) +} + // GetFontName returns the subview font. // If the second argument (subviewID) is "" then a value from the first argument (view) is returned. func GetFontName(view View, subviewID string) string {