[haiku-webkit-commits] r233 - webkit/trunk/WebKit/haiku/HaikuLauncher

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Sat, 27 Feb 2010 12:26:17 +0000

Author: stippi
Date: Sat Feb 27 12:26:17 2010
New Revision: 233
URL: http://mmlr.dyndns.org/changeset/233

Log:
Instead of hiding the tab view when there is only one tab, make the tab close
buttons only available when there is more than one tab. This gives a more
consistent interface and doesn't hide features, most importantly the "Add tab"
button. For users that wish the most minimalistic UI, this behavior could
later be configurable (along with opening new windows versus new tabs).

Modified:
   webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp
   webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Sat Feb 27 
11:01:36 2010        (r232)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/LauncherWindow.cpp  Sat Feb 27 
12:26:17 2010        (r233)
@@ -692,7 +692,8 @@
 void LauncherWindow::updateTabGroupVisibility()
 {
        if (Lock()) {
-           m_tabGroup->SetVisible(m_tabManager->CountTabs() > 1);
+           //m_tabGroup->SetVisible(m_tabManager->CountTabs() > 1);
+           m_tabManager->SetCloseButtonsAvailable(m_tabManager->CountTabs() > 
1);
            Unlock();
        }
 }

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp      Sat Feb 27 
11:01:36 2010        (r232)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.cpp      Sat Feb 27 
12:26:17 2010        (r233)
@@ -187,8 +187,6 @@
 
 TabContainerView::~TabContainerView()
 {
-       // TODO: Not so nice, that we take ownership of the controller.
-       delete fController;
 }
 
 
@@ -717,8 +715,19 @@
 
        void CloseTab(int32 index);
 
+       void SetCloseButtonsAvailable(bool available)
+       {
+               fCloseButtonsAvailable = available;
+       }
+
+       bool CloseButtonsAvailable() const
+       {
+               return fCloseButtonsAvailable;
+       }
+
 private:
        TabManager* fManager;
+       bool fCloseButtonsAvailable;
 };
 
 
@@ -740,6 +749,8 @@
                const BMessage* dragMessage);
 
 private:
+       void _DrawCloseButton(BView* owner, BRect& frame, const BRect& 
updateRect,
+               bool isFirst, bool isLast, bool isFront);
        BRect _CloseRectFrame(BRect frame) const;
 
 private:
@@ -773,41 +784,8 @@
 WebTabView::DrawContents(BView* owner, BRect frame, const BRect& updateRect,
        bool isFirst, bool isLast, bool isFront)
 {
-       BRect closeRect = _CloseRectFrame(frame);
-       frame.right = closeRect.left - be_control_look->DefaultLabelSpacing();
-
-       closeRect.left = (closeRect.left + closeRect.right) / 2 - 3;
-       closeRect.right = closeRect.left + 6;
-       closeRect.top = (closeRect.top + closeRect.bottom) / 2 - 3;
-       closeRect.bottom = closeRect.top + 6;
-
-       rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
-       float tint = B_DARKEN_1_TINT;
-       if (!IsFront())
-               tint *= 1.02;
-
-       base = tint_color(base, tint);
-
-       if (fOverCloseRect)
-               tint *= 1.2;
-
-       if (fClicked && fOverCloseRect) {
-               BRect buttonRect(closeRect.InsetByCopy(-4, -4));
-               be_control_look->DrawButtonFrame(owner, buttonRect, updateRect,
-                       base, base,
-                       BControlLook::B_ACTIVATED | 
BControlLook::B_BLEND_FRAME);
-               be_control_look->DrawButtonBackground(owner, buttonRect, 
updateRect,
-                       base, BControlLook::B_ACTIVATED);
-               tint *= 1.2;
-               closeRect.OffsetBy(1, 1);
-       }
-
-       base = tint_color(base, tint);
-       owner->SetHighColor(base);
-       owner->SetPenSize(2);
-       owner->StrokeLine(closeRect.LeftTop(), closeRect.RightBottom());
-       owner->StrokeLine(closeRect.LeftBottom(), closeRect.RightTop());
-       owner->SetPenSize(1);
+       if (fController->CloseButtonsAvailable())
+               _DrawCloseButton(owner, frame, updateRect, isFirst, isLast, 
isFront);
 
        TabView::DrawContents(owner, frame, updateRect, isFirst, isLast, 
isFront);
 }
@@ -822,7 +800,7 @@
        }
 
        BRect closeRect = _CloseRectFrame(Frame());
-       if (!closeRect.Contains(where)) {
+       if (!fController->CloseButtonsAvailable() || 
!closeRect.Contains(where)) {
                TabView::MouseDown(where, buttons);
                return;
        }
@@ -851,11 +829,13 @@
 WebTabView::MouseMoved(BPoint where, uint32 transit,
        const BMessage* dragMessage)
 {
-       BRect closeRect = _CloseRectFrame(Frame());
-       bool overCloseRect = closeRect.Contains(where);
-       if (overCloseRect != fOverCloseRect) {
-               fOverCloseRect = overCloseRect;
-               ContainerView()->Invalidate(closeRect);
+       if (fController->CloseButtonsAvailable()) {
+               BRect closeRect = _CloseRectFrame(Frame());
+               bool overCloseRect = closeRect.Contains(where);
+               if (overCloseRect != fOverCloseRect) {
+                       fOverCloseRect = overCloseRect;
+                       ContainerView()->Invalidate(closeRect);
+               }
        }
 
        TabView::MouseMoved(where, transit, dragMessage);
@@ -870,12 +850,54 @@
 }
 
 
+void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
+       const BRect& updateRect, bool isFirst, bool isLast, bool isFront)
+{
+       BRect closeRect = _CloseRectFrame(frame);
+       frame.right = closeRect.left - be_control_look->DefaultLabelSpacing();
+
+       closeRect.left = (closeRect.left + closeRect.right) / 2 - 3;
+       closeRect.right = closeRect.left + 6;
+       closeRect.top = (closeRect.top + closeRect.bottom) / 2 - 3;
+       closeRect.bottom = closeRect.top + 6;
+
+       rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
+       float tint = B_DARKEN_1_TINT;
+       if (!IsFront())
+               tint *= 1.02;
+
+       base = tint_color(base, tint);
+
+       if (fOverCloseRect)
+               tint *= 1.2;
+
+       if (fClicked && fOverCloseRect) {
+               BRect buttonRect(closeRect.InsetByCopy(-4, -4));
+               be_control_look->DrawButtonFrame(owner, buttonRect, updateRect,
+                       base, base,
+                       BControlLook::B_ACTIVATED | 
BControlLook::B_BLEND_FRAME);
+               be_control_look->DrawButtonBackground(owner, buttonRect, 
updateRect,
+                       base, BControlLook::B_ACTIVATED);
+               tint *= 1.2;
+               closeRect.OffsetBy(1, 1);
+       }
+
+       base = tint_color(base, tint);
+       owner->SetHighColor(base);
+       owner->SetPenSize(2);
+       owner->StrokeLine(closeRect.LeftTop(), closeRect.RightBottom());
+       owner->StrokeLine(closeRect.LeftBottom(), closeRect.RightTop());
+       owner->SetPenSize(1);
+}
+
+
 // #pragma mark - TabManagerController
 
 
 TabManagerController::TabManagerController(TabManager* manager)
        :
-       fManager(manager)
+       fManager(manager),
+       fCloseButtonsAvailable(false)
 {
 }
 
@@ -1038,13 +1060,14 @@
 
 TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
     :
+    fController(new TabManagerController(this)),
     fTarget(target)
 {
        fContainerView = new BView("web view container", 0);
        fCardLayout = new BCardLayout();
        fContainerView->SetLayout(fCardLayout);
 
-       fTabContainerView = new TabContainerView(new 
TabManagerController(this));
+       fTabContainerView = new TabContainerView(fController);
        fTabContainerGroup = new BGroupView(B_HORIZONTAL);
        fTabContainerGroup->GroupLayout()->SetInsets(0, 5, 0, 0);
        fTabContainerGroup->GroupLayout()->AddView(fTabContainerView);
@@ -1059,6 +1082,7 @@
 
 TabManager::~TabManager()
 {
+       delete fController;
 }
 
 
@@ -1169,3 +1193,13 @@
        fTabContainerView->SetTabLabel(tabIndex, label);
 }
 
+
+void
+TabManager::SetCloseButtonsAvailable(bool available)
+{
+       if (available == fController->CloseButtonsAvailable())
+               return;
+       fController->SetCloseButtonsAvailable(available);
+       fTabContainerView->Invalidate();
+}
+

Modified: webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h
==============================================================================
--- webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h        Sat Feb 27 
11:01:36 2010        (r232)
+++ webkit/trunk/WebKit/haiku/HaikuLauncher/WebTabView.h        Sat Feb 27 
12:26:17 2010        (r233)
@@ -39,6 +39,7 @@
 class BCardLayout;
 class BGroupView;
 class TabContainerView;
+class TabManagerController;
 
 class TabManager {
 public:
@@ -64,12 +65,14 @@
                        int32                           CountTabs() const;
 
                        void                            SetTabLabel(int32 
tabIndex, const char* label);
+                       void                            
SetCloseButtonsAvailable(bool available);
 
 private:
                        BGroupView*                     fTabContainerGroup;
                        TabContainerView*       fTabContainerView;
                        BView*                          fContainerView;
                        BCardLayout*            fCardLayout;
+                       TabManagerController* fController;
 
                        BMessenger                      fTarget;
 };

Other related posts:

  • » [haiku-webkit-commits] r233 - webkit/trunk/WebKit/haiku/HaikuLauncher - webkit