Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
917 changes: 912 additions & 5 deletions Documentation/dictionary/datagrid.lcdoc

Large diffs are not rendered by default.

Binary file modified Toolset/palettes/revdatagridlibrary.rev
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
script "RevDataGridLibraryBehaviorsSwipeControlHolderBehavior"
----------------------------------------------------------------------
-- This behavior is applied to a group used to house fully visible swipe
-- controls for a give row and side, dealing with animating the control in an
-- out as well as catching any clicks. (Partially visible - i.e. during a row
-- drag left/right action - are handled in the row's chained behavior). When
-- fully visible, a swipe control takes over the full DataGrid, using the holder
-- group as message catcher, with all clicks in th DataGrid either hiding the
-- swipe control or performing the swipe control click action.

local sRowIndex
local sSwipeControlSide
local sSwipeControl
local sSwipeControlOwner

setProp dgSwipeControlSide pSide
put pSide into sSwipeControlSide
end dgSwipeControlSide

getProp dgSwipeControlSide
return sSwipeControlSide
end dgSwipeControlSide

-- Animate in the swipe control for the given row index using from the
-- previously specified side.
-- Setting to empty will animate out any visible swipe control.
setProp dgSwipeControlRowIndex pIndex
if pIndex is not empty then
local tRowControl
put the dgDataControlOfIndex[pIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
return "Could not find row control"
end if

switch sSwipeControlSide
case "left"
get DG2_CustomisableControlsGetLeftSwipeControlForControl(the long id of tRowControl)
break
case "right"
get DG2_CustomisableControlsGetRightSwipeControlForControl(the long id of tRowControl)
break
default
return "Unknown swipe side" && sSwipeControlSide
end switch
if it is empty then
return "Could not find swipe control"
end if

put it into sSwipeControl
put pIndex into sRowIndex
put the owner of sSwipeControl into sSwipeControlOwner

lock screen
set the rect of me to the rect of group "dgList" of the dgControl of me
set the rect of graphic "Message Catcher" of me to the rect of me
set the visible of me to true
unlock screen

DG2_SwipeControlShow
return the result
else
local tResult
DG2_SwipeControlHide
put empty into sRowIndex
return tResult
end if
end dgSwipeControlRowIndex

getProp dgSwipeControlRowIndex
return sRowIndex
end dgSwipeControlRowIndex

-- A scroll or resize has occurred. Reposition the group inside the the list,
-- the swipe control next to the appropriate row and the row to the left or
-- right of the swipe control.
command DG2_SwipeControlHolderReposition
if not the visible of me then
return empty
end if
if sRowIndex is empty then
return empty
end if
if sSwipeControl is empty then
return empty
end if

local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
set the visible of sSwipeControl to false
return empty
end if

lock screen
set the visible of sSwipeControl to true
set the rect of me to the rect of group "dgList" of the dgControl of me
set the rect of graphic "Message Catcher" of me to the rect of me
set the top of sSwipeControl to the top of tRowControl
switch sSwipeControlSide
case "left"
set the left of tRowControl to the right of sSwipeControl
break
case "right"
set the right of tRowControl to the left of sSwipeControl
break
end switch
unlock screen

return empty
end DG2_SwipeControlHolderReposition

private command DG2_SwipeControlShow
local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
return "Could not find row control"
end if

-- A swipe has been occured so tell the user by sending the
-- appropriate message. If the user handles the message then we
-- can assume they are dealing with the action and on't need to do
-- anything more. If it's not handled, then fully animate in the
-- swipe control.
switch sSwipeControlSide
case "left"
dispatch DG2_GetMessageNameForTag("RowSwipedRight") to tRowControl
if it is not "handled" then
DG2_AnimationsAdd the long id of tRowControl, "left", the left of tRowControl, the right of sSwipeControl, the dgAnimationProp["SwipeCompleteDuration"] of the dgControl of me, the dgAnimationProp["SwipeCompleteEasing"] of the dgControl of me, "DG2_SwipeControlShowComplete", empty, the long id of me
end if
break
case "right"
dispatch DG2_GetMessageNameForTag("RowSwipedLeft") to tRowControl
if it is not "handled" then
DG2_AnimationsAdd the long id of tRowControl, "right", the right of tRowControl, the left of sSwipeControl, the dgAnimationProp["SwipeCompleteDuration"] of the dgControl of me, the dgAnimationProp["SwipeCompleteEasing"] of the dgControl of me, "DG2_SwipeControlShowComplete", empty, the long id of me
end if
break
end switch

return empty
end DG2_SwipeControlShow

on DG2_SwipeControlShowComplete
-- When the animation is complete, the swipe control should be fully visible.
-- This means we can now bring it to the front of the DataGrid allowing it or
-- the holder group to catch all messages.
lock screen
relayer me to front of owner
relayer sSwipeControl to front of me
unlock screen

return empty
end DG2_SwipeControlShowComplete

private command DG2_SwipeControlHide
local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
return "Could not find row control"
end if

local tIsVisible
put the visible of me into tIsVisible

lock screen
relayer sSwipeControl before tRowControl
set the visible of me to false
unlock screen

-- The row script takes care of returning the swipe control.
-- If we're not visible then tell the row control not to bother animating the
-- return.
dispatch "DG2_SwipeReturn" to tRowControl with not tIsVisible
return the result
end DG2_SwipeControlHide

on DG2_SwipeControlHideComplete
local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is not empty then
set the left of tRowControl to the left of group "dgList" of the dgControl of me
end if

if sSwipeControl is not empty then
set the visible of sSwipeControl to false
relayer sSwipeControl to back of sSwipeControlOwner
end if

return empty
end DG2_SwipeControlHideComplete

on mouseUp
local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
exit mouseUp
end if

if the long id of the target contains the long id of sSwipeControl then
switch sSwipeControlSide
case "left"
dispatch DG2_GetMessageNameForTag("RowLeftSwipeControlClicked") to tRowControl
break
case "right"
dispatch DG2_GetMessageNameForTag("RowRightSwipeControlClicked") to tRowControl
break
end switch
else
DG2_SwipeControlHide
switch sSwipeControlSide
case "left"
dispatch DG2_GetMessageNameForTag("RowLeftSwipeControlHidden") to tRowControl
break
case "right"
dispatch DG2_GetMessageNameForTag("RowRightSwipeControlHidden") to tRowControl
break
end switch
end if
end mouseUp
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
script "RevDataGridLibraryBehaviorsActionControlHolderBehavior"
----------------------------------------------------------------------
-- This behavior is applied to a group used to house the action control for a
-- given row. It takes care of animating the action control in and out as well
-- as handling any actions when visible: When visible, the action control takes
-- over the full DataGrid, with all clicks either resulting in the action
-- control being hidden or the action control action being applied. The
-- behaviors's group acts as a message catcher, spanning the whole DataGrid.

local sRowIndex
local sActionControl
local sActionControlOwner

-- Animate in the action control for the row with the given index.
-- Setting to empty will animate out any visible action control.
setProp dgActionControlRowIndex pIndex
if pIndex is not empty then
local tRowControl
put the dgDataControlOfIndex[pIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
return "Could not find row control"
end if

get DG2_CustomisableControlsGetEditModeActionControlForControl(the long id of tRowControl)
if it is empty then
return "Could not find action control"
end if

put it into sActionControl
put pIndex into sRowIndex
put the owner of sActionControl into sActionControlOwner

lock screen
set the rect of me to the rect of group "dgList" of the dgControl of me
set the rect of graphic "Message Catcher" of me to the rect of me
set the visible of me to true
unlock screen

DG2_EditModeActionControlShow
return the result
else
local tResult
DG2_EditModeActionControlHide
put the result into tResult
put empty into sRowIndex
return the result
end if
end dgActionControlRowIndex

getProp dgActionControlRowIndex
return sRowIndex
end dgActionControlRowIndex

-- A scroll or resize has occurred. Reposition the group inside the the list,
-- the action control next to the appropriate row and the row to the left of
-- the action control.
command DG2_EditModeActionControlHolderReposition
if not the visible of me then
return empty
end if
if sRowIndex is empty then
return empty
end if
if sActionControl is empty then
return empty
end if

local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
set the visible of sActionControl to false
return empty
end if

lock screen
set the visible of sActionControl to true
set the rect of me to the rect of group "dgList" of the dgControl of me
set the rect of graphic "Message Catcher" of me to the rect of me
set the top of sActionControl to the top of tRowControl
set the right of tRowControl to the left of sActionControl
unlock screen

return empty
end DG2_EditModeActionControlHolderReposition

private command DG2_EditModeActionControlShow
local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
return "Could not find row control"
end if

-- We relayer the action control behind the row so that it is revealed as the
-- row animates left.
lock screen
relayer sActionControl before tRowControl
set the rect of sActionControl to the right of tRowControl - the width of sActionControl, the top of tRowControl, the right of tRowControl, the bottom of tRowControl
set the visible of sActionControl to true
unlock screen

DG2_AnimationsAdd the long id of tRowControl, "left", the left of tRowControl, the left of tRowControl - the width of sActionControl, the dgAnimationProp["EditModeActionControlAnimationDuration"] of the dgControl of me, the dgAnimationProp["EditModeActionControlAnimationEasing"] of the dgControl of me, "DG2_EditModeActionControlShowComplete", empty, the long id of me

return empty
end DG2_EditModeActionControlShow

on DG2_EditModeActionControlShowComplete
-- When the animation is complete, the action control should be fully visible.
-- This means we can now bring it to the front of the DataGrid allowing it or
-- the holder group to catch all messages.
lock screen
relayer me to front of owner
relayer sActionControl to front of me
unlock screen

return empty
end DG2_EditModeActionControlShowComplete

private command DG2_EditModeActionControlHide
local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
return "Could not find row control"
end if

if the visible of me then
-- Put the action control back behind the row control so that it is hidden
-- as the row animates right.
lock screen
relayer sActionControl before tRowControl
set the visible of me to false
unlock screen

DG2_AnimationsAdd the long id of tRowControl, "left", the left of tRowControl, the left of tRowControl + the width of sActionControl, the dgAnimationProp["EditModeActionControlAnimationDuration"] of the dgControl of me, the dgAnimationProp["EditModeActionControlAnimationEasing"] of the dgControl of me, "DG2_EditModeActionControlHideComplete", empty, the long id of me
else
-- If we're not visible, don't bother with any animating.
set the left of tRowControl to the left of group "dgList" of the dgControl of me
DG2_EditModeActionControlHideComplete
end if

return empty
end DG2_EditModeActionControlHide

on DG2_EditModeActionControlHideComplete
-- Return the action control to where it was before being added to the group.
if sActionControl is not empty then
lock screen
set the visible of sActionControl to false
relayer sActionControl to back of sActionControlOwner
unlock screen
end if

return empty
end DG2_EditModeActionControlHideComplete

on mouseUp
local tRowControl
put the dgDataControlOfIndex[sRowIndex] of the dgControl of me into tRowControl
if tRowControl is empty then
exit mouseUp
end if

if the long id of the target contains the long id of sActionControl then
dispatch DG2_GetMessageNameForTag("EditModeActionControlClicked") to tRowControl with the target
else
DG2_EditModeActionControlHide
dispatch DG2_GetMessageNameForTag("EditModeActionControlHidden") to tRowControl
end if
end mouseUp
Loading