mirror of https://github.com/anoshenko/rui.git
Added ViewSeq add ViewCount methods to ParentView interface
This commit is contained in:
parent
69a4d1e712
commit
7214eda01d
|
|
@ -5,6 +5,7 @@
|
|||
* Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded
|
||||
* Added Popups, PopupShowAnimation, and SetPopupShowAnimation methods to Session interface
|
||||
* Added DismissWithoutAnimation add SetHotKey methods to Popup interface
|
||||
* Added ViewSeq add ViewCount methods to ParentView interface
|
||||
* Added ToBoundsProperty method to Bounds struct
|
||||
|
||||
# v0.20.0
|
||||
|
|
|
|||
15
listView.go
15
listView.go
|
|
@ -2,6 +2,7 @@ package rui
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"iter"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -161,6 +162,20 @@ func (listView *listViewData) Views() []View {
|
|||
return listView.items
|
||||
}
|
||||
|
||||
func (listView *listViewData) ViewSeq() iter.Seq[View] {
|
||||
return func(yield func(View) bool) {
|
||||
for _, view := range listView.items {
|
||||
if !yield(view) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (listView *listViewData) ViewCount() int {
|
||||
return len(listView.items)
|
||||
}
|
||||
|
||||
func normalizeListViewTag(tag PropertyName) PropertyName {
|
||||
tag = defaultNormalize(tag)
|
||||
switch tag {
|
||||
|
|
|
|||
16
resizable.go
16
resizable.go
|
|
@ -2,6 +2,7 @@ package rui
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"iter"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -91,6 +92,21 @@ func (resizable *resizableData) Views() []View {
|
|||
return []View{}
|
||||
}
|
||||
|
||||
func (resizable *resizableData) ViewSeq() iter.Seq[View] {
|
||||
return func(yield func(View) bool) {
|
||||
if view := resizable.content(); view != nil {
|
||||
yield(view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (resizable *resizableData) ViewCount() int {
|
||||
if resizable.content() != nil {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (resizable *resizableData) content() View {
|
||||
if value := resizable.getRaw(Content); value != nil {
|
||||
if content, ok := value.(View); ok {
|
||||
|
|
|
|||
15
tableView.go
15
tableView.go
|
|
@ -2,6 +2,7 @@ package rui
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"iter"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -1694,6 +1695,20 @@ func (table *tableViewData) Views() []View {
|
|||
return table.cellViews
|
||||
}
|
||||
|
||||
func (table *tableViewData) ViewSeq() iter.Seq[View] {
|
||||
return func(yield func(View) bool) {
|
||||
for _, view := range table.cellViews {
|
||||
if !yield(view) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (table *tableViewData) ViewCount() int {
|
||||
return len(table.cellViews)
|
||||
}
|
||||
|
||||
func (table *tableViewData) handleCommand(self View, command PropertyName, data DataObject) bool {
|
||||
switch command {
|
||||
case "currentRow":
|
||||
|
|
|
|||
|
|
@ -1,11 +1,20 @@
|
|||
package rui
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"iter"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ParentView describe a view which can have a child views
|
||||
type ParentView interface {
|
||||
// Views return a list of child views
|
||||
// Views returns a list of child views
|
||||
Views() []View
|
||||
|
||||
// ViewSeq returns an iterator over all child views
|
||||
ViewSeq() iter.Seq[View]
|
||||
|
||||
// ViewCount returns a number of child views
|
||||
ViewCount() int
|
||||
}
|
||||
|
||||
// ViewsContainer represent a mutable list-container of views
|
||||
|
|
@ -67,6 +76,24 @@ func (container *viewsContainerData) Views() []View {
|
|||
return []View{}
|
||||
}
|
||||
|
||||
func (container *viewsContainerData) ViewSeq() iter.Seq[View] {
|
||||
if container.views == nil {
|
||||
container.views = []View{}
|
||||
}
|
||||
|
||||
return func(yield func(View) bool) {
|
||||
for _, view := range container.views {
|
||||
if !yield(view) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (container *viewsContainerData) ViewCount() int {
|
||||
return len(container.views)
|
||||
}
|
||||
|
||||
func (container *viewsContainerData) append(view View) bool {
|
||||
if view != nil {
|
||||
view.setParentID(container.htmlID())
|
||||
|
|
|
|||
Loading…
Reference in New Issue