Skip to content

Commit

Permalink
TableView: Fix some issues with frozen columns
Browse files Browse the repository at this point in the history
  • Loading branch information
lxn committed Sep 10, 2020
1 parent 0030d12 commit 93a5128
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions tableview.go
Original file line number Diff line number Diff line change
Expand Up @@ -1737,10 +1737,7 @@ func (tv *TableView) RestoreState() error {
name2tvcs[tvcs.Name] = tvcsRetained[len(tvcsRetained)-1]

if tvc := name2tvc[tvcs.Name]; tvc != nil {
if err := tvc.SetTitleOverride(tvcs.Title); err != nil {
return err
}
if err := tvc.SetWidth(tvcs.Width); err != nil {
if err := tvc.SetFrozen(tvcs.Frozen); err != nil {
return err
}
var visible bool
Expand All @@ -1753,7 +1750,10 @@ func (tv *TableView) RestoreState() error {
if err := tvc.SetVisible(tvc.visible && (visible || tvcs.Visible)); err != nil {
return err
}
if err := tvc.SetFrozen(tvcs.Frozen); err != nil {
if err := tvc.SetTitleOverride(tvcs.Title); err != nil {
return err
}
if err := tvc.SetWidth(tvcs.Width); err != nil {
return err
}
}
Expand Down Expand Up @@ -2701,7 +2701,7 @@ func (tv *TableView) updateLVSizes() {
func (tv *TableView) updateLVSizesWithSpecialCare(needSpecialCare bool) {
var width int
for i := tv.columns.Len() - 1; i >= 0; i-- {
if col := tv.columns.At(i); col.frozen {
if col := tv.columns.At(i); col.frozen && col.visible {
width += col.Width()
}
}
Expand Down
4 changes: 2 additions & 2 deletions tableviewcolumn.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,15 @@ func (tvc *TableViewColumn) SetFrozen(frozen bool) (err error) {
}
}()

if tvc.tv != nil {
if tvc.tv != nil && tvc.visible {
if err = tvc.destroy(); err != nil {
return
}
}

tvc.frozen = frozen

if tvc.tv != nil {
if tvc.tv != nil && tvc.visible {
return tvc.create()
}

Expand Down

0 comments on commit 93a5128

Please sign in to comment.