diff --git a/src/kits/tracker/Pose.cpp b/src/kits/tracker/Pose.cpp index c2612f5aac..4ea99cb6bd 100644 --- a/src/kits/tracker/Pose.cpp +++ b/src/kits/tracker/Pose.cpp @@ -71,8 +71,8 @@ BPose::BPose(Model *model, BPoseView *view, uint32 clipboardMode, bool selected) fWidgetList(4, true), fClipboardMode(clipboardMode), fPercent(-1), + fSelectionTime(0), fIsSelected(selected), - fDelayedEdit(true), fHasLocation(false), fNeedsSaveLocation(false), fListModeInited(false), @@ -198,7 +198,7 @@ OneMouseUp(BTextWidget *widget, BPose *pose, BPoseView *poseView, BColumn *colum rect = widget->CalcClickRect(pose->Location(poseView), 0, poseView); if (rect.Contains(where)) { - widget->MouseUp(rect, poseView, pose, where, pose->DelayedEdit()); + widget->MouseUp(rect, poseView, pose, where); return true; } return false; diff --git a/src/kits/tracker/Pose.h b/src/kits/tracker/Pose.h index 568442c77d..200c0bea87 100644 --- a/src/kits/tracker/Pose.h +++ b/src/kits/tracker/Pose.h @@ -81,6 +81,7 @@ class BPose { void Select(bool selected); bool IsSelected() const; // Rename to IsHighlighted + bigtime_t SelectionTime() const; BTextWidget *ActiveWidget() const; BTextWidget *WidgetFor(uint32 hashAttr, int32 *index = 0) const; @@ -138,9 +139,9 @@ class BPose { uint32 fClipboardMode; int32 fPercent; + bigtime_t fSelectionTime; bool fIsSelected : 1; - bool fDelayedEdit : 1; bool fHasLocation : 1; bool fNeedsSaveLocation : 1; bool fListModeInited : 1; @@ -176,20 +177,15 @@ inline void BPose::Select(bool on) { fIsSelected = on; + if (on) + fSelectionTime = system_time(); } -inline bool -BPose::DelayedEdit() const +inline bigtime_t +BPose::SelectionTime() const { - return fDelayedEdit; -} - - -inline void -BPose::SetDelayedEdit(bool on) -{ - fDelayedEdit = on; + return fSelectionTime; } diff --git a/src/kits/tracker/TextWidget.cpp b/src/kits/tracker/TextWidget.cpp index 9c96045c47..1eeef941cd 100644 --- a/src/kits/tracker/TextWidget.cpp +++ b/src/kits/tracker/TextWidget.cpp @@ -211,45 +211,20 @@ BTextWidget::CalcClickRect(BPoint poseLoc, const BColumn *column, void -BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint, - bool delayedEdit) +BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint) { - // wait until a double click time to see if we are double clicking - // or selecting widget for editing - // start editing early if mouse left widget or modifier down - - if (!IsEditable()) - return; - - if (delayedEdit) { - bigtime_t doubleClickTime; - get_click_speed(&doubleClickTime); - doubleClickTime += system_time(); - - while (system_time() < doubleClickTime) { - // loop for double-click time and watch the mouse and keyboard - - BPoint point; - uint32 buttons; - view->GetMouse(&point, &buttons, false); - if (buttons) - // if mouse button goes down then a double click, exit - // without editing - return; - - if (!bounds.Contains(point)) - // mouse has moved outside of text widget so go into edit mode - break; - - if (modifiers() & (B_SHIFT_KEY | B_COMMAND_KEY | B_CONTROL_KEY | B_MENU_KEY)) - // watch the keyboard (ignoring standard locking keys) - break; - - snooze(100000); - } + // start editing if the duration between the pose selection time and + // the click on the widget is bigger than the doubleclick threshold. + + if (IsEditable() && pose->IsSelected()) { + bigtime_t delta = system_time() - pose->SelectionTime(); + bigtime_t doubleClickSpeed; + get_click_speed(&doubleClickSpeed); + + // TODO: modifiers + if (delta > doubleClickSpeed) + StartEdit(bounds, view, pose); } - - StartEdit(bounds, view, pose); } diff --git a/src/kits/tracker/TextWidget.h b/src/kits/tracker/TextWidget.h index f9fe3a86e5..697a8f1e6c 100644 --- a/src/kits/tracker/TextWidget.h +++ b/src/kits/tracker/TextWidget.h @@ -56,8 +56,8 @@ public: // second call is used for offscreen drawing, where PoseView // and current drawing view are different - void MouseUp(BRect bounds, BPoseView *, BPose *, BPoint mouseLoc, - bool delayedEdit); + void MouseUp(BRect bounds, BPoseView *, BPose *, BPoint mouseLoc); + BRect CalcRect(BPoint poseLoc, const BColumn *, const BPoseView *); // returns the rect derived from the formatted string width // may force WidgetAttributeText recalculation