* 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),
|
fWidgetList(4, true),
|
||||||
fClipboardMode(clipboardMode),
|
fClipboardMode(clipboardMode),
|
||||||
fPercent(-1),
|
fPercent(-1),
|
||||||
|
fSelectionTime(0),
|
||||||
fIsSelected(selected),
|
fIsSelected(selected),
|
||||||
fDelayedEdit(true),
|
|
||||||
fHasLocation(false),
|
fHasLocation(false),
|
||||||
fNeedsSaveLocation(false),
|
fNeedsSaveLocation(false),
|
||||||
fListModeInited(false),
|
fListModeInited(false),
|
||||||
@@ -198,7 +198,7 @@ OneMouseUp(BTextWidget *widget, BPose *pose, BPoseView *poseView, BColumn *colum
|
|||||||
rect = widget->CalcClickRect(pose->Location(poseView), 0, poseView);
|
rect = widget->CalcClickRect(pose->Location(poseView), 0, poseView);
|
||||||
|
|
||||||
if (rect.Contains(where)) {
|
if (rect.Contains(where)) {
|
||||||
widget->MouseUp(rect, poseView, pose, where, pose->DelayedEdit());
|
widget->MouseUp(rect, poseView, pose, where);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+7
-11
@@ -81,6 +81,7 @@ class BPose {
|
|||||||
void Select(bool selected);
|
void Select(bool selected);
|
||||||
bool IsSelected() const;
|
bool IsSelected() const;
|
||||||
// Rename to IsHighlighted
|
// Rename to IsHighlighted
|
||||||
|
bigtime_t SelectionTime() const;
|
||||||
|
|
||||||
BTextWidget *ActiveWidget() const;
|
BTextWidget *ActiveWidget() const;
|
||||||
BTextWidget *WidgetFor(uint32 hashAttr, int32 *index = 0) const;
|
BTextWidget *WidgetFor(uint32 hashAttr, int32 *index = 0) const;
|
||||||
@@ -138,9 +139,9 @@ class BPose {
|
|||||||
|
|
||||||
uint32 fClipboardMode;
|
uint32 fClipboardMode;
|
||||||
int32 fPercent;
|
int32 fPercent;
|
||||||
|
bigtime_t fSelectionTime;
|
||||||
|
|
||||||
bool fIsSelected : 1;
|
bool fIsSelected : 1;
|
||||||
bool fDelayedEdit : 1;
|
|
||||||
bool fHasLocation : 1;
|
bool fHasLocation : 1;
|
||||||
bool fNeedsSaveLocation : 1;
|
bool fNeedsSaveLocation : 1;
|
||||||
bool fListModeInited : 1;
|
bool fListModeInited : 1;
|
||||||
@@ -176,20 +177,15 @@ inline void
|
|||||||
BPose::Select(bool on)
|
BPose::Select(bool on)
|
||||||
{
|
{
|
||||||
fIsSelected = on;
|
fIsSelected = on;
|
||||||
|
if (on)
|
||||||
|
fSelectionTime = system_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool
|
inline bigtime_t
|
||||||
BPose::DelayedEdit() const
|
BPose::SelectionTime() const
|
||||||
{
|
{
|
||||||
return fDelayedEdit;
|
return fSelectionTime;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void
|
|
||||||
BPose::SetDelayedEdit(bool on)
|
|
||||||
{
|
|
||||||
fDelayedEdit = on;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -211,45 +211,20 @@ BTextWidget::CalcClickRect(BPoint poseLoc, const BColumn *column,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint,
|
BTextWidget::MouseUp(BRect bounds, BPoseView *view, BPose *pose, BPoint)
|
||||||
bool delayedEdit)
|
|
||||||
{
|
{
|
||||||
// wait until a double click time to see if we are double clicking
|
// start editing if the duration between the pose selection time and
|
||||||
// or selecting widget for editing
|
// the click on the widget is bigger than the doubleclick threshold.
|
||||||
// start editing early if mouse left widget or modifier down
|
|
||||||
|
if (IsEditable() && pose->IsSelected()) {
|
||||||
if (!IsEditable())
|
bigtime_t delta = system_time() - pose->SelectionTime();
|
||||||
return;
|
bigtime_t doubleClickSpeed;
|
||||||
|
get_click_speed(&doubleClickSpeed);
|
||||||
if (delayedEdit) {
|
|
||||||
bigtime_t doubleClickTime;
|
// TODO: modifiers
|
||||||
get_click_speed(&doubleClickTime);
|
if (delta > doubleClickSpeed)
|
||||||
doubleClickTime += system_time();
|
StartEdit(bounds, view, pose);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StartEdit(bounds, view, pose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ public:
|
|||||||
// second call is used for offscreen drawing, where PoseView
|
// second call is used for offscreen drawing, where PoseView
|
||||||
// and current drawing view are different
|
// and current drawing view are different
|
||||||
|
|
||||||
void MouseUp(BRect bounds, BPoseView *, BPose *, BPoint mouseLoc,
|
void MouseUp(BRect bounds, BPoseView *, BPose *, BPoint mouseLoc);
|
||||||
bool delayedEdit);
|
|
||||||
BRect CalcRect(BPoint poseLoc, const BColumn *, const BPoseView *);
|
BRect CalcRect(BPoint poseLoc, const BColumn *, const BPoseView *);
|
||||||
// returns the rect derived from the formatted string width
|
// returns the rect derived from the formatted string width
|
||||||
// may force WidgetAttributeText recalculation
|
// may force WidgetAttributeText recalculation
|
||||||
|
|||||||
Reference in New Issue
Block a user