Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 3cb73a5

Browse files
[[ DataGrid 2]] Assorted bug fixes.
Manually send reorder move. This effectively throttles the mouse move message (which was interfering with animations in certain situations) and also means that we allow widgets to be used as reorder controls (since widgets don't pass mouse move by default). Make sure to set the horozontal position of the reorder control in the LayoutControl handler. This ensures the reorder control is in the correct pisition after scrolls and resizes. Extend the reorder scroll check to beyond the rect of the data grid. This means users can drag above or below the group and the scroll will continue. Make sure we send the animation pulse message at the correct intervals. Use the correct animation properties for animating the reoder control. Correctly check the bounds on reordering, preventing reodering line numbers not in the datagrid.
1 parent 8089bd6 commit 3cb73a5

2 files changed

Lines changed: 44 additions & 22 deletions

File tree

Toolset/palettes/revdatagridlibrary/behaviorsdatagridbuttonbehavior.livecodescript

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ local sReorderStartIndex
8181
local sReorderStartLine
8282
local sReorderLastHoverLine
8383
local sReorderMouseMoveInProgress
84+
local sReorderMoveMsgId
85+
86+
constant sReorderMovePollRate = 30
8487

8588
constant kReorderDragControlBlendLevel = 30
8689
constant kReorderDragControlGlowColor = "0,0,0"
@@ -9604,6 +9607,9 @@ private command DG2_ClearVars
96049607
put empty into sReorderLastHoverLine
96059608
put false into sReorderMouseMoveInProgress
96069609

9610+
cancel sReorderMoveMsgId
9611+
put empty into sReorderMoveMsgId
9612+
96079613
cancel sAnimationsPulseMsgID
96089614
put empty into sAnimationsPulseMsgID
96099615
put empty into sAnimationsA
@@ -9933,10 +9939,10 @@ on DG2_EditModeEnterDrawCallback @pContextA, pControl, pLineNo, @pControlRect, @
99339939
-- thus not effected by the control sliding in from the right (which would naturally
99349940
-- move the roerder control right).
99359941
add 1 to pContextA["animation count"]
9936-
put DG2_AnimationsAnimationCreate(tReorderControl, "left", the left of tReorderControl, the left of tReorderControl, the dgAnimationProp["EditModeEnterExitDuration"] of me, the dgAnimationProp["EditModeEnterExitReorderControlEasing"] of me) into pContextA["animations"][pContextA["animation count"]]
9942+
put DG2_AnimationsAnimationCreate(tReorderControl, "left", the left of tReorderControl, the left of tReorderControl, the dgAnimationProp["EditModeEnterExitDuration"] of me, "linear") into pContextA["animations"][pContextA["animation count"]]
99379943

99389944
add 1 to pContextA["animation count"]
9939-
put DG2_AnimationsAnimationCreate(tReorderControl, "blendLevel", 100, 0, the dgAnimationProp["EditModeEnterExitDuration"] of me, "linear") into pContextA["animations"][pContextA["animation count"]]
9945+
put DG2_AnimationsAnimationCreate(tReorderControl, "blendLevel", 100, 0, the dgAnimationProp["EditModeEnterExitDuration"] of me, the dgAnimationProp["EditModeEnterExitReorderControlEasing"] of me) into pContextA["animations"][pContextA["animation count"]]
99409946
end if
99419947

99429948
-- If the controls are cached, "LayoutControl" won't be called by the standard draw loop.
@@ -9995,10 +10001,10 @@ on DG2_EditModeLeaveDrawCallback @pContextA, pControl, pLineNo, @pControlRect, @
999510001
-- thus not effected by the control sliding out to the right (which would naturally
999610002
-- move the roerder control left).
999710003
add 1 to pContextA["animation count"]
9998-
put DG2_AnimationsAnimationCreate(tReorderControl, "left", the left of tReorderControl, the left of tReorderControl, the dgAnimationProp["EditModeEnterExitDuration"] of me, the dgAnimationProp["EditModeEnterExitReorderControlEasing"] of me) into pContextA["animations"][pContextA["animation count"]]
10004+
put DG2_AnimationsAnimationCreate(tReorderControl, "left", the left of tReorderControl, the left of tReorderControl, the dgAnimationProp["EditModeEnterExitDuration"] of me, "linear") into pContextA["animations"][pContextA["animation count"]]
999910005
add 1 to pContextA["animation count"]
1000010006

10001-
put DG2_AnimationsAnimationCreate(tReorderControl, "blendLevel", 0, 100, the dgAnimationProp["EditModeEnterExitDuration"] of me, "linear") into pContextA["animations"][pContextA["animation count"]]
10007+
put DG2_AnimationsAnimationCreate(tReorderControl, "blendLevel", 0, 100, the dgAnimationProp["EditModeEnterExitDuration"] of me, the dgAnimationProp["EditModeEnterExitReorderControlEasing"] of me) into pContextA["animations"][pContextA["animation count"]]
1000210008
end if
1000310009

1000410010
-- If the controls are cached, "LayoutControl" won't be called by the standard draw loop.
@@ -10082,13 +10088,25 @@ command DG2_ReorderStart
1008210088
-- and adjusts the scroll accodingly.
1008310089
send "DG2_ReorderScrollPoll" to me in 0 seconds
1008410090

10091+
-- Check for mouse moves. We do this manually rather than using mouse move
10092+
-- as mouse move for a couple of reasons:
10093+
-- Mouse move is sent to regularly, which can cometimes mean handling it
10094+
-- interferes with animations. Polling like this acts as the equivelant of
10095+
-- throttling mouse move.
10096+
-- Also, widgets don't pass mouse move, so need to post it directly. This
10097+
-- message can sometimes not get posted until the vent loop is cleared,
10098+
-- meaning it can be held up behind any pending animations.
10099+
send "DG2_ReorderMove" to me in 0 seconds
10100+
1008510101
-- Tell the user a reorder has started.
1008610102
dispatch DG2_GetMessageNameForTag("EditModeReorderStarted") to me with sReorderStartIndex, sReorderStartLine
1008710103

1008810104
return empty
1008910105
end DG2_ReorderStart
1009010106

1009110107
command DG2_ReorderMove pNewMouseH, pNewMouseV
10108+
cancel sReorderMoveMsgId
10109+
1009210110
if not sReorderInProgress then
1009310111
return "No reorder currently in progress"
1009410112
end if
@@ -10097,21 +10115,27 @@ command DG2_ReorderMove pNewMouseH, pNewMouseV
1009710115
return empty
1009810116
end if
1009910117

10118+
if the mouse is not "down" then
10119+
return empty
10120+
end if
10121+
10122+
put true into sReorderMouseMoveInProgress
10123+
1010010124
if pNewMouseV is empty then
1010110125
put item 2 of the mouseLoc into pNewMouseV
1010210126
end if
1010310127

1010410128
-- Don't extend the reorder beyond the rect of the DataGrid!
10105-
if pNewMouseV < the top of me then
10106-
put the top of me into pNewMouseV
10107-
else if pNewMouseV > bottom of me then
10108-
put the bottom of me into pNewMouseV
10129+
if pNewMouseV < the top of group "dgListMask" of me then
10130+
put the top of group "dgListMask" of me into pNewMouseV
10131+
else if pNewMouseV > bottom of group "dgListMask" of me then
10132+
put the bottom of group "dgListMask" of me into pNewMouseV
1010910133
end if
1011010134

10111-
put true into sReorderMouseMoveInProgress
10112-
1011310135
local tHoverLine
1011410136
put DG2_VerticalLocToLineNo(pNewMouseV) into tHoverLine
10137+
put max(tHoverLine, 1) into tHoverLine
10138+
put min(tHoverLine, the dgNumberOfLines of me) into tHoverLine
1011510139

1011610140
-- If the mouse is over a new line.
1011710141
-- This means we need to reorder.
@@ -10155,6 +10179,9 @@ command DG2_ReorderMove pNewMouseH, pNewMouseV
1015510179
-- Make sure the control we're reordering is always tracking the mouse.
1015610180
set the loc of sReorderControl to item 1 of the loc sReorderControl, pNewMouseV
1015710181

10182+
send "DG2_ReorderMove" to me in sReorderMovePollRate milliseconds
10183+
put the result into sReorderMoveMsgId
10184+
1015810185
put false into sReorderMouseMoveInProgress
1015910186

1016010187
return empty
@@ -10195,17 +10222,13 @@ on DG2_ReorderScrollPoll
1019510222
local tMaxVScroll
1019610223
put the dgFormattedHeight of me - the height of group "dgList" of me into tMaxVScroll
1019710224

10198-
if the mouseLoc is within the rect of me then
1019910225
-- If the mouse is sitting at the top of the list, scroll the list up.
1020010226
-- If the mouse is sitting at teh bottom of the list, scroll the list down.
1020110227
-- This allows users to scroll the list while reordering.
1020210228
if item 2 of the mouseLoc - the top of me <= kReorderScrollPollMargin and the dgVScroll of me >= 0 then
1020310229
set the dgVScroll of me to max(the dgVScroll of me - kReorderScollPollIncrement, 0)
10204-
DG2_ReorderMove item 1 of the mouseLoc, item 2 of the mouseLoc
1020510230
else if the bottom of me - item 2 of the mouseLoc <= kReorderScrollPollMargin and the dgVScroll of me <= tMaxVScroll then
1020610231
set the dgVScroll of me to min(the dgVScroll of me + kReorderScollPollIncrement, tMaxVScroll)
10207-
DG2_ReorderMove item 1 of the mouseLoc, item 2 of the mouseLoc
10208-
end if
1020910232
end if
1021010233

1021110234
send "DG2_ReorderScrollPoll" to me in kReorderScrollPollRate milliseconds
@@ -11211,7 +11234,7 @@ on DG2_AnimationsPulse
1121111234
if sAnimationsA is not empty then
1121211235
-- Redraw every kAnimationsPulseRate milliseconds.
1121311236
-- Make sure we take into account how long this handler took when determing when next to redraw.
11214-
send "DG2_AnimationsPulse" to me in (kAnimationsPulseRate - the milliseconds - tCurrentTime) milliseconds
11237+
send "DG2_AnimationsPulse" to me in (kAnimationsPulseRate - (the milliseconds - tCurrentTime)) milliseconds
1121511238
put the result into sAnimationsPulseMsgID
1121611239
else
1121711240
put empty into sAnimationsPulseMsgID

Toolset/palettes/revdatagridlibrary/behaviorsrowchainedbehavior.livecodescript

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ before mouseMove pNewMouseH, pNewMouseV
8484
pass mouseMove
8585
end if
8686

87-
if the dgEditMode of the of the dgControl of me then
88-
DG2_ReorderMove pNewMouseH, pNewMouseV
89-
else
87+
if not the dgEditMode of the of the dgControl of me then
9088
if sDragging then
9189
put the milliseconds && pNewMouseH & return before sDragLocs
9290

@@ -188,11 +186,12 @@ before LayoutControl pControlRect, pWorkingRect
188186
end if
189187

190188
if tReorderControl is not empty then
191-
-- We only need to worry about the top of the reorder control. It's
192-
-- horizontal position will be set when entering edit mode.
189+
-- We can't rely on the right of the control rect to be the right of
190+
-- the list group: When animating out of edit mode, the control rect
191+
-- can be extended to the right to make room for the animation. So,
192+
-- use the right of the list group to postion the reorder control.
193193
set the visible of tReorderControl to true
194-
set the top of tReorderControl to item 2 of pControlRect + (item 4 of pControlRect - item 2 of pControlRect - the height of tReorderControl) / 2
195-
--set the topRight of tReorderControl to item 3 of pControlRect, item 2 of pControlRect + (item 4 of pControlRect - item 2 of pControlRect - the height of tReorderControl) / 2
194+
set the topRight of tReorderControl to min(item 3 of pControlRect, the right of group "dgList" of the dgControl of me), item 2 of pControlRect + (item 4 of pControlRect - item 2 of pControlRect - the height of tReorderControl) / 2
196195
end if
197196
else
198197
if tActionSelectControl is not empty then

0 commit comments

Comments
 (0)