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

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 18 Nov 2010 16:41:06 +0100 (CET)

Author: bonefish
Date: 2010-11-18 16:41:06 +0100 (Thu, 18 Nov 2010)
New Revision: 39481
Changeset: http://dev.haiku-os.org/changeset/39481

Modified:
   haiku/trunk/src/apps/terminal/SmartTabView.cpp
   haiku/trunk/src/apps/terminal/TermWindow.cpp
   haiku/trunk/src/apps/terminal/TermWindow.h
Log:
* SmartTabView::MouseDown(): Also notify the listener when the click didn't hit
  a tab.
* TermWindow: Add a new tab on double-click in the tab view's tab-free area.


Modified: haiku/trunk/src/apps/terminal/SmartTabView.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/SmartTabView.cpp      2010-11-18 15:08:58 UTC 
(rev 39480)
+++ haiku/trunk/src/apps/terminal/SmartTabView.cpp      2010-11-18 15:41:06 UTC 
(rev 39481)
@@ -70,24 +70,22 @@
 
        if (CountTabs() > 1) {
                int32 tabIndex = _ClickedTabIndex(point);
-               if (tabIndex >= 0) {
-                       int32 buttons = 0;
-                       int32 clickCount = 0;
-                       Window()->CurrentMessage()->FindInt32("buttons", 
&buttons);
-                       Window()->CurrentMessage()->FindInt32("clicks", 
&clickCount);
+               int32 buttons = 0;
+               int32 clickCount = 0;
+               Window()->CurrentMessage()->FindInt32("buttons", &buttons);
+               Window()->CurrentMessage()->FindInt32("clicks", &clickCount);
 
-                       if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0 && 
clickCount == 2) {
-                               if (fListener != NULL)
-                                       fListener->TabDoubleClicked(this, 
point, tabIndex);
-                       } else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
-                               if (fListener != NULL)
-                                       fListener->TabRightClicked(this, point, 
tabIndex);
-                               handled = true;
-                       } else if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) {
-                               if (fListener != NULL)
-                                       fListener->TabMiddleClicked(this, 
point, tabIndex);
-                               handled = true;
-                       }
+               if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0 && clickCount == 2) 
{
+                       if (fListener != NULL)
+                               fListener->TabDoubleClicked(this, point, 
tabIndex);
+               } else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
+                       if (fListener != NULL)
+                               fListener->TabRightClicked(this, point, 
tabIndex);
+                       handled = true;
+               } else if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) {
+                       if (fListener != NULL)
+                               fListener->TabMiddleClicked(this, point, 
tabIndex);
+                       handled = true;
                }
        }
 

Modified: haiku/trunk/src/apps/terminal/TermWindow.cpp
===================================================================
--- haiku/trunk/src/apps/terminal/TermWindow.cpp        2010-11-18 15:08:58 UTC 
(rev 39480)
+++ haiku/trunk/src/apps/terminal/TermWindow.cpp        2010-11-18 15:41:06 UTC 
(rev 39481)
@@ -688,16 +688,7 @@
                }
 
                case kNewTab:
-                       if (fTabView->CountTabs() < kMaxTabs) {
-                               if (fFullScreen)
-                                       _ActiveTermView()->ScrollBar()->Show();
-
-                               ActiveProcessInfo info;
-                               if 
(_ActiveTermView()->GetActiveProcessInfo(info))
-                                       _AddTab(NULL, info.CurrentDirectory());
-                               else
-                                       _AddTab(NULL);
-                       }
+                       _NewTab();
                        break;
 
                case kCloseView:
@@ -838,6 +829,22 @@
 
 
 void
+TermWindow::_NewTab()
+{
+       if (fTabView->CountTabs() < kMaxTabs) {
+               if (fFullScreen)
+                       _ActiveTermView()->ScrollBar()->Show();
+
+               ActiveProcessInfo info;
+               if (_ActiveTermView()->GetActiveProcessInfo(info))
+                       _AddTab(NULL, info.CurrentDirectory());
+               else
+                       _AddTab(NULL);
+       }
+}
+
+
+void
 TermWindow::_AddTab(Arguments* args, const BString& currentDirectory)
 {
        int argc = 0;
@@ -1029,20 +1036,29 @@
 void
 TermWindow::TabDoubleClicked(SmartTabView* tabView, BPoint point, int32 index)
 {
-       // TODO:...
+       if (index >= 0) {
+               // TODO: Open the change title dialog!
+       } else {
+               // not clicked on a tab -- create a new one
+               _NewTab();
+       }
 }
 
 
 void
 TermWindow::TabMiddleClicked(SmartTabView* tabView, BPoint point, int32 index)
 {
-       _RemoveTab(index);
+       if (index >= 0)
+               _RemoveTab(index);
 }
 
 
 void
 TermWindow::TabRightClicked(SmartTabView* tabView, BPoint point, int32 index)
 {
+       if (index < 0)
+               return;
+
        TermView* termView = _TermViewAt(index);
        if (termView == NULL)
                return;

Modified: haiku/trunk/src/apps/terminal/TermWindow.h
===================================================================
--- haiku/trunk/src/apps/terminal/TermWindow.h  2010-11-18 15:08:58 UTC (rev 
39480)
+++ haiku/trunk/src/apps/terminal/TermWindow.h  2010-11-18 15:41:06 UTC (rev 
39481)
@@ -96,6 +96,7 @@
                        void                            _GetPreferredFont(BFont 
&font);
                        status_t                        _DoPageSetup();
                        void                            _DoPrint();
+                       void                            _NewTab();
                        void                            _AddTab(Arguments* args,
                                                                        const 
BString& currentDirectory
                                                                                
= BString());


Other related posts:

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