From 02bcf34efbf22eae3d61ee53d2b557cff4010cf9 Mon Sep 17 00:00:00 2001 From: unodgs Date: Fri, 7 Jan 2011 12:26:55 +0000 Subject: [PATCH] TabBar: Fixed making groups git-svn-id: svn://ultimatepp.org/upp/trunk@2966 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/TabBar/TabBar.cpp | 21 ++++++++++++--------- uppsrc/TabBar/TabBar.h | 3 ++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/uppsrc/TabBar/TabBar.cpp b/uppsrc/TabBar/TabBar.cpp index 207beca05..9ab915701 100644 --- a/uppsrc/TabBar/TabBar.cpp +++ b/uppsrc/TabBar/TabBar.cpp @@ -340,11 +340,17 @@ void TabBar::Set(const TabBar& t) groups.Clear(); groups <<= t.groups; + group = t.group; + stackcount = t.stackcount; + active = t.active; cross = -1; highlight = -1; target = -1; + mouse.Clear(); + oldp.Clear(); + sc.Set(t.sc); SetAlign(t.GetAlign()); } @@ -582,14 +588,12 @@ void TabBar::MakeGroups() groups[n].last = i; } } - - int removed = 0; - for(int i = 1; i < groups.GetCount(); i++) + + int cnt = groups.GetCount() - 1; + for(int i = cnt; i > 0; i--) if(groups[i].count == 0) - { - groups.Remove(i - removed); - removed++; - } + groups.Remove(i); + if(group > groups.GetCount() - 1 && group > 0) group--; } @@ -1008,7 +1012,6 @@ void TabBar::PaintTab(Draw &w, const Size &sz, int n, bool enable, bool dragsamp void TabBar::Paint(Draw &w) { - LOG("Paint"); int align = GetAlign(); const Style &st = StyleDefault(); Size ctrlsz = GetSize(); @@ -1232,7 +1235,7 @@ int TabBar::InsertKey0(int ix, const Value &key, const Value &value, Image icon, NewGroup(group); g = groups.GetCount() - 1; } - } + } group = groups[g].name; Tab t; diff --git a/uppsrc/TabBar/TabBar.h b/uppsrc/TabBar/TabBar.h index fe68c8b3a..e529ba89a 100644 --- a/uppsrc/TabBar/TabBar.h +++ b/uppsrc/TabBar/TabBar.h @@ -210,6 +210,7 @@ protected: int first; int last; virtual void Serialize(Stream& s); + String ToString() const { return Format("%s - %d", name, count); } }; struct TabValueSort : public TabSort { @@ -256,7 +257,7 @@ private: int group; const Display *display; Image dragtab; - int stackcount; + int stackcount; int scrollbar_sz; bool allowreorder;