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.
This commit is contained in:
John Scipione 2013-04-09 02:58:58 -04:00
parent d45ea79290
commit 7e702e5226
4 changed files with 51 additions and 137 deletions

View File

@ -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);
BRect rect(0, 0, 12, 12);
rect.OffsetBy(-1, -1);
rgb_color outlineColor = {0, 0, 0, 255};
rgb_color middleColor = state == kPressed ? kHighlightColor : kNormalColor;
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);
}

View File

@ -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,7 +3060,8 @@ DeleteTransientQueriesTask::StartUpTransientQueryCleaner()
RecentFindItemsMenu::RecentFindItemsMenu(const char* title,
const BMessenger* target, uint32 what)
: BMenu(title, B_ITEMS_IN_COLUMN),
:
BMenu(title, B_ITEMS_IN_COLUMN),
fTarget(*target),
fWhat(what)
{
@ -3095,7 +3097,8 @@ 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,
:
DraggableIcon(frame, name, B_QUERY_MIMETYPE, B_LARGE_ICON,
message, messenger, resizeFlags, flags)
{
}
@ -3329,4 +3332,3 @@ MostUsedNames::UpdateList()
}
} // namespace BPrivate

View File

@ -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

View File

@ -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};
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;
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();
SetDrawingMode(B_OP_COPY);
be_control_look->DrawArrowShape(this, rect, rect, arrowColor,
BControlLook::B_RIGHT_ARROW, 0, tint);
}