forked from mbk-lab/rui_orig
Added processing of title, icon, and close button changing in TabsLayout
This commit is contained in:
parent
76ff9a38fb
commit
9b3816f049
|
@ -2,8 +2,6 @@ package rui
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
// TODO Expanded event
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Summary is the constant for the "summary" property tag.
|
// Summary is the constant for the "summary" property tag.
|
||||||
// The contents of the "summary" property are used as the label for the disclosure widget.
|
// The contents of the "summary" property are used as the label for the disclosure widget.
|
||||||
|
|
|
@ -557,7 +557,6 @@ func (tabsLayout *tabsLayoutData) ListItem(index int, session Session) View {
|
||||||
Column: 2,
|
Column: 2,
|
||||||
Content: "✕",
|
Content: "✕",
|
||||||
ClickEvent: func() {
|
ClickEvent: func() {
|
||||||
// TODO close menu
|
|
||||||
for _, listener := range tabsLayout.tabCloseListener {
|
for _, listener := range tabsLayout.tabCloseListener {
|
||||||
listener(tabsLayout, index)
|
listener(tabsLayout, index)
|
||||||
}
|
}
|
||||||
|
@ -580,6 +579,10 @@ func (tabsLayout *tabsLayoutData) IsListItemEnabled(index int) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tabsLayout *tabsLayoutData) updateContent(view View, tag string) {
|
||||||
|
updateInnerHTML(tabsLayout.htmlID(), tabsLayout.session)
|
||||||
|
}
|
||||||
|
|
||||||
// Append appends view to the end of view list
|
// Append appends view to the end of view list
|
||||||
func (tabsLayout *tabsLayoutData) Append(view View) {
|
func (tabsLayout *tabsLayoutData) Append(view View) {
|
||||||
if tabsLayout.views == nil {
|
if tabsLayout.views == nil {
|
||||||
|
@ -587,6 +590,9 @@ func (tabsLayout *tabsLayoutData) Append(view View) {
|
||||||
}
|
}
|
||||||
if view != nil {
|
if view != nil {
|
||||||
tabsLayout.viewsContainerData.Append(view)
|
tabsLayout.viewsContainerData.Append(view)
|
||||||
|
view.SetChangeListener(Title, tabsLayout.updateContent)
|
||||||
|
view.SetChangeListener(Icon, tabsLayout.updateContent)
|
||||||
|
view.SetChangeListener(TabCloseButton, tabsLayout.updateContent)
|
||||||
if len(tabsLayout.views) == 1 {
|
if len(tabsLayout.views) == 1 {
|
||||||
tabsLayout.properties[Current] = 0
|
tabsLayout.properties[Current] = 0
|
||||||
for _, listener := range tabsLayout.tabListener {
|
for _, listener := range tabsLayout.tabListener {
|
||||||
|
@ -609,6 +615,9 @@ func (tabsLayout *tabsLayoutData) Insert(view View, index int) {
|
||||||
defer tabsLayout.propertyChangedEvent(Current)
|
defer tabsLayout.propertyChangedEvent(Current)
|
||||||
}
|
}
|
||||||
tabsLayout.viewsContainerData.Insert(view, index)
|
tabsLayout.viewsContainerData.Insert(view, index)
|
||||||
|
view.SetChangeListener(Title, tabsLayout.updateContent)
|
||||||
|
view.SetChangeListener(Icon, tabsLayout.updateContent)
|
||||||
|
view.SetChangeListener(TabCloseButton, tabsLayout.updateContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,27 +633,32 @@ func (tabsLayout *tabsLayoutData) RemoveView(index int) View {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var view View
|
||||||
if count == 1 {
|
if count == 1 {
|
||||||
view := tabsLayout.views[0]
|
view = tabsLayout.views[0]
|
||||||
tabsLayout.views = []View{}
|
tabsLayout.views = []View{}
|
||||||
for _, listener := range tabsLayout.tabListener {
|
for _, listener := range tabsLayout.tabListener {
|
||||||
listener(tabsLayout, 0, 0)
|
listener(tabsLayout, 0, 0)
|
||||||
}
|
}
|
||||||
tabsLayout.propertyChangedEvent(Current)
|
tabsLayout.propertyChangedEvent(Current)
|
||||||
return view
|
|
||||||
}
|
|
||||||
|
|
||||||
current := tabsLayout.currentItem()
|
} else {
|
||||||
removeCurrent := (i == current)
|
current := tabsLayout.currentItem()
|
||||||
if i < current || (removeCurrent && i == count-1) {
|
removeCurrent := (i == current)
|
||||||
tabsLayout.properties[Current] = current - 1
|
if i < current || (removeCurrent && i == count-1) {
|
||||||
for _, listener := range tabsLayout.tabListener {
|
tabsLayout.properties[Current] = current - 1
|
||||||
listener(tabsLayout, current-1, current)
|
for _, listener := range tabsLayout.tabListener {
|
||||||
|
listener(tabsLayout, current-1, current)
|
||||||
|
}
|
||||||
|
defer tabsLayout.propertyChangedEvent(Current)
|
||||||
}
|
}
|
||||||
defer tabsLayout.propertyChangedEvent(Current)
|
view = tabsLayout.viewsContainerData.RemoveView(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
return tabsLayout.viewsContainerData.RemoveView(index)
|
view.SetChangeListener(Title, nil)
|
||||||
|
view.SetChangeListener(Icon, nil)
|
||||||
|
view.SetChangeListener(TabCloseButton, nil)
|
||||||
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tabsLayout *tabsLayoutData) htmlProperties(self View, buffer *strings.Builder) {
|
func (tabsLayout *tabsLayoutData) htmlProperties(self View, buffer *strings.Builder) {
|
||||||
|
|
Loading…
Reference in New Issue