* Rewrote rename-click detection to be more usable. The code is much smaller
and is based on the pose selection time, not on click time. It is more robust and since the selection might have been by click, keyboard or selection rect, it makes the behavior very pleasant (in my opinion) for multiselections. Try and tell me! * Disabled the modifiers (first click editing). Too many of them, and conflicting with other usages, i'd like your opinions/preferences. * Removed old, hackish and now unused DelayedEdit/SetDelayedEdit stuff. Fixes #3617 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32529 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -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;
|
||||
|
||||
+7
-11
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user