diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index 74934250a7..594eee30a8 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -99,6 +99,7 @@ void do_minimize_team(BRect zoomRect, team_id team, bool zoom); const float kDragSlop = 3.0f; namespace BPrivate { + const char *kAddOnsMenuName = "Add-Ons"; class DraggableContainerIcon : public BView { @@ -114,7 +115,9 @@ class DraggableContainerIcon : public BView { private: uint32 fDragButton; BPoint fClickPoint; + bool fDragStarted; }; + } // namespace BPrivate struct AddOneAddonParams { @@ -141,7 +144,12 @@ ActivateWindowFilter(BMessage *, BHandler **target, BMessageFilter *) { BView *view = dynamic_cast(*target); - if (view && !dynamic_cast(view) && view->Window()) + // activate the window if no PoseView or DraggableContainerIcon had been pressed + // (those will activate the window themselves, if necessary) + if (view + && !dynamic_cast(view) + && !dynamic_cast(view) + && view->Window()) view->Window()->Activate(true); return B_DISPATCH_MESSAGE; @@ -313,7 +321,8 @@ AddMimeTypeString(BObjectList &list, Model *model) DraggableContainerIcon::DraggableContainerIcon(BRect rect, const char *name, uint32 resizeMask) : BView(rect, name, resizeMask, B_WILL_DRAW), - fDragButton(0) + fDragButton(0), + fDragStarted(false) { } @@ -345,22 +354,31 @@ DraggableContainerIcon::MouseDown(BPoint point) kNormalIcon, B_MINI_ICON)) { // The click hit the icon, initiate a drag fDragButton = buttons & (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON); + fDragStarted = false; fClickPoint = point; - } + } else + fDragButton = 0; + + if (!fDragButton) + Window()->Activate(true); } void DraggableContainerIcon::MouseUp(BPoint /*point*/) { + if (!fDragStarted) + Window()->Activate(true); + fDragButton = 0; + fDragStarted = false; } void DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, const BMessage */*message*/) { - if (fDragButton == 0 + if (fDragButton == 0 || fDragStarted || (abs((int32)(point.x - fClickPoint.x)) <= kDragSlop && abs((int32)(point.y - fClickPoint.y)) <= kDragSlop)) return; @@ -431,6 +449,9 @@ DraggableContainerIcon::MouseMoved(BPoint point, uint32 /*transit*/, const BMess (modifiers() & B_OPTION_KEY) != 0 ? B_COPY_TARGET : B_MOVE_TARGET); } + fDragStarted = true; + fDragButton = 0; + DragMessage(&message, dragBitmap, B_OP_ALPHA, BPoint(fClickPoint.x + hIconOffset, fClickPoint.y), this); } @@ -445,9 +466,9 @@ DraggableContainerIcon::Draw(BRect /*updateRect*/) // Draw the icon, straddling the border SetDrawingMode(B_OP_OVER); - float iconOffset = (Bounds().Width()-B_MINI_ICON)/2; - IconCache::sIconCache->Draw(window->TargetModel(), this, BPoint(iconOffset, iconOffset), - kNormalIcon, B_MINI_ICON, true); + float iconOffset = (Bounds().Width() - B_MINI_ICON) / 2; + IconCache::sIconCache->Draw(window->TargetModel(), this, + BPoint(iconOffset, iconOffset), kNormalIcon, B_MINI_ICON, true); } @@ -457,39 +478,39 @@ DraggableContainerIcon::Draw(BRect /*updateRect*/) BContainerWindow::BContainerWindow(LockingList *list, uint32 containerWindowFlags, window_look look, window_feel feel, uint32 flags, uint32 workspace) - : BWindow(InitialWindowRect(feel), "TrackerWindow", look, feel, flags, + : BWindow(InitialWindowRect(feel), "TrackerWindow", look, feel, flags, workspace), - fFileContextMenu(NULL), - fWindowContextMenu(NULL), - fDropContextMenu(NULL), - fVolumeContextMenu(NULL), - fDragContextMenu(NULL), - fMoveToItem(NULL), - fCopyToItem(NULL), - fCreateLinkItem(NULL), - fOpenWithItem(NULL), - fNavigationItem(NULL), - fMenuBar(NULL), - fNavigator(NULL), - fPoseView(NULL), - fWindowList(list), - fAttrMenu(NULL), - fWindowMenu(NULL), - fFileMenu(NULL), - fSelectionWindow(NULL), - fTaskLoop(NULL), - fIsTrash(false), - fInTrash(false), - fIsPrinters(false), - fContainerWindowFlags(containerWindowFlags), - fBackgroundImage(NULL), - fSavedZoomRect(0, 0, -1, -1), - fContextMenu(NULL), - fDragMessage(NULL), - fCachedTypesList(NULL), - fStateNeedsSaving(false), - fSaveStateIsEnabled(true), - fIsWatchingPath(false) + fFileContextMenu(NULL), + fWindowContextMenu(NULL), + fDropContextMenu(NULL), + fVolumeContextMenu(NULL), + fDragContextMenu(NULL), + fMoveToItem(NULL), + fCopyToItem(NULL), + fCreateLinkItem(NULL), + fOpenWithItem(NULL), + fNavigationItem(NULL), + fMenuBar(NULL), + fNavigator(NULL), + fPoseView(NULL), + fWindowList(list), + fAttrMenu(NULL), + fWindowMenu(NULL), + fFileMenu(NULL), + fSelectionWindow(NULL), + fTaskLoop(NULL), + fIsTrash(false), + fInTrash(false), + fIsPrinters(false), + fContainerWindowFlags(containerWindowFlags), + fBackgroundImage(NULL), + fSavedZoomRect(0, 0, -1, -1), + fContextMenu(NULL), + fDragMessage(NULL), + fCachedTypesList(NULL), + fStateNeedsSaving(false), + fSaveStateIsEnabled(true), + fIsWatchingPath(false) { InitIconPreloader(); @@ -728,7 +749,7 @@ BContainerWindow::AddContextMenus() AddDropContextMenus(fDropContextMenu); fDragContextMenu = new BSlowContextMenu("DragContext"); - // will get added and built dynamically in ShowContextMenu + // will get added and built dynamically in ShowContextMenu } @@ -795,7 +816,8 @@ BContainerWindow::RepopulateMenus() SetupOpenWithMenu(fFileMenu); SetupMoveCopyMenus(selectCount - ? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef() : NULL, fFileMenu); + ? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef() : NULL, + fFileMenu); } @@ -847,7 +869,7 @@ BContainerWindow::Init(const BMessage *message) } // add folder icon to menu bar - if (!TargetModel()->IsRoot() && !TargetModel()->IsVolume() && !IsTrash() && !IsPrintersDir()) { + if (!TargetModel()->IsRoot() && !IsTrash() && !IsPrintersDir()) { float iconSize = fMenuBar->Bounds().Height() - 2; if (iconSize < 16) iconSize = 16; @@ -857,9 +879,10 @@ BContainerWindow::Init(const BMessage *message) "ThisContainer", B_FOLLOW_RIGHT); fMenuBar->AddChild(icon); } - } else + } else { // add equivalents of the menu shortcuts to the menuless desktop window AddShortcuts(); + } AddContextMenus(); AddShortcut('T', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(kDelete), PoseView()); diff --git a/src/kits/tracker/DeskWindow.cpp b/src/kits/tracker/DeskWindow.cpp index d852c6bb0c..c915db7a04 100644 --- a/src/kits/tracker/DeskWindow.cpp +++ b/src/kits/tracker/DeskWindow.cpp @@ -234,7 +234,12 @@ BDeskWindow::CreatePoseView(Model *model) rgb_color desktopColor = screen.DesktopColor(); if (desktopColor.alpha != 255) { desktopColor.alpha = 255; +#if B_BEOS_VERSION > B_BEOS_VERSION_5 + // This call seems to have the power to cause R5 to freeze! + // Please report if commenting this out helped or helped not + // on your system screen.SetDesktopColor(desktopColor); +#endif } fPoseView->SetViewColor(desktopColor); diff --git a/src/kits/tracker/FilePanel.cpp b/src/kits/tracker/FilePanel.cpp index c76f721783..e0d07d555a 100644 --- a/src/kits/tracker/FilePanel.cpp +++ b/src/kits/tracker/FilePanel.cpp @@ -34,6 +34,7 @@ All rights reserved. // Implementation for the public FilePanel object. +#include #include #include @@ -41,19 +42,24 @@ All rights reserved. #include "Commands.h" #include "FilePanelPriv.h" + // prototypes for some private kernel calls that will some day be public #if B_BEOS_VERSION_DANO -#define _IMPEXP_ROOT +# define _IMPEXP_ROOT +# define _IMPEXP_TRACKER #endif extern "C" _IMPEXP_ROOT int _kset_fd_limit_(int num); -#if B_BEOS_VERSION_DANO -#undef _IMPEXP_ROOT -#endif // these two calls are deprecated extern _IMPEXP_TRACKER void run_open_panel(); extern _IMPEXP_TRACKER void run_save_panel(); +#if B_BEOS_VERSION_DANO +# undef _IMPEXP_ROOT +# undef _IMPEXP_TRACKER +#endif + + void run_open_panel() { @@ -67,6 +73,9 @@ run_save_panel() } +// #pragma mark - + + BFilePanel::BFilePanel(file_panel_mode mode, BMessenger *target, const entry_ref *ref, uint32 nodeFlavors, bool multipleSelection, BMessage *message, BRefFilter *filter, bool modal, diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp index 72b26b68cd..51322ede75 100644 --- a/src/kits/tracker/PoseView.cpp +++ b/src/kits/tracker/PoseView.cpp @@ -217,7 +217,6 @@ BPoseView::BPoseView(Model *model, BRect bounds, uint32 viewMode, uint32 resizeM fIsWatchingDateFormatChange(false), fHasPosesInClipboard(false) { - fViewState->SetViewMode(viewMode); fShowSelectionWhenInactive = TrackerSettings().ShowSelectionWhenInactive(); fTransparentSelection = TrackerSettings().TransparentSelection(); @@ -301,7 +300,7 @@ BPoseView::InitCommon() EnableScrollBars(); StartWatching(); - // trun on volume node monitor, metamime monitor, etc. + // turn on volume node monitor, metamime monitor, etc. if (window && window->ShouldAddCountView()) AddCountView(); @@ -776,7 +775,11 @@ void BPoseView::StartWatching() { // watch volumes - TTracker::WatchNode(0, B_WATCH_MOUNT, this); + TTracker::WatchNode(NULL, B_WATCH_MOUNT, this); + + if (TargetModel() != NULL) + TTracker::WatchNode(TargetModel()->NodeRef(), B_WATCH_ATTR, this); + BMimeType::StartWatching(BMessenger(this)); } @@ -2864,7 +2867,7 @@ BPoseView::UpdatePosesClipboardModeFromClipboard(BMessage *clipboardReport) fSelectionList->MakeEmpty(); fMimeTypesInSelectionCache.MakeEmpty(); - SetHasPosesInClipboard(hasPosesInClipboard | fHasPosesInClipboard); + SetHasPosesInClipboard(hasPosesInClipboard || fHasPosesInClipboard); if (fullInvalidateNeeded) Invalidate(); @@ -2959,29 +2962,16 @@ BPoseView::NewFileFromTemplate(const BMessage *message) // try to place new item at click point or under mouse if possible PlaceFolder(&destEntryRef, message); - if (dir.InitCheck() == B_OK) { - // special-case directories - start renaming them - int32 index; - BPose *pose = EntryCreated(TargetModel()->NodeRef(), &destNodeRef, - destEntryRef.name, &index); + // start renaming the entry + int32 index; + BPose *pose = EntryCreated(TargetModel()->NodeRef(), &destNodeRef, + destEntryRef.name, &index); - if (pose) { - UpdateScrollRange(); - CommitActivePose(); - SelectPose(pose, index); - pose->EditFirstWidget(BPoint(0, index * fListElemHeight), this); - } - } else { - // open the corresponding application - BMessage openMessage(B_REFS_RECEIVED); - openMessage.AddRef("refs", &destEntryRef); - - // add a messenger to the launch message that will be used to - // dispatch scripting calls from apps to the PoseView - openMessage.AddMessenger("TrackerViewToken", BMessenger(this)); - - if (fSelectionHandler) - fSelectionHandler->PostMessage(&openMessage); + if (pose) { + UpdateScrollRange(); + CommitActivePose(); + SelectPose(pose, index); + pose->EditFirstWidget(BPoint(0, index * fListElemHeight), this); } } @@ -3878,7 +3868,7 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target // look for srcWindow to determine whether drag was initiated in tracker BContainerWindow *srcWindow = NULL; - message->FindPointer("src_window", (void **) &srcWindow); + message->FindPointer("src_window", (void **)&srcWindow); if (!srcWindow) { // drag was from another app @@ -4063,7 +4053,7 @@ BPoseView::HandleDropCommon(BMessage *message, Model *targetModel, BPose *target } // handle refs by performing a copy - BObjectList *entryList = new BObjectList(); + BObjectList *entryList = new BObjectList(10, true); for (int32 index = 0; ; index++) { // copy all enclosed refs into a list @@ -5098,6 +5088,19 @@ BPoseView::AttributeChanged(const BMessage *message) const char *attrName; message->FindString("attr", &attrName); + if (*TargetModel()->NodeRef() == itemNode && TargetModel()->AttrChanged(attrName)) { + // the icon of our target has changed, update drag icon + // TODO: make this simpler (ie. store the icon with the window) + BView *view = Window()->FindView("MenuBar"); + if (view != NULL) { + view = view->FindView("ThisContainer"); + if (view != NULL) { + IconCache::sIconCache->IconChanged(TargetModel()); + view->Invalidate(); + } + } + } + int32 index; BPose *pose = fPoseList->DeepFindPose(&itemNode, &index); if (pose) { @@ -8571,54 +8574,61 @@ BPoseView::MouseMoved(BPoint mouseLoc, uint32 moveCode, const BMessage *message) if (!fDropEnabled || !message) return; - BContainerWindow* window = dynamic_cast(Window()); + BContainerWindow* window = ContainerWindow(); if (!window) return; switch (moveCode) { case B_INSIDE_VIEW: case B_ENTERED_VIEW: - UpdateDropTarget(mouseLoc, message, window->ContextMenu()); - if (fDropTarget) { - bigtime_t dropMenuDelay; - get_click_speed(&dropMenuDelay); - dropMenuDelay *= 3; - - BContainerWindow *window = ContainerWindow(); - if (!window || !message || window->ContextMenu()) + { + UpdateDropTarget(mouseLoc, message, window->ContextMenu()); + if (fAutoScrollState == kAutoScrollOff) { + // turn on auto scrolling if it's not yet on + fAutoScrollState = kWaitForTransition; + window->SetPulseRate(100000); + } + + bigtime_t dropActionDelay; + get_click_speed(&dropActionDelay); + dropActionDelay *= 3; + + if (window->ContextMenu()) + break; + + bigtime_t clickTime = system_time(); + BPoint loc; + uint32 buttons; + GetMouse(&loc, &buttons); + for (;;) { + if (buttons == 0 + || fabs(loc.x - mouseLoc.x) > 4 || fabs(loc.y - mouseLoc.y) > 4) { + // only loop if mouse buttons are down + // moved the mouse, cancel showing the context menu break; + } - bigtime_t clickTime = system_time(); - BPoint loc; - uint32 buttons; - GetMouse(&loc, &buttons); - for (;;) { - if (buttons == 0 - || fabs(loc.x - mouseLoc.x) > 4 || fabs(loc.y - mouseLoc.y) > 4) - // only loop if mouse buttons are down - // moved the mouse, cancel showing the context menu - break; - - // handle drag and drop - bigtime_t now = system_time(); - // use shift key to get around over-loading of Control key - // for context menus and auto-dnd menu - if (((modifiers() & B_SHIFT_KEY) - && (now - clickTime) > 200000) - || now - clickTime > dropMenuDelay) { - // let go of button or pressing for a while, show menu now + // handle drag and drop + bigtime_t now = system_time(); + // use shift key to get around over-loading of Control key + // for context menus and auto-dnd menu + if (((modifiers() & B_SHIFT_KEY) && (now - clickTime) > 200000) + || now - clickTime > dropActionDelay) { + // let go of button or pressing for a while, show menu now + if (fDropTarget) { window->DragStart(message); FrameForPose(fDropTarget, true, &fStartFrame); ShowContextMenu(mouseLoc); - break; - } - - snooze(10000); - GetMouse(&loc, &buttons); + } else + window->Activate(); + break; } + snooze(10000); + GetMouse(&loc, &buttons); } break; + } case B_EXITED_VIEW: // ToDo: diff --git a/src/kits/tracker/QueryPoseView.cpp b/src/kits/tracker/QueryPoseView.cpp index 81ee0c491e..d711e50a27 100644 --- a/src/kits/tracker/QueryPoseView.cpp +++ b/src/kits/tracker/QueryPoseView.cpp @@ -454,7 +454,7 @@ QueryEntryListCollection::QueryEntryListCollection(Model *model, BHandler *targe if (model->Node()->GetAttrInfo(kAttrQueryVolume, &info) == B_OK) { char *buffer = NULL; - if ((buffer = (char *)malloc(info.size)) != NULL + if ((buffer = (char *)malloc((size_t)info.size)) != NULL && model->Node()->ReadAttr(kAttrQueryVolume, B_MESSAGE_TYPE, 0, buffer, (size_t)info.size) == info.size) { diff --git a/src/kits/tracker/StatusWindow.cpp b/src/kits/tracker/StatusWindow.cpp index 1a86de6435..4bb17dab2e 100644 --- a/src/kits/tracker/StatusWindow.cpp +++ b/src/kits/tracker/StatusWindow.cpp @@ -652,13 +652,13 @@ BStatusView::Draw(BRect) rgb_color light = tint_color(ViewColor(), B_LIGHTEN_MAX_TINT); rgb_color shadow = tint_color(ViewColor(), B_DARKEN_1_TINT); BeginLineArray(4); - AddLine(BPoint(bounds.left, bounds.bottom - 1.0), + AddLine(BPoint(bounds.left, bounds.bottom - 1.0f), BPoint(bounds.left, bounds.top), light); - AddLine(BPoint(bounds.left + 1.0, bounds.top), + AddLine(BPoint(bounds.left + 1.0f, bounds.top), BPoint(bounds.right, bounds.top), light); - AddLine(BPoint(bounds.right, bounds.top + 1.0), + AddLine(BPoint(bounds.right, bounds.top + 1.0f), BPoint(bounds.right, bounds.bottom), shadow); - AddLine(BPoint(bounds.right - 1.0, bounds.bottom), + AddLine(BPoint(bounds.right - 1.0f, bounds.bottom), BPoint(bounds.left, bounds.bottom), shadow); EndLineArray(); diff --git a/src/kits/tracker/TitleView.cpp b/src/kits/tracker/TitleView.cpp index 2349b8ca10..970dc8a310 100644 --- a/src/kits/tracker/TitleView.cpp +++ b/src/kits/tracker/TitleView.cpp @@ -48,12 +48,14 @@ All rights reserved. #include "PoseView.h" #include "Utilities.h" -const rgb_color kTitleBackground = {220, 220, 220, 255}; -const rgb_color kDarkTitleBackground = {180, 180, 180, 255}; +static rgb_color sTitleBackground; +static rgb_color sDarkTitleBackground; +static rgb_color sShineColor; +static rgb_color sLightShadowColor; +static rgb_color sShadowColor; +static rgb_color sDarkShadowColor; + const rgb_color kHighlightColor = {100, 100, 210, 255}; -const rgb_color kLightGray = {150, 150, 150, 255}; -const rgb_color kGray = {100, 100, 100, 255}; -const rgb_color kDarkGray = {70, 70, 70, 255}; const unsigned char kHorizontalResizeCursor[] = { 16, 1, 7, 7, @@ -64,18 +66,54 @@ const unsigned char kHorizontalResizeCursor[] = { }; +static void +_DrawLine(BPoseView *view, BPoint from, BPoint to) +{ + rgb_color highColor = view->HighColor(); + view->SetHighColor(kHighlightColor); + view->StrokeLine(from, to); + view->SetHighColor(highColor); +} + + +static void +_UndrawLine(BPoseView *view, BPoint from, BPoint to) +{ + view->StrokeLine(from, to, B_SOLID_LOW); +} + + +static void +_DrawOutline(BView *view, BRect where) +{ + where.InsetBy(1, 1); + rgb_color highColor = view->HighColor(); + view->SetHighColor(kHighlightColor); + view->StrokeRect(where); + view->SetHighColor(highColor); +} + + +// #pragma mark - + BTitleView::BTitleView(BRect frame, BPoseView *view) - : BView(frame, "TitleView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW), - fPoseView(view), - fTitleList(10, true), - fHorizontalResizeCursor(kHorizontalResizeCursor), - fPreviouslyClickedColumnTitle(0) - + : BView(frame, "TitleView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW), + fPoseView(view), + fTitleList(10, true), + fHorizontalResizeCursor(kHorizontalResizeCursor), + fPreviouslyClickedColumnTitle(0) { - SetHighColor(kTitleBackground); - SetLowColor(kTitleBackground); - SetViewColor(kTitleBackground); + sTitleBackground = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 0.88f); // 216 -> 220 + sDarkTitleBackground = tint_color(sTitleBackground, B_DARKEN_1_TINT); + sShineColor = tint_color(sTitleBackground, B_LIGHTEN_MAX_TINT); + sLightShadowColor = tint_color(sTitleBackground, B_DARKEN_2_TINT); + sShadowColor = tint_color(sTitleBackground, B_DARKEN_4_TINT); + sDarkShadowColor = tint_color(sShadowColor, B_DARKEN_2_TINT); + + SetHighColor(sTitleBackground); + SetLowColor(sTitleBackground); + SetViewColor(sTitleBackground); BFont font(be_plain_font); font.SetSize(9); @@ -84,10 +122,12 @@ BTitleView::BTitleView(BRect frame, BPoseView *view) Reset(); } + BTitleView::~BTitleView() { } + void BTitleView::Reset() { @@ -100,12 +140,13 @@ BTitleView::Reset() } } + void BTitleView::AddTitle(BColumn *column, const BColumn *after) { int32 count = fTitleList.CountItems(); int32 index; - if (after) + if (after) { for (index = 0; index < count; index++) { BColumn *titleColumn = fTitleList.ItemAt(index)->Column(); @@ -114,13 +155,14 @@ BTitleView::AddTitle(BColumn *column, const BColumn *after) break; } } - else + } else index = count; fTitleList.AddItem(new BColumnTitle(this, column), index); Invalidate(); } + void BTitleView::RemoveTitle(BColumn *column) { @@ -136,12 +178,14 @@ BTitleView::RemoveTitle(BColumn *column) Invalidate(); } + void BTitleView::Draw(BRect rect) { Draw(rect, false); } + void BTitleView::Draw(BRect, bool useOffscreen, bool updateOnly, const BColumnTitle *pressedColumn, @@ -174,12 +218,12 @@ BTitleView::Draw(BRect, bool useOffscreen, bool updateOnly, view->FillRect(bounds, B_SOLID_LOW); view->BeginLineArray(4); - view->AddLine(bounds.LeftTop(), bounds.RightTop(), kGray); - view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), kGray); + view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShadowColor); + view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sShadowColor); // draw lighter gray and white inset lines bounds.InsetBy(0, 1); - view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), kLightGray); - view->AddLine(bounds.LeftTop(), bounds.RightTop(), kWhite); + view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sLightShadowColor); + view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShineColor); view->EndLineArray(); int32 count = fTitleList.CountItems(); @@ -201,8 +245,8 @@ BTitleView::Draw(BRect, bool useOffscreen, bool updateOnly, tmp.left = minx; tmp.InsetBy(-1, 0); view->BeginLineArray(2); - view->AddLine(tmp.LeftTop(), tmp.LeftBottom(), kGray); - view->AddLine(tmp.RightTop(), tmp.RightBottom(), kWhite); + view->AddLine(tmp.LeftTop(), tmp.LeftBottom(), sShadowColor); + view->AddLine(tmp.RightTop(), tmp.RightBottom(), sShineColor); view->EndLineArray(); if (useOffscreen) { @@ -215,6 +259,7 @@ BTitleView::Draw(BRect, bool useOffscreen, bool updateOnly, (trackRectBlitter)(view, passThru); } + void BTitleView::MouseDown(BPoint where) { @@ -255,7 +300,6 @@ BTitleView::MouseDown(BPoint where) if (resizedTitle) { bool force = static_cast(buttons & B_TERTIARY_MOUSE_BUTTON); if (force || buttons & B_PRIMARY_MOUSE_BUTTON) { - if (force || fPreviouslyClickedColumnTitle != 0) { if (force || system_time() - fPreviousLeftClickTime < doubleClickSpeed) { if (fPoseView->ResizeColumnToWidest(resizedTitle->Column())) { @@ -269,13 +313,13 @@ BTitleView::MouseDown(BPoint where) } } else if (!title) return; - + ColumnTrackState *trackState; if (resizedTitle) trackState = new ColumnResizeState(this, resizedTitle, where); else trackState = new ColumnDragState(this, title, where); - + // track the mouse // - if it is pressed shortly and not moved, it is a click // all else is a track @@ -306,13 +350,13 @@ BTitleView::MouseDown(BPoint where) if (!pastClick && system_time() > pastClickTime) pastClick = true; - snooze(15000); } delete trackState; } + void BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage *message) { @@ -331,6 +375,7 @@ BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage *message) _inherited::MouseMoved(where, code, message); } + BColumnTitle * BTitleView::InColumnResizeArea(BPoint where) const { @@ -344,6 +389,7 @@ BTitleView::InColumnResizeArea(BPoint where) const return NULL; } + BColumnTitle * BTitleView::FindColumnTitle(BPoint where) const { @@ -357,6 +403,7 @@ BTitleView::FindColumnTitle(BPoint where) const return NULL; } + BColumnTitle * BTitleView::FindColumnTitle(const BColumn *column) const { @@ -370,6 +417,18 @@ BTitleView::FindColumnTitle(const BColumn *column) const return NULL; } + +// #pragma mark - + + +BColumnTitle::BColumnTitle(BTitleView *view, BColumn *column) + : + fColumn(column), + fParent(view) +{ +} + + bool BColumnTitle::InColumnResizeArea(BPoint where) const { @@ -380,11 +439,6 @@ BColumnTitle::InColumnResizeArea(BPoint where) const return edge.Contains(where); } -BColumnTitle::BColumnTitle(BTitleView *view, BColumn *column) - : fColumn(column), - fParent(view) -{ -} BRect BColumnTitle::Bounds() const @@ -395,24 +449,20 @@ BColumnTitle::Bounds() const return bounds; } + void BColumnTitle::Draw(BView *view, bool pressed) { BRect bounds(Bounds()); BPoint loc(0, bounds.bottom - 4); - if (pressed) - view->SetLowColor(kDarkTitleBackground); - else - view->SetLowColor(kTitleBackground); - + view->SetLowColor(pressed ? sDarkTitleBackground : sTitleBackground); view->FillRect(bounds, B_SOLID_LOW); BString titleString(fColumn->Title()); view->TruncateString(&titleString, B_TRUNCATE_END, bounds.Width() - kTitleColumnExtraMargin); float resultingWidth = view->StringWidth(titleString.String()); - switch (fColumn->Alignment()) { case B_ALIGN_LEFT: @@ -449,33 +499,39 @@ BColumnTitle::Draw(BView *view, bool pressed) BRect rect(bounds); - view->SetHighColor(kGray); + view->SetHighColor(sShadowColor); view->StrokeRect(rect); - + view->BeginLineArray(4); // draw lighter gray and white inset lines rect.InsetBy(1, 1); view->AddLine(rect.LeftBottom(), rect.RightBottom(), - pressed ? kLightGray : kLightGray); + pressed ? sLightShadowColor : sLightShadowColor); view->AddLine(rect.LeftTop(), rect.RightTop(), - pressed ? kDarkGray: kWhite); + pressed ? sDarkShadowColor : sShineColor); view->AddLine(rect.LeftTop(), rect.LeftBottom(), - pressed ? kDarkGray : kWhite); + pressed ? sDarkShadowColor : sShineColor); view->AddLine(rect.RightTop(), rect.RightBottom(), - pressed ? kLightGray : kLightGray); - + pressed ? sLightShadowColor : sLightShadowColor); + view->EndLineArray(); } + +// #pragma mark - + + ColumnTrackState::ColumnTrackState(BTitleView *view, BColumnTitle *title, BPoint where) - : fTitleView(view), - fTitle(title), - fLastPos(where) + : + fTitleView(view), + fTitle(title), + fLastPos(where) { } + void ColumnTrackState::MouseMoved(BPoint where, uint32 buttons) { @@ -486,15 +542,20 @@ ColumnTrackState::MouseMoved(BPoint where, uint32 buttons) fLastPos = where; } + +// #pragma mark - + + ColumnResizeState::ColumnResizeState(BTitleView *view, BColumnTitle *title, BPoint where) - : ColumnTrackState(view, title, where), - fLastLineDrawPos(-1), - fInitialTrackOffset((title->fColumn->Offset() + title->fColumn->Width()) - where.x) + : ColumnTrackState(view, title, where), + fLastLineDrawPos(-1), + fInitialTrackOffset((title->fColumn->Offset() + title->fColumn->Width()) - where.x) { DrawLine(); } + bool ColumnResizeState::ValueChanged(BPoint where) { @@ -505,20 +566,6 @@ ColumnResizeState::ValueChanged(BPoint where) return newWidth != fTitle->fColumn->Width(); } -static void -_DrawLine(BPoseView *view, BPoint from, BPoint to) -{ - rgb_color highColor = view->HighColor(); - view->SetHighColor(kHighlightColor); - view->StrokeLine(from, to); - view->SetHighColor(highColor); -} - -static void -_UndrawLine(BPoseView *view, BPoint from, BPoint to) -{ - view->StrokeLine(from, to, B_SOLID_LOW); -} void ColumnResizeState::Moved(BPoint where, uint32) @@ -542,18 +589,21 @@ ColumnResizeState::Moved(BPoint where, uint32) fTitleView->Draw(bounds, true, false); } + void ColumnResizeState::Done(BPoint) { UndrawLine(); } + void ColumnResizeState::Clicked(BPoint, uint32) { UndrawLine(); } + void ColumnResizeState::DrawLine() { @@ -569,6 +619,7 @@ ColumnResizeState::DrawLine() _DrawLine(poseView, poseViewBounds.LeftTop(), poseViewBounds.LeftBottom()); } + void ColumnResizeState::UndrawLine() { @@ -583,12 +634,14 @@ ColumnResizeState::UndrawLine() } +// #pragma mark - + ColumnDragState::ColumnDragState(BTitleView *view, BColumnTitle *columnTitle, BPoint where) - : ColumnTrackState(view, columnTitle, where), - fInitialMouseTrackOffset(where.x), - fTrackingRemovedColumn(false) + : ColumnTrackState(view, columnTitle, where), + fInitialMouseTrackOffset(where.x), + fTrackingRemovedColumn(false) { ASSERT(columnTitle); ASSERT(fTitle); @@ -596,15 +649,6 @@ ColumnDragState::ColumnDragState(BTitleView *view, BColumnTitle *columnTitle, DrawPressNoOutline(); } -static void -_DrawOutline(BView *view, BRect where) -{ - where.InsetBy(1, 1); - rgb_color highColor = view->HighColor(); - view->SetHighColor(kHighlightColor); - view->StrokeRect(where); - view->SetHighColor(highColor); -} // ToDo: // Autoscroll when dragging column left/right @@ -613,7 +657,6 @@ _DrawOutline(BView *view, BRect where) void ColumnDragState::Moved(BPoint where, uint32) { - // figure out where we are with the mouse BRect titleBounds(fTitleView->Bounds()); bool overTitleView = titleBounds.Contains(where); @@ -685,6 +728,7 @@ ColumnDragState::Moved(BPoint where, uint32) UndrawOutline(); } + void ColumnDragState::Done(BPoint) { @@ -693,6 +737,7 @@ ColumnDragState::Done(BPoint) UndrawOutline(); } + void ColumnDragState::Clicked(BPoint, uint32) { @@ -731,6 +776,7 @@ ColumnDragState::Clicked(BPoint, uint32) poseView->Invalidate(); } + void ColumnDragState::Pressing(BPoint, uint32) { @@ -743,12 +789,14 @@ ColumnDragState::ValueChanged(BPoint) return true; } + void ColumnDragState::DrawPressNoOutline() { fTitleView->Draw(fTitleView->Bounds(), true, false, fTitle); } + void ColumnDragState::DrawOutline(float pos) { @@ -757,6 +805,7 @@ ColumnDragState::DrawOutline(float pos) fTitleView->Draw(fTitleView->Bounds(), true, false, fTitle, _DrawOutline, outline); } + void ColumnDragState::UndrawOutline() { diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index df524481e8..4e7fb0a402 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -1463,22 +1463,23 @@ TTracker::WatchNode(const node_ref *node, uint32 flags, BMessenger target) { status_t result = watch_node(node, flags, target); - - if (result == B_OK || result != ENOMEM) + if (result == B_OK || result != B_NO_MEMORY) { // need to make sure this uses the same error value as // the node monitor code return result; - + } + PRINT(("failed to start monitoring, trying to allocate more " "node monitors\n")); TTracker *tracker = dynamic_cast(be_app); - if (!tracker) + if (!tracker) { // we are the file panel only, just fail return result; + } result = tracker->NeedMoreNodeMonitors(); - + if (result != B_OK) { PRINT(("failed to allocate more node monitors, %s\n", strerror(result))); diff --git a/src/kits/tracker/Utilities.cpp b/src/kits/tracker/Utilities.cpp index d655044b37..229232e095 100644 --- a/src/kits/tracker/Utilities.cpp +++ b/src/kits/tracker/Utilities.cpp @@ -302,7 +302,7 @@ void OffscreenBitmap::NewBitmap(BRect bounds) { delete fBitmap; - fBitmap = new BBitmap(bounds, B_COLOR_8_BIT, true); + fBitmap = new BBitmap(bounds, B_RGB32, true); if (fBitmap->Lock()) { BView *view = new BView(fBitmap->Bounds(), "", B_FOLLOW_NONE, 0); fBitmap->AddChild(view);