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,
|
||||
NewEllipseRadialGradient, GetPushTransform, GetPushDuration, GetPushTiming, IsMoveToFrontAnimation,
|
||||
GetBackground, GetMask, GetBackgroundClip,GetBackgroundOrigin, GetMaskClip, GetMaskOrigin, NewColumnSeparator,
|
||||
NewClipShapeProperty, NewTransitionAnimation, NewAnimation.
|
||||
NewClipShapeProperty, NewTransitionAnimation, NewAnimation, IsSummaryMarkerHidden.
|
||||
|
||||
* 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 "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 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" показывает дочерние
|
||||
View, "false" - скрывает.
|
||||
|
||||
Получить значение свойства "expanded" можно с помощью функции
|
||||
По умолчанию в начале элемента "summary" отображается маркер ▶︎/▼. Его можно спрятать.
|
||||
Для этого используется свойство "hide-summary-marker" (константа DetailsView) типа bool.
|
||||
|
||||
func IsDetailsExpanded(view View, subviewID ...string) bool
|
||||
|
||||
а значение свойства "summary" можно получить с помощью функции
|
||||
Получить значение свойств "summary", "expanded" и "hide-summary-marker" можно с помощью функций
|
||||
|
||||
func GetDetailsSummary(view View, subviewID ...string) View
|
||||
func IsDetailsExpanded(view View, subviewID ...string) bool
|
||||
func IsSummaryMarkerHidden(view View, subviewID ...string) bool
|
||||
|
||||
## 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.
|
||||
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
|
||||
|
||||
and the value of the "summary" property can be obtained using the function
|
||||
The value of the "summary", "expanded" and "hide-summary-marker" properties can be obtained using the functions
|
||||
|
||||
func GetDetailsSummary(view View, subviewID ...string) View
|
||||
func IsDetailsExpanded(view View, subviewID ...string) bool
|
||||
func IsSummaryMarkerHidden(view View, subviewID ...string) bool
|
||||
|
||||
## Resizable
|
||||
|
||||
|
|
|
@ -181,6 +181,14 @@ ul:focus {
|
|||
overflow: auto;
|
||||
}
|
||||
|
||||
.hiddenMarker {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.hiddenMarker::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/*
|
||||
@media (prefers-color-scheme: light) {
|
||||
body {
|
||||
|
|
|
@ -25,6 +25,18 @@ const (
|
|||
// - true, 1, "true", "yes", "on", or "1" - Content is visible.
|
||||
// - false, 0, "false", "no", "off", or "0" - Content is collapsed (hidden).
|
||||
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
|
||||
|
@ -99,7 +111,7 @@ func (detailsView *detailsViewData) setFunc(tag PropertyName, value any) []Prope
|
|||
|
||||
func (detailsView *detailsViewData) propertyChanged(tag PropertyName) {
|
||||
switch tag {
|
||||
case Summary:
|
||||
case Summary, HideSummaryMarker:
|
||||
updateInnerHTML(detailsView.htmlID(), detailsView.Session())
|
||||
|
||||
case Expanded:
|
||||
|
@ -130,24 +142,46 @@ func (detailsView *detailsViewData) htmlProperties(self View, buffer *strings.Bu
|
|||
}
|
||||
|
||||
func (detailsView *detailsViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||
summary := false
|
||||
hidden := IsSummaryMarkerHidden(detailsView)
|
||||
|
||||
if value, ok := detailsView.properties[Summary]; ok {
|
||||
|
||||
switch value := value.(type) {
|
||||
case string:
|
||||
if !GetNotTranslate(detailsView) {
|
||||
value, _ = detailsView.session.GetString(value)
|
||||
}
|
||||
if hidden {
|
||||
buffer.WriteString(`<summary class="hiddenMarker">`)
|
||||
} else {
|
||||
buffer.WriteString("<summary>")
|
||||
}
|
||||
buffer.WriteString(value)
|
||||
buffer.WriteString("</summary>")
|
||||
summary = true
|
||||
|
||||
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")
|
||||
} else {
|
||||
buffer.WriteString(`<summary><div style="display: inline-block;">`)
|
||||
viewHTML(value, buffer, "")
|
||||
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 {
|
||||
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,
|
||||
ColumnSpanAll,
|
||||
MoveToFrontAnimation,
|
||||
HideSummaryMarker,
|
||||
}
|
||||
|
||||
var intProperties = []PropertyName{
|
||||
|
|
Loading…
Reference in New Issue