[haiku-commits] haiku: hrev45472 - src/kits/tracker

  • From: jscipione@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 9 Apr 2013 09:01:24 +0200 (CEST)

hrev45472 adds 1 changeset to branch 'master'
old head: d45ea79290d07ba0f8a16fa77d4dc227213d75a8
new head: 7e702e52265d3cc0979ebf4c6ca501877e96fc66
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=7e702e5+%5Ed45ea79

----------------------------------------------------------------------------

7e702e5: Covert Tracker Find window to use ControlLook arrows
  
  Also fix a few style issues and make the MiniMenu control have a nice keyboard
  focus border.

                                     [ John Scipione <jscipione@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45472
Commit:      7e702e52265d3cc0979ebf4c6ca501877e96fc66
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7e702e5
Author:      John Scipione <jscipione@xxxxxxxxx>
Date:        Tue Apr  9 06:58:58 2013 UTC

----------------------------------------------------------------------------

4 files changed, 52 insertions(+), 138 deletions(-)
src/kits/tracker/DialogPane.cpp    | 104 +++++----------------------------
src/kits/tracker/FindPanel.cpp     |  26 +++++----
src/kits/tracker/FindPanel.h       |   2 +-
src/kits/tracker/MiniMenuField.cpp |  58 +++++++-----------

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/DialogPane.cpp b/src/kits/tracker/DialogPane.cpp
index ececc64..8473c24 100644
--- a/src/kits/tracker/DialogPane.cpp
+++ b/src/kits/tracker/DialogPane.cpp
@@ -34,6 +34,7 @@ All rights reserved.
 
 #include "DialogPane.h"
 
+#include <ControlLook.h>
 #include <LayoutUtils.h>
 
 #include "Thread.h"
@@ -73,7 +74,8 @@ ViewList::AddAll(BView* toParent)
 
 DialogPane::DialogPane(BRect mode1Frame, BRect mode2Frame, int32 initialMode,
        const char* name, uint32 followFlags, uint32 flags)
-       : BView(FrameForMode(initialMode, mode1Frame, mode2Frame, mode2Frame),
+       :
+       BView(FrameForMode(initialMode, mode1Frame, mode2Frame, mode2Frame),
                name, followFlags, flags),
        fMode(initialMode),
        fMode1Frame(mode1Frame),
@@ -495,103 +497,29 @@ PaneSwitch::Track(BPoint point, uint32)
 void
 PaneSwitch::DrawInState(PaneSwitch::State state)
 {
-       BRect rect(0, 0, 10, 10);
-
-       rgb_color outlineColor = {0, 0, 0, 255};
-       rgb_color middleColor = state == kPressed ? kHighlightColor : 
kNormalColor;
+       BRect rect(0, 0, 12, 12);
+       rect.OffsetBy(-1, -1);
 
-       SetDrawingMode(B_OP_COPY);
+       rgb_color arrowColor = state == kPressed ? kHighlightColor : 
kNormalColor;
+       int32 arrowDirection = BControlLook::B_RIGHT_ARROW;
+       float tint = IsEnabled() && Window()->IsActive() ? B_DARKEN_3_TINT
+               : B_DARKEN_1_TINT;
 
        switch (state) {
                case kCollapsed:
-                       BeginLineArray(6);
-
-                       if (fLeftAligned) {
-                               AddLine(BPoint(rect.left + 3, rect.top + 1),
-                                       BPoint(rect.left + 3, rect.bottom - 1), 
outlineColor);
-                               AddLine(BPoint(rect.left + 3, rect.top + 1),
-                                       BPoint(rect.left + 7, rect.top + 5), 
outlineColor);
-                               AddLine(BPoint(rect.left + 7, rect.top + 5),
-                                       BPoint(rect.left + 3, rect.bottom - 1), 
outlineColor);
-
-                               AddLine(BPoint(rect.left + 4, rect.top + 3),
-                                       BPoint(rect.left + 4, rect.bottom - 3), 
middleColor);
-                               AddLine(BPoint(rect.left + 5, rect.top + 4),
-                                       BPoint(rect.left + 5, rect.bottom - 4), 
middleColor);
-                               AddLine(BPoint(rect.left + 5, rect.top + 5),
-                                       BPoint(rect.left + 6, rect.top + 5), 
middleColor);
-                       } else {
-                               AddLine(BPoint(rect.right - 3, rect.top + 1),
-                                       BPoint(rect.right - 3, rect.bottom - 
1), outlineColor);
-                               AddLine(BPoint(rect.right - 3, rect.top + 1),
-                                       BPoint(rect.right - 7, rect.top + 5), 
outlineColor);
-                               AddLine(BPoint(rect.right - 7, rect.top + 5),
-                                       BPoint(rect.right - 3, rect.bottom - 
1), outlineColor);
-
-                               AddLine(BPoint(rect.right - 4, rect.top + 3),
-                                       BPoint(rect.right - 4, rect.bottom - 
3), middleColor);
-                               AddLine(BPoint(rect.right - 5, rect.top + 4),
-                                       BPoint(rect.right - 5, rect.bottom - 
4), middleColor);
-                               AddLine(BPoint(rect.right - 5, rect.top + 5),
-                                       BPoint(rect.right - 6, rect.top + 5), 
middleColor);
-                       }
-                       EndLineArray();
+                       arrowDirection = BControlLook::B_RIGHT_ARROW;
                        break;
 
                case kPressed:
-                       BeginLineArray(7);
-                       if (fLeftAligned) {
-                               AddLine(BPoint(rect.left + 1, rect.top + 7),
-                                       BPoint(rect.left + 7, rect.top + 7), 
outlineColor);
-                               AddLine(BPoint(rect.left + 7, rect.top + 1),
-                                       BPoint(rect.left + 7, rect.top + 7), 
outlineColor);
-                               AddLine(BPoint(rect.left + 1, rect.top + 7),
-                                       BPoint(rect.left + 7, rect.top + 1), 
outlineColor);
-
-                               AddLine(BPoint(rect.left + 3, rect.top + 6),
-                                       BPoint(rect.left + 6, rect.top + 6), 
middleColor);
-                               AddLine(BPoint(rect.left + 4, rect.top + 5),
-                                       BPoint(rect.left + 6, rect.top + 5), 
middleColor);
-                               AddLine(BPoint(rect.left + 5, rect.top + 4),
-                                       BPoint(rect.left + 6, rect.top + 4), 
middleColor);
-                               AddLine(BPoint(rect.left + 6, rect.top + 3),
-                                       BPoint(rect.left + 6, rect.top + 4), 
middleColor);
-                       } else {
-                               AddLine(BPoint(rect.right - 1, rect.top + 7),
-                                       BPoint(rect.right - 7, rect.top + 7), 
outlineColor);
-                               AddLine(BPoint(rect.right - 7, rect.top + 1),
-                                       BPoint(rect.right - 7, rect.top + 7), 
outlineColor);
-                               AddLine(BPoint(rect.right - 1, rect.top + 7),
-                                       BPoint(rect.right - 7, rect.top + 1), 
outlineColor);
-
-                               AddLine(BPoint(rect.right - 3, rect.top + 6),
-                                       BPoint(rect.right - 6, rect.top + 6), 
middleColor);
-                               AddLine(BPoint(rect.right - 4, rect.top + 5),
-                                       BPoint(rect.right - 6, rect.top + 5), 
middleColor);
-                               AddLine(BPoint(rect.right - 5, rect.top + 4),
-                                       BPoint(rect.right - 6, rect.top + 4), 
middleColor);
-                               AddLine(BPoint(rect.right - 6, rect.top + 3),
-                                       BPoint(rect.right - 6, rect.top + 4), 
middleColor);
-                       }
-                       EndLineArray();
+                       arrowDirection = BControlLook::B_RIGHT_DOWN_ARROW;
                        break;
 
                case kExpanded:
-                       BeginLineArray(6);
-                       AddLine(BPoint(rect.left + 1, rect.top + 3),
-                               BPoint(rect.right - 1, rect.top + 3), 
outlineColor);
-                       AddLine(BPoint(rect.left + 1, rect.top + 3),
-                               BPoint(rect.left + 5, rect.top + 7), 
outlineColor);
-                       AddLine(BPoint(rect.left + 5, rect.top + 7),
-                               BPoint(rect.right - 1, rect.top + 3), 
outlineColor);
-
-                       AddLine(BPoint(rect.left + 3, rect.top + 4),
-                               BPoint(rect.right - 3, rect.top + 4), 
middleColor);
-                       AddLine(BPoint(rect.left + 4, rect.top + 5),
-                               BPoint(rect.right - 4, rect.top + 5), 
middleColor);
-                       AddLine(BPoint(rect.left + 5, rect.top + 5),
-                               BPoint(rect.left + 5, rect.top + 6), 
middleColor);
-                       EndLineArray();
+                       arrowDirection = BControlLook::B_DOWN_ARROW;
                        break;
        }
+
+       SetDrawingMode(B_OP_COPY);
+       be_control_look->DrawArrowShape(this, rect, rect, arrowColor,
+               arrowDirection, 0, tint);
 }
diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp
index 258f39b..6f92e7d 100644
--- a/src/kits/tracker/FindPanel.cpp
+++ b/src/kits/tracker/FindPanel.cpp
@@ -694,7 +694,7 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* 
parent,
 
        BMessenger self(this);
        fRecentQueries = new BPopUpMenu("RecentQueries");
-       FindPanel::AddRecentQueries(fRecentQueries,     true, &self,
+       FindPanel::AddRecentQueries(fRecentQueries, true, &self,
                kSwitchToQueryTemplate);
 
        AddChild(new MiniMenuField(rect, "RecentQueries", fRecentQueries));
@@ -781,9 +781,10 @@ FindPanel::FindPanel(BRect frame, BFile* node, FindWindow* 
parent,
 
        rect = expandedBounds;
        rect.right = rect.left + 200;
-       rect.bottom = rect.top + 20;;
+       rect.bottom = rect.top + 20;
        fQueryName = new BTextControl(rect, "queryName",
-               B_TRANSLATE("Query name:"), "", 0);
+               B_TRANSLATE("Query name:"), "", B_FOLLOW_NONE,
+               B_NAVIGABLE | B_NAVIGABLE_JUMP);
        fQueryName->SetDivider(fQueryName->StringWidth(fQueryName->Label()) + 
5);
        fMoreOptionsPane->AddItem(fQueryName, 1);
        FillCurrentQueryName(fQueryName, parent);
@@ -1886,7 +1887,6 @@ FindPanel::AddRecentQueries(BMenu* menu, bool 
addSaveAsItem,
        for (int32 index = 0; index < count; index++)
                AddOneRecentItem(&recentQueries.ItemAt(index)->first, &params);
 
-
        if (addSaveAsItem) {
                // add a Save as template item
                if (count || templates.CountItems())
@@ -1894,7 +1894,7 @@ FindPanel::AddRecentQueries(BMenu* menu, bool 
addSaveAsItem,
 
                BMessage* message = new BMessage(kRunSaveAsTemplatePanel);
                BMenuItem* item = new BMenuItem(
-                       B_TRANSLATE("Save Query as template"B_UTF8_ELLIPSIS), 
message);
+                       B_TRANSLATE("Save Query as template" B_UTF8_ELLIPSIS), 
message);
                menu->AddItem(item);
        }
 }
@@ -2420,7 +2420,8 @@ FindPanel::ShowOrHideMimeTypeMenu()
 
 
 TAttrView::TAttrView(BRect frame, int32 index)
-       :       BView(frame, "AttrView", B_FOLLOW_NONE, B_WILL_DRAW)
+       :
+       BView(frame, "AttrView", B_FOLLOW_NONE, B_WILL_DRAW)
 {
        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
        SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -3059,9 +3060,10 @@ 
DeleteTransientQueriesTask::StartUpTransientQueryCleaner()
 
 RecentFindItemsMenu::RecentFindItemsMenu(const char* title,
        const BMessenger* target, uint32 what)
-       :       BMenu(title, B_ITEMS_IN_COLUMN),
-               fTarget(*target),
-               fWhat(what)
+       :
+       BMenu(title, B_ITEMS_IN_COLUMN),
+       fTarget(*target),
+       fWhat(what)
 {
 }
 
@@ -3095,8 +3097,9 @@ TrackerBuildRecentFindItemsMenu(const char* title)
 DraggableQueryIcon::DraggableQueryIcon(BRect frame, const char* name,
        const BMessage* message, BMessenger messenger, uint32 resizeFlags,
                uint32 flags)
-       :       DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON,
-                       message, messenger, resizeFlags, flags)
+       :
+       DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON,
+               message, messenger, resizeFlags, flags)
 {
 }
 
@@ -3329,4 +3332,3 @@ MostUsedNames::UpdateList()
 }
 
 }      // namespace BPrivate
-
diff --git a/src/kits/tracker/FindPanel.h b/src/kits/tracker/FindPanel.h
index bffffc1..5bed25d 100644
--- a/src/kits/tracker/FindPanel.h
+++ b/src/kits/tracker/FindPanel.h
@@ -223,7 +223,7 @@ class FindPanel : public BView {
 
                void AddMimeTypesToMenu();
                        // populates the type menu
-               static bool AddOneMimeTypeToMenu(const ShortMimeInfo*, void*);
+               static bool AddOneMimeTypeToMenu(const ShortMimeInfo*, void* 
castToMenu);
 
                void AddVolumes(BMenu*);
                        // populates the volume menu
diff --git a/src/kits/tracker/MiniMenuField.cpp 
b/src/kits/tracker/MiniMenuField.cpp
index 27ac518..7821918 100644
--- a/src/kits/tracker/MiniMenuField.cpp
+++ b/src/kits/tracker/MiniMenuField.cpp
@@ -33,6 +33,8 @@ All rights reserved.
 */
 
 
+#include <ControlLook.h>
+#include <InterfaceDefs.h>
 #include <PopUpMenu.h>
 #include <Window.h>
 
@@ -96,10 +98,18 @@ void
 MiniMenuField::Draw(BRect)
 {
        BRect bounds(Bounds());
-       bounds.InsetBy(2, 2);
+       bounds.OffsetBy(1, 2);
+       bounds.right--;
+       bounds.bottom -= 2;
+       if (IsFocus()) {
+               // draw the focus indicator border
+               SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
+               StrokeRect(bounds);
+       }
+       bounds.right--;
+       bounds.bottom--;
        BRect rect(bounds);
-       rect.right--;
-       rect.bottom--;
+       rect.InsetBy(1, 1);
 
        rgb_color darkest = tint_color(kBlack, 0.6f);
        rgb_color dark = tint_color(kBlack, 0.4f);
@@ -121,43 +131,17 @@ MiniMenuField::Draw(BRect)
        AddLine(rect.RightBottom(), rect.LeftBottom(), medium);
        AddLine(rect.LeftBottom(), rect.LeftTop(), light);
        AddLine(rect.LeftTop(), rect.RightTop(), light);
-
        EndLineArray();
 
        // draw triangle
-       rect = BRect(5, 5, 15, 15);
-       const rgb_color outlineColor = kBlack;
-       const rgb_color middleColor = {150, 150, 150, 255};
-
-       BeginLineArray(5);
-       AddLine(BPoint(rect.left + 3, rect.top + 1),
-               BPoint(rect.left + 3, rect.top + 7), outlineColor);
-       AddLine(BPoint(rect.left + 3, rect.top + 1),
-               BPoint(rect.left + 6, rect.top + 4), outlineColor);
-       AddLine(BPoint(rect.left + 6, rect.top + 4),
-               BPoint(rect.left + 3, rect.top + 7), outlineColor);
-
-       AddLine(BPoint(rect.left + 4, rect.top + 3),
-               BPoint(rect.left + 4, rect.top + 5), middleColor);
-       AddLine(BPoint(rect.left + 5, rect.top + 4),
-               BPoint(rect.left + 5, rect.top + 4), middleColor);
-       EndLineArray();
-
-       // draw focus if focused, else erase focus
-       bounds = Bounds();
-       bool focused = IsFocus() && Window()->IsActive();
-       rgb_color markColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
-       rgb_color viewColor = ViewColor();
-       BeginLineArray(4);
-       AddLine(BPoint(bounds.left, bounds.top),
-               BPoint(bounds.right, bounds.top), focused ? markColor : 
viewColor);
-       AddLine(BPoint(bounds.right, bounds.top),
-               BPoint(bounds.right, bounds.bottom), focused ? markColor : 
viewColor);
-       AddLine(BPoint(bounds.right, bounds.bottom),
-               BPoint(bounds.left, bounds.bottom), focused ? markColor : 
viewColor);
-       AddLine(BPoint(bounds.left, bounds.bottom),
-               BPoint(bounds.left, bounds.top), focused ? markColor : 
viewColor);
-       EndLineArray();
+       rect = BRect(0, 0, 12, 12);
+       rect.OffsetBy(4, 4);
+       const rgb_color arrowColor = {150, 150, 150, 255};
+       float tint = Window()->IsActive() ? B_DARKEN_3_TINT : B_DARKEN_1_TINT;
+
+       SetDrawingMode(B_OP_COPY);
+       be_control_look->DrawArrowShape(this, rect, rect, arrowColor,
+               BControlLook::B_RIGHT_ARROW, 0, tint);
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev45472 - src/kits/tracker - jscipione