[haiku-commits] r39489 - haiku/trunk/src/apps/terminal

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 19 Nov 2010 02:06:02 +0100 (CET)

Author: bonefish
Date: 2010-11-19 02:06:02 +0100 (Fri, 19 Nov 2010)
New Revision: 39489
Changeset: http://dev.haiku-os.org/changeset/39489

Modified:
   haiku/trunk/src/apps/terminal/SmartTabView.cpp
   haiku/trunk/src/apps/terminal/SmartTabView.h
Log:
Added MoveTab() method.


Modified: haiku/trunk/src/apps/terminal/SmartTabView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/SmartTabView.cpp      2010-11-18 22:36:03 UTC 
(rev 39488)
+++ haiku/trunk/src/apps/terminal/SmartTabView.cpp      2010-11-19 01:06:02 UTC 
(rev 39489)
@@ -206,6 +206,29 @@
 }
 
 
+void
+SmartTabView::MoveTab(int32 index, int32 newIndex)
+{
+       // check the indexes
+       int32 count = CountTabs();
+       if (index == newIndex || index < 0 || newIndex < 0 || index >= count
+               || newIndex >= count) {
+               return;
+       }
+
+       // Remove the tab from its position and add it to the end. Then cycle 
the
+       // tabs starting after the new position (save the tab already moved) to 
the
+       // end.
+       BTab* tab = BTabView::RemoveTab(index);
+       BTabView::AddTab(tab->View(), tab);
+
+       for (int32 i = newIndex; i < count - 1; i++) {
+               tab = BTabView::RemoveTab(newIndex);
+               BTabView::AddTab(tab->View(), tab);
+       }
+}
+
+
 BRect
 SmartTabView::DrawTabs()
 {

Modified: haiku/trunk/src/apps/terminal/SmartTabView.h
===================================================================
--- haiku/trunk/src/apps/terminal/SmartTabView.h        2010-11-18 22:36:03 UTC 
(rev 39488)
+++ haiku/trunk/src/apps/terminal/SmartTabView.h        2010-11-19 01:06:02 UTC 
(rev 39489)
@@ -48,6 +48,7 @@
 
        virtual void                            AddTab(BView* target, BTab* tab 
= NULL);
        virtual BTab*                           RemoveTab(int32 index);
+                       void                            MoveTab(int32 index, 
int32 newIndex);
 
        virtual BRect                           DrawTabs();
 


Other related posts:

  • » [haiku-commits] r39489 - haiku/trunk/src/apps/terminal - ingo_weinhold