void BTitleView::MouseDown(BPoint where) { BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window()); if (window == NULL) return; if (!window->IsActive()) { // window wasn't active, activate it and bail window->Activate(); return; } // finish any pending edits fPoseView->CommitActivePose(); BColumnTitle* title = FindColumnTitle(where); BColumnTitle* resizedTitle = InColumnResizeArea(where); uint32 buttons; GetMouse(&where, &buttons); // Check if the user clicked the secondary mouse button. // if so, display the attribute menu: if (SecondaryMouseButtonDown(modifiers(), buttons)) { BPopUpMenu* menu = new BPopUpMenu("Attributes", false, false); menu->SetFont(be_plain_font); window->NewAttributeMenu(menu); window->AddMimeTypesToMenu(menu); window->MarkAttributeMenu(menu); menu->SetTargetForItems(window->PoseView()); menu->Go(ConvertToScreen(where), true, false); return; } bigtime_t doubleClickSpeed; get_click_speed(&doubleClickSpeed); if (resizedTitle) { bool force = static_cast<bool>(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())) { Invalidate(); return; } } } fPreviousLeftClickTime = system_time(); fPreviouslyClickedColumnTitle = resizedTitle; } } else if (!title) return; SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); // track the mouse if (resizedTitle) { fTrackingState = new ColumnResizeState(this, resizedTitle, where, system_time() + doubleClickSpeed); } else { fTrackingState = new ColumnDragState(this, title, where, system_time() + doubleClickSpeed); } }
void TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, const BMessage *stateMessage) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow *window = NULL; if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) // find out if window already open window = FindContainerWindow(model->NodeRef()); bool someWindowActivated = false; uint32 workspace = (uint32)(1 << current_workspace()); int32 windowCount = 0; while (window) { // At least one window open, just pull to front // make sure we don't jerk workspaces around uint32 windowWorkspaces = window->Workspaces(); if (windowWorkspaces & workspace) { window->Activate(); someWindowActivated = true; } window = FindContainerWindow(model->NodeRef(), ++windowCount); } if (someWindowActivated) { delete model; return; } // If no window was actiated, (none in the current workspace // we open a new one. if (openSelector == kRunOpenWithWindow) { BMessage *refList = NULL; if (!originalRefsList) { // when passing just a single model, stuff it's entry in a single // element list anyway ASSERT(model); refList = new BMessage; refList->AddRef("refs", model->EntryRef()); delete model; model = NULL; } else // clone the message, window adopts it for it's own use refList = new BMessage(*originalRefsList); window = new OpenWithContainerWindow(refList, &fWindowList); } else if (model->IsRoot()) { // window will adopt the model window = new BVolumeWindow(&fWindowList, openFlags); } else if (model->IsQuery()) { // window will adopt the model window = new BQueryContainerWindow(&fWindowList, openFlags); } else // window will adopt the model window = new BContainerWindow(&fWindowList, openFlags); if (model) window->CreatePoseView(model); BMessage restoreStateMessage(kRestoreState); if (stateMessage) restoreStateMessage.AddMessage("state", stateMessage); window->PostMessage(&restoreStateMessage); }
void TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, const BMessage* stateMessage) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow* window = NULL; const node_ref* modelNodeRef = model->NodeRef(); if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) { // find out if window already open window = FindContainerWindow(modelNodeRef); } bool someWindowActivated = false; uint32 workspace = (uint32)(1 << current_workspace()); int32 windowCount = 0; while (window != NULL) { if ((window->Workspaces() & workspace) != 0 && (dynamic_cast<BDeskWindow*>(window) == NULL || !TrackerSettings().SingleWindowBrowse())) { // We found at least one window that is open and is not Desktop // or we're in spatial mode, activate it and make sure we don't // jerk the workspaces around. window->Activate(); someWindowActivated = true; } window = FindContainerWindow(model->NodeRef(), ++windowCount); } if (someWindowActivated) { delete model; return; } // If no window was activated (none in the current workspace), // we open a new one. if (openSelector == kRunOpenWithWindow) { BMessage* refList = NULL; if (originalRefsList == NULL) { // when passing just a single model, stuff it's entry in a single // element list anyway ASSERT(model != NULL); refList = new BMessage; refList->AddRef("refs", model->EntryRef()); delete model; model = NULL; } else { // clone the message, window adopts it for it's own use refList = new BMessage(*originalRefsList); } window = new OpenWithContainerWindow(refList, &fWindowList); } else if (model->IsQuery()) { // window will adopt the model window = new BQueryContainerWindow(&fWindowList, openFlags); } else if (model->IsVirtualDirectory()) { // window will adopt the model window = new VirtualDirectoryWindow(&fWindowList, openFlags); } else { // window will adopt the model window = new BContainerWindow(&fWindowList, openFlags); } if (model != NULL) window->CreatePoseView(model); BMessage restoreStateMessage(kRestoreState); if (stateMessage != NULL) restoreStateMessage.AddMessage("state", stateMessage); window->PostMessage(&restoreStateMessage); }