mirror of https://github.com/anoshenko/rui.git
Added "hide-summary-marker" DetailsView property
This commit is contained in:
parent
0bdfe48f09
commit
848606a3be
|
@ -33,7 +33,7 @@
|
||||||
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
|
* Added functions: NewBounds, NewEllipticRadius, NewRadii, NewLinearGradient, NewCircleRadialGradient,
|
||||||
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
|
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
|
||||||
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator,
|
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator,
|
||||||
NewClipShapeProperty, NewTransitionAnimation, NewAnimation.
|
NewClipShapeProperty, NewTransitionAnimation, NewAnimation, IsSummaryMarkerHidden.
|
||||||
|
|
||||||
* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
|
* Added SetConicGradientFillStyle and SetConicGradientStrokeStyle methods to Canvas interface.
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ NewClipShapeProperty, NewTransitionAnimation, NewAnimation.
|
||||||
|
|
||||||
* Added "mask", "mask-clip", "mask-origin", and "background-origin" properties.
|
* Added "mask", "mask-clip", "mask-origin", and "background-origin" properties.
|
||||||
|
|
||||||
|
* Added "hide-summary-marker" DetailsView property.
|
||||||
|
|
||||||
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
|
* Added LineJoin type. Type of constants MiterJoin, RoundJoin, and BevelJoin changed to LineJoin. Type of Canvas.SetLineJoin function argument changed to LineJoin.
|
||||||
|
|
||||||
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
|
* Added LineCap type. Type of constants ButtCap, RoundCap, and SquareCap changed to LineCap. Type of Canvas.SetLineCap function argument changed to LineCap.
|
||||||
|
|
|
@ -2980,13 +2980,14 @@ DetailsView переключается между состояниями по к
|
||||||
"expanded" (константа Expanded). Соответственно значение "true" показывает дочерние
|
"expanded" (константа Expanded). Соответственно значение "true" показывает дочерние
|
||||||
View, "false" - скрывает.
|
View, "false" - скрывает.
|
||||||
|
|
||||||
Получить значение свойства "expanded" можно с помощью функции
|
По умолчанию в начале элемента "summary" отображается маркер ▶︎/▼. Его можно спрятать.
|
||||||
|
Для этого используется свойство "hide-summary-marker" (константа DetailsView) типа bool.
|
||||||
|
|
||||||
func IsDetailsExpanded(view View, subviewID ...string) bool
|
Получить значение свойств "summary", "expanded" и "hide-summary-marker" можно с помощью функций
|
||||||
|
|
||||||
а значение свойства "summary" можно получить с помощью функции
|
|
||||||
|
|
||||||
func GetDetailsSummary(view View, subviewID ...string) View
|
func GetDetailsSummary(view View, subviewID ...string) View
|
||||||
|
func IsDetailsExpanded(view View, subviewID ...string) bool
|
||||||
|
func IsSummaryMarkerHidden(view View, subviewID ...string) bool
|
||||||
|
|
||||||
## Resizable
|
## Resizable
|
||||||
|
|
||||||
|
|
|
@ -2963,13 +2963,14 @@ DetailsView switches between states by clicking on "summary" view.
|
||||||
For forced switching of the DetailsView states, the bool property "expanded" (Expanded constant) is used.
|
For forced switching of the DetailsView states, the bool property "expanded" (Expanded constant) is used.
|
||||||
Accordingly, the value "true" shows child Views, "false" - hides.
|
Accordingly, the value "true" shows child Views, "false" - hides.
|
||||||
|
|
||||||
You can get the value of the "expanded" property using the function
|
By default, a ▶︎/▼ marker is displayed at the beginning of the "summary" element. It can be hidden.
|
||||||
|
For this, the "hide-summary-marker" bool property (DetailsView constant) is used.
|
||||||
|
|
||||||
func IsDetailsExpanded(view View, subviewID ...string) bool
|
The value of the "summary", "expanded" and "hide-summary-marker" properties can be obtained using the functions
|
||||||
|
|
||||||
and the value of the "summary" property can be obtained using the function
|
|
||||||
|
|
||||||
func GetDetailsSummary(view View, subviewID ...string) View
|
func GetDetailsSummary(view View, subviewID ...string) View
|
||||||
|
func IsDetailsExpanded(view View, subviewID ...string) bool
|
||||||
|
func IsSummaryMarkerHidden(view View, subviewID ...string) bool
|
||||||
|
|
||||||
## Resizable
|
## Resizable
|
||||||
|
|
||||||
|
|
|
@ -181,6 +181,14 @@ ul:focus {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hiddenMarker {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hiddenMarker::-webkit-details-marker {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@media (prefers-color-scheme: light) {
|
@media (prefers-color-scheme: light) {
|
||||||
body {
|
body {
|
||||||
|
|
|
@ -25,6 +25,18 @@ const (
|
||||||
// - true, 1, "true", "yes", "on", or "1" - Content is visible.
|
// - true, 1, "true", "yes", "on", or "1" - Content is visible.
|
||||||
// - false, 0, "false", "no", "off", or "0" - Content is collapsed (hidden).
|
// - false, 0, "false", "no", "off", or "0" - Content is collapsed (hidden).
|
||||||
Expanded PropertyName = "expanded"
|
Expanded PropertyName = "expanded"
|
||||||
|
|
||||||
|
// HideSummaryMarker is the constant for "hide-summary-marker" property tag.
|
||||||
|
//
|
||||||
|
// Used by DetailsView.
|
||||||
|
// Allows you to hide the summary marker (▶︎). Default value is false.
|
||||||
|
//
|
||||||
|
// Supported types: bool, int, string.
|
||||||
|
//
|
||||||
|
// Values:
|
||||||
|
// - true, 1, "true", "yes", "on", or "1" - The summary marker is hidden.
|
||||||
|
// - false, 0, "false", "no", "off", or "0" - The summary marker is displayed (default value).
|
||||||
|
HideSummaryMarker PropertyName = "hide-summary-marker"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DetailsView represent a DetailsView view, which is a collapsible container of views
|
// DetailsView represent a DetailsView view, which is a collapsible container of views
|
||||||
|
@ -99,7 +111,7 @@ func (detailsView *detailsViewData) setFunc(tag PropertyName, value any) []Prope
|
||||||
|
|
||||||
func (detailsView *detailsViewData) propertyChanged(tag PropertyName) {
|
func (detailsView *detailsViewData) propertyChanged(tag PropertyName) {
|
||||||
switch tag {
|
switch tag {
|
||||||
case Summary:
|
case Summary, HideSummaryMarker:
|
||||||
updateInnerHTML(detailsView.htmlID(), detailsView.Session())
|
updateInnerHTML(detailsView.htmlID(), detailsView.Session())
|
||||||
|
|
||||||
case Expanded:
|
case Expanded:
|
||||||
|
@ -130,24 +142,46 @@ func (detailsView *detailsViewData) htmlProperties(self View, buffer *strings.Bu
|
||||||
}
|
}
|
||||||
|
|
||||||
func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
|
summary := false
|
||||||
|
hidden := IsSummaryMarkerHidden(detailsView)
|
||||||
|
|
||||||
if value, ok := detailsView.properties[Summary]; ok {
|
if value, ok := detailsView.properties[Summary]; ok {
|
||||||
|
|
||||||
switch value := value.(type) {
|
switch value := value.(type) {
|
||||||
case string:
|
case string:
|
||||||
if !GetNotTranslate(detailsView) {
|
if !GetNotTranslate(detailsView) {
|
||||||
value, _ = detailsView.session.GetString(value)
|
value, _ = detailsView.session.GetString(value)
|
||||||
}
|
}
|
||||||
|
if hidden {
|
||||||
|
buffer.WriteString(`<summary class="hiddenMarker">`)
|
||||||
|
} else {
|
||||||
buffer.WriteString("<summary>")
|
buffer.WriteString("<summary>")
|
||||||
|
}
|
||||||
buffer.WriteString(value)
|
buffer.WriteString(value)
|
||||||
buffer.WriteString("</summary>")
|
buffer.WriteString("</summary>")
|
||||||
|
summary = true
|
||||||
|
|
||||||
case View:
|
case View:
|
||||||
if value.htmlTag() == "div" {
|
if hidden {
|
||||||
|
buffer.WriteString(`<summary class="hiddenMarker">`)
|
||||||
|
viewHTML(value, buffer, "")
|
||||||
|
buffer.WriteString("</summary>")
|
||||||
|
} else if value.htmlTag() == "div" {
|
||||||
viewHTML(value, buffer, "summary")
|
viewHTML(value, buffer, "summary")
|
||||||
} else {
|
} else {
|
||||||
buffer.WriteString(`<summary><div style="display: inline-block;">`)
|
buffer.WriteString(`<summary><div style="display: inline-block;">`)
|
||||||
viewHTML(value, buffer, "")
|
viewHTML(value, buffer, "")
|
||||||
buffer.WriteString("</div></summary>")
|
buffer.WriteString("</div></summary>")
|
||||||
}
|
}
|
||||||
|
summary = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !summary {
|
||||||
|
if hidden {
|
||||||
|
buffer.WriteString(`<summary class="hiddenMarker"></summary>`)
|
||||||
|
} else {
|
||||||
|
buffer.WriteString("<summary></summary>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,3 +223,9 @@ func GetDetailsSummary(view View, subviewID ...string) View {
|
||||||
func IsDetailsExpanded(view View, subviewID ...string) bool {
|
func IsDetailsExpanded(view View, subviewID ...string) bool {
|
||||||
return boolStyledProperty(view, subviewID, Expanded, false)
|
return boolStyledProperty(view, subviewID, Expanded, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsDetailsExpanded returns a value of the HideSummaryMarker property of DetailsView.
|
||||||
|
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
|
||||||
|
func IsSummaryMarkerHidden(view View, subviewID ...string) bool {
|
||||||
|
return boolStyledProperty(view, subviewID, HideSummaryMarker, false)
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ var boolProperties = []PropertyName{
|
||||||
UserSelect,
|
UserSelect,
|
||||||
ColumnSpanAll,
|
ColumnSpanAll,
|
||||||
MoveToFrontAnimation,
|
MoveToFrontAnimation,
|
||||||
|
HideSummaryMarker,
|
||||||
}
|
}
|
||||||
|
|
||||||
var intProperties = []PropertyName{
|
var intProperties = []PropertyName{
|
||||||
|
|
Loading…
Reference in New Issue