Added functions: GetBackgroundColorPair, GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair

This commit is contained in:
Alexei Anoshenko 2026-07-10 19:03:04 +03:00
parent bd0e918f88
commit 9dda89c781
4 changed files with 79 additions and 18 deletions

View File

@ -2,7 +2,8 @@
* Removed "style-disabled" property and GetDisabledStyle function
* Added GoogleFonts field to AppParams
* Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded
* Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded, GetBackgroundColorPair,
GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair
* Added ClientSession interface
* Added ClientSession, Popups, PopupDefault, PopupDefaultsSeq, and SetPopupDefaults methods to Session interface
* Removed ClientItem, SetClientItem, RemoveClientItem, and RemoveAllClientItems methods from Session interface

View File

@ -181,18 +181,21 @@ func (columnLayout *columnLayoutData) propertyChanged(tag PropertyName) {
// GetColumnCount returns int value which specifies number of columns into which the content of
// ColumnLayout is break. If the return value is 0 then the number of columns is calculated
// based on the "column-width" property.
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnCount(view View, subviewID ...string) int {
return intStyledProperty(view, subviewID, ColumnCount, 0)
}
// GetColumnWidth returns SizeUnit value which specifies the width of each column of ColumnLayout.
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnWidth(view View, subviewID ...string) SizeUnit {
return sizeStyledProperty(view, subviewID, ColumnWidth, false)
}
// GetColumnGap returns SizeUnit property which specifies the size of the gap (gutter) between columns of ColumnLayout.
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnGap(view View, subviewID ...string) SizeUnit {
return sizeStyledProperty(view, subviewID, ColumnGap, false)
@ -217,6 +220,7 @@ func getColumnSeparator(view View, subviewID []string) ViewBorder {
// GetColumnSeparator returns ViewBorder struct which specifies the line drawn between
// columns in a multi-column ColumnLayout.
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnSeparator(view View, subviewID ...string) ViewBorder {
return getColumnSeparator(view, subviewID)
@ -224,7 +228,9 @@ func GetColumnSeparator(view View, subviewID ...string) ViewBorder {
// ColumnSeparatorStyle returns int value which specifies the style of the line drawn between
// columns in a multi-column layout.
//
// Valid values are NoneLine (0), SolidLine (1), DashedLine (2), DottedLine (3), and DoubleLine (4).
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnSeparatorStyle(view View, subviewID ...string) int {
border := getColumnSeparator(view, subviewID)
@ -233,20 +239,31 @@ func GetColumnSeparatorStyle(view View, subviewID ...string) int {
// ColumnSeparatorWidth returns SizeUnit value which specifies the width of the line drawn between
// columns in a multi-column layout.
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnSeparatorWidth(view View, subviewID ...string) SizeUnit {
border := getColumnSeparator(view, subviewID)
return border.Width
}
// ColumnSeparatorColor returns Color value which specifies the color of the line drawn between
// ColumnSeparatorColor returns Color value which specifies the current theme color of the line drawn between
// columns in a multi-column layout.
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnSeparatorColor(view View, subviewID ...string) Color {
border := getColumnSeparator(view, subviewID)
return border.CurrentColor(view.Session())
}
// ColumnSeparatorColorPair returns ColorPair value which specifies the light and dark theme color of the line drawn between
// columns in a multi-column layout.
//
// If the second argument (subviewID) is not specified or it is "" then a top position of the first argument (view) is returned
func GetColumnSeparatorColorPair(view View, subviewID ...string) ColorPair {
border := getColumnSeparator(view, subviewID)
return border.Color
}
// GetColumnFill returns a "column-fill" property value of the subview.
// Returns one of next values: ColumnFillBalance (0) or ColumnFillAuto (1)
//

View File

@ -541,10 +541,18 @@ func AppendEditText(view View, subviewID string, text string) {
}
}
// GetCaretColor returns the color of the text input caret.
// GetCaretColor returns the current theme color of the text input caret.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
func GetCaretColor(view View, subviewID ...string) Color {
return colorStyledProperty(view, subviewID, CaretColor, false)
}
// GetCaretColorPair returns the light and dark theme color of the text input caret.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
func GetCaretColorPair(view View, subviewID ...string) ColorPair {
return colorPairStyledProperty(view, subviewID, CaretColor, false)
}

View File

@ -339,7 +339,7 @@ func GetTextShadows(view View, subviewID ...string) []ShadowProperty {
return getShadows(view, TextShadow)
}
// GetBackgroundColor returns a background color of the subview.
// GetBackgroundColor returns the current theme background color of the subview.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
@ -347,7 +347,15 @@ 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.
// GetBackgroundColorPair returns the light and dark theme background color of the subview.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
func GetBackgroundColorPair(view View, subviewID ...string) ColorPair {
return colorPairStyledProperty(view, subviewID, BackgroundColor, false)
}
// GetAccentColor returns the current theme accent color for UI controls generated by some elements.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
@ -355,6 +363,14 @@ func GetAccentColor(view View, subviewID ...string) Color {
return colorStyledProperty(view, subviewID, AccentColor, false)
}
// GetAccentColorPair returns the light and dark theme accent color for UI controls generated by some elements.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
func GetAccentColorPair(view View, subviewID ...string) ColorPair {
return colorPairStyledProperty(view, subviewID, AccentColor, false)
}
// GetFontName returns the subview font.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
@ -363,7 +379,7 @@ func GetFontName(view View, subviewID ...string) string {
return stringStyledProperty(view, nil, FontName, true)
}
// GetTextColor returns a text color of the subview.
// GetTextColor returns the current theme text color of the subview.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
@ -371,6 +387,14 @@ func GetTextColor(view View, subviewID ...string) Color {
return colorStyledProperty(view, subviewID, TextColor, true)
}
// GetTextColorPair returns the light and dark theme text color of the subview.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
func GetTextColorPair(view View, subviewID ...string) ColorPair {
return colorPairStyledProperty(view, subviewID, TextColor, true)
}
// GetTextSize returns a text size of the subview.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
@ -530,7 +554,7 @@ func GetTextLineStyle(view View, subviewID ...string) int {
return enumStyledProperty(view, subviewID, TextLineStyle, SolidLine, true)
}
// GetTextLineColor returns the stroke color of the decoration line that
// GetTextLineColor returns the current theme stroke color of the decoration line that
// is used on text in an element, such as a line-through, underline, or overline.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
@ -539,6 +563,15 @@ func GetTextLineColor(view View, subviewID ...string) Color {
return colorStyledProperty(view, subviewID, TextLineColor, true)
}
// GetTextLineColorPair returns the light and dark theme stroke color of the decoration line that
// is used on text in an element, such as a line-through, underline, or overline.
//
// The second argument (subviewID) specifies the path to the child element whose value needs to be returned.
// If it is not specified then a value from the first argument (view) is returned.
func GetTextLineColorPair(view View, subviewID ...string) ColorPair {
return colorPairStyledProperty(view, subviewID, TextLineColor, true)
}
// GetTextTransform returns a text transform of the subview. Return one of next values:
// NoneTextTransform (0), CapitalizeTextTransform (1), LowerCaseTextTransform (2) or UpperCaseTextTransform (3)
//
@ -746,29 +779,31 @@ func floatStyledProperty(view View, subviewID []string, tag PropertyName, defaul
return defaultValue
}
func colorStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) Color {
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 {
if view.Session().DarkTheme() {
return darkColor
}
return lightColor
return ColorPair{Light: lightColor, Dark: darkColor}
}
if value := valueFromStyle(view, tag); value != nil {
if lightColor, darkColor, ok := valueToColor(value, view.Session()); ok {
if view.Session().DarkTheme() {
return darkColor
}
return lightColor
return ColorPair{Light: lightColor, Dark: darkColor}
}
}
if inherit {
if parent := view.Parent(); parent != nil {
return colorStyledProperty(parent, []string{}, tag, true)
return colorPairStyledProperty(parent, []string{}, tag, true)
}
}
}
return Color(0)
return ColorPair{Light: Color(0), Dark: 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.Light
}
func transformStyledProperty(view View, subviewID []string, tag PropertyName) TransformProperty {