@@ -239,6 +239,44 @@ private command _Initialize
239
239
local theMasterRect
240
240
put the rect of me into theMasterRect
241
241
242
+ # # Configure the DG subgroups to enable use of acceleratedRendering
243
+ # # effectively in form mode.
244
+
245
+ # # The top-level group must be container (this means that no adornment
246
+ # # props must be set on the top-level group).
247
+ set the layerMode of me to "container"
248
+
249
+ # # The dgBackground group holds the backdrop behind the row-templates.
250
+ # # This can be changed to static when the engine is changed so that
251
+ # # a control is only redrawn when focused *if* it will change appearance.
252
+ set the layerMode of control "dgBackground" of me to "dynamic"
253
+
254
+ # # The dgListMask group holds the scrolling elements; in form view mode
255
+ # # only the dgList subgroup is relevant. As it holds other subgroups which
256
+ # # will hold dynamic layers it must be container.
257
+ set the layerMode of group "dgListMask" of me to "container"
258
+
259
+ # # The dgList group holds the replicated row template groups. As it holds
260
+ # # dynamic layer groups it must be container.
261
+ set the layerMode of group "dgList" of me to "container"
262
+
263
+ # # The dgHorizontalComponents group holds the horizontal scrollbar and
264
+ # # corner wedge. Making it dynamic means that it doesn't cause re-rendering
265
+ # # of static layers above when it changes.
266
+ set the layerMode of group "dgHorizontalComponents" of me to "dynamic"
267
+
268
+ # # The dgScrollbar group holds the vertical scrollbar. Making it dynamic
269
+ # # means that it doesn't cause re-rendering of static layers above when it
270
+ # # changes.
271
+ set the layerMode of scrollbar "dgScrollbar" of me to "dynamic"
272
+
273
+ # # The following groups all relate to table mode. These are all set to
274
+ # # static for now.
275
+ set the layerMode of group "dgAlternatingRowsMask" of me to "static"
276
+ set the layerMode of group "dgHighlights" of me to "static"
277
+ set the layerMode of group "dgHeaderComponents" of me to "static"
278
+ set the layerMode of group "dgDividers" of me to "static"
279
+
242
280
switch the platform
243
281
case "Win32"
244
282
if "registryRead" is among the items of the securityPermissions then
@@ -2587,12 +2625,19 @@ private command _DrawListWithProperties pStartingSequence, pSetVScrollTo, pForce
2587
2625
2588
2626
# # Make sure focus stays with us
2589
2627
if the long ID of me is in theControl then
2590
-
2591
2628
lock messages
2592
2629
if there is not a theControl then
2630
+ # # [[ FocusRedraw ]] Make sure focus is only changed if the target is
2631
+ # # not already focused.
2632
+ if the long id of the focusedObject is not the long id of graphic "dgBackground" of me then
2593
2633
focus on graphic "dgBackground" of me
2634
+ end if
2594
2635
else
2636
+ # # [[ FocusRedraw ]] Make sure focus is only changed if the target is
2637
+ # # not already focused.
2638
+ if the long id of the focusedObject is not theControl then
2595
2639
focus on theControl
2640
+ end if
2596
2641
end if
2597
2642
unlock messages
2598
2643
end if
@@ -2964,6 +3009,7 @@ private command _list.FillListWithJustEnoughControls
2964
3009
repeat with i = theCurrentControlCount + 1 to theRequiredControlCount
2965
3010
copy theTemplateGroup to group "dgList" of me
2966
3011
put it into theControl
3012
+ set the layerMode of theControl to "dynamic"
2967
3013
set the name of theControl to the short name of theControl && format ("%04d" , i)
2968
3014
put "control id" && word 3 of theControl && "of me" & cr after sTableObjectsA ["all row controls" ]
2969
3015
@@ -3096,6 +3142,14 @@ private command _list.DrawControlsInRealTime pForceRefresh, pCallback, pCallback
3096
3142
3097
3143
put not controlCountWasModified and sTableObjectsA ["current" ]["indexes" ] is theIndexesInSequence into noRedrawNeeded
3098
3144
-- put theIndexesInSequence && the milliseconds & cr into msg
3145
+
3146
+ # # [[ DG2Layout ]] If edit mode or enable swipe is enabled or if minimal
3147
+ # # layout is not enabled then we must still call LayoutControl on each
3148
+ # # iteration.
3149
+ local theMustLayout
3150
+ put sEditMode or \
3151
+ the dgProps["enable swipe" ] of me or \
3152
+ not the dgProps["minimal layout" ] of me into theMustLayout
3099
3153
3100
3154
if not noRedrawNeeded or pForceRefresh then
3101
3155
put empty into sTableObjectsA ["visible row controls" ]
@@ -3137,16 +3191,24 @@ private command _list.DrawControlsInRealTime pForceRefresh, pCallback, pCallback
3137
3191
3138
3192
# # Set row color
3139
3193
if there is a graphic "Background" of theEffectiveControl then
3194
+ # # Compute the new row color based on the alternating index
3195
+ local theNewRowColor
3140
3196
if theSequence mod 2 is kAlternatingRowModValue then
3141
- set the backgroundColor of graphic "Background" of theEffectiveControl to theRow2Color
3197
+ put theRow2Color into theNewRowColor
3142
3198
else
3143
- set the backgroundColor of graphic "Background" of theEffectiveControl to theRow1Color
3199
+ put theRow1Color into theNewRowColor
3200
+ end if
3201
+
3202
+ # # [[ ColorRedraw ]] Only change the backgroundColor of the control
3203
+ # # if it has changed.
3204
+ if the backgroundColor of graphic "Background" of theEffectiveControl is not theNewRowColor then
3205
+ set the backgroundColor of graphic "Background" of theEffectiveControl to theNewRowColor
3144
3206
end if
3145
3207
end if
3146
3208
3147
3209
# # If control index is not the index we are working on then
3148
3210
# # Load new data
3149
- local theCurrentIndex
3211
+ local theCurrentIndex , theNeedsLayout
3150
3212
put the dgIndex of theControl into theCurrentIndex
3151
3213
if theCurrentIndex is not theIndex then
3152
3214
# # Allow developer to do something if unloading control
@@ -3170,32 +3232,56 @@ private command _list.DrawControlsInRealTime pForceRefresh, pCallback, pCallback
3170
3232
dispatch "FillInData" to theControl with sDataArray [theIndex ]
3171
3233
lock messages
3172
3234
end if
3235
+
3236
+ # # If data was changed, then the control must layout
3237
+ put true into theNeedsLayout
3173
3238
else
3174
3239
-- put "not drawing index:" && theIndex & cr after msg
3240
+
3241
+ # # If data has not changed then only layout if DG2 features are
3242
+ # # active
3243
+ put theMustLayout into theNeedsLayout
3175
3244
end if
3176
3245
3177
3246
# # Set the rect AFTER filling in data in case filling in data causes the group to resize
3178
3247
unlock messages
3179
3248
if pCallback is not empty then
3180
3249
dispatch pCallback to me with pCallbackContext , theControl , theSequence , theRect , theTopLeft
3181
3250
end if
3182
- set the topLeft of theControl to item 1 to 2 of theRect # # So developer can always count on topleft of controls in template code
3183
- lock messages
3184
- set the rect of theControl to theRect
3185
- unlock messages
3186
- dispatch "LayoutControl" to theControl with theRect , DG2_GetWorkingRectOfControlFromControlRect(theControl , theRect )
3187
-
3188
- # # Resize to fit height
3189
- if not controlHeightIsFixed then
3251
+
3252
+ # # Always set the topLeft of the row template - this causes unchanged
3253
+ # # rows to scroll, and ensure that changed rows controls are where they
3254
+ # # expect.
3255
+ set the topLeft of theControl to item 1 to 2 of theRect
3256
+
3257
+ # # If the width or height of the row template has changed then get the
3258
+ # # user script to layout it out again.
3259
+ if theNeedsLayout or \
3260
+ the width of theControl is not (item 3 of theRect - item 1 of theRect ) or \
3261
+ the height of theControl is not (item 4 of theRect - item 2 of theRect ) then
3190
3262
lock messages
3191
- put item 2 of theRect + the formattedHeight of theControl into item 4 of theRect
3192
3263
set the rect of theControl to theRect
3193
3264
unlock messages
3265
+
3266
+ set the lockUpdates of theControl to true
3267
+ dispatch "LayoutControl" to theControl with theRect , DG2_GetWorkingRectOfControlFromControlRect(theControl , theRect )
3268
+ set the lockUpdates of theControl to false
3269
+
3270
+ # # Resize to fit height
3271
+ if not controlHeightIsFixed then
3272
+ lock messages
3273
+ put item 2 of theRect + the formattedHeight of theControl into item 4 of theRect
3274
+ set the rect of theControl to theRect
3275
+ unlock messages
3276
+ end if
3194
3277
end if
3195
3278
3196
3279
put the bottom of theControl into item 2 of theTopLeft
3197
3280
3198
- # # Hilited index?
3281
+ # # [[ HiliteAll ]] Update the hilite of the row template - ideally
3282
+ # # this would only be done *if* the hilite of the row has changed
3283
+ # # or the row template has been reused or the data for the row has
3284
+ # # changed.
3199
3285
if theIndex is among the items of sHilitedIndexes then
3200
3286
_HiliteControl theEffectiveControl , true
3201
3287
else
@@ -3214,7 +3300,7 @@ private command _list.DrawControlsInRealTime pForceRefresh, pCallback, pCallback
3214
3300
# # Filter control list and reset controls that aren't part of visible list
3215
3301
put line (the number of lines of sTableObjectsA ["visible row controls" ] + 1 ) to - 1 of theMasterControlList into theMasterControlList
3216
3302
_ResetControls theMasterControlList
3217
-
3303
+
3218
3304
return empty
3219
3305
end _list.DrawControlsInRealTime
3220
3306
@@ -3398,6 +3484,7 @@ private command _list.CalculateFormattedHeight
3398
3484
lock messages
3399
3485
copy theTemplateGroup to group "dgList" of me
3400
3486
put it into theControl
3487
+ set the layerMode of theControl to "dynamic"
3401
3488
unlock messages
3402
3489
3403
3490
try # # Watch for user errors
@@ -6143,6 +6230,12 @@ setprop dgProps [pProp] pValue
6143
6230
set the dgProps[pProp ] of me to "Data Grid"
6144
6231
unlock messages
6145
6232
break
6233
+
6234
+ case "minimal layout"
6235
+ lock messages
6236
+ set the dgProps[pProp ] of me to pValue is true
6237
+ unlock messages
6238
+ break
6146
6239
6147
6240
default
6148
6241
throw "invalid property '" & pProp & "'"
@@ -6358,6 +6451,10 @@ getprop dgProps [pProp]
6358
6451
case "fixed control height" # # early dev versions
6359
6452
return the dgProps["fixed row height" ] of me
6360
6453
break
6454
+
6455
+ case "minimal layout"
6456
+ return the dgProps["minimal layout" ] of me
6457
+ break
6361
6458
end switch
6362
6459
6363
6460
pass dgProps
@@ -7683,6 +7780,7 @@ private command _ProcessNewIndexData pIndex
7683
7780
put "control id" && word 3 of theControl && "of me" into sControlOfIndexA [pIndex ]
7684
7781
set the visible of theControl to false
7685
7782
set the dgIndex of theControl to pIndex
7783
+ set the layerMode of theControl to "dynamic"
7686
7784
unlock messages
7687
7785
7688
7786
put sControlOfIndexA [pIndex ] into line (the number of lines of sTableObjectsA ["all row controls" ] + 1 ) of sTableObjectsA ["all row controls" ]
@@ -7735,6 +7833,7 @@ private command _UpdateIndexWithNewData pIndex
7735
7833
lock messages
7736
7834
copy theTemplateGroup to group "dgList" of me
7737
7835
put it into theControl
7836
+ set the layerMode of theControl to "dynamic"
7738
7837
end if
7739
7838
7740
7839
# # Insert data into control
@@ -8392,6 +8491,7 @@ private command _CacheControls
8392
8491
copy theTemplateGroup to group "dgList" of me
8393
8492
put "control id" && word 3 of it && "of me" & cr after sTableObjectsA ["all row controls" ]
8394
8493
set the name of it to the short name of it && format ("%04d" , i)
8494
+ set the layerMode of it to "dynamic"
8395
8495
8396
8496
# # Take over geometry
8397
8497
set the lockloc of it to true
@@ -8558,21 +8658,29 @@ private command _LayoutCachedControls
8558
8658
unlock screen
8559
8659
end _LayoutCachedControls
8560
8660
8561
-
8562
8661
private command _HiliteControl pControl, pBoolean
8563
- if there is a graphic "Background" of pControl then
8662
+ if there is a graphic "Background" of pControl then
8663
+ # # Compute the new background color based on whether it is hilited and
8664
+ # # if not hilited, whether alternating colors should be used.
8665
+ local tNewBackgroundColor
8564
8666
if pBoolean then
8565
- set the backgroundColor of graphic "Background" of pControl to _GetHiliteColor()
8667
+ put _GetHiliteColor() into tNewBackgroundColor
8566
8668
else
8567
8669
set the wholeMatches to true
8568
8670
local theLine
8569
8671
put itemOffset (the dgIndex of pControl , sIndexSequencing ) into theLine
8570
8672
if theLine mod 2 is kAlternatingRowModValue then
8571
- set the backgroundColor of graphic "Background" of pControl to _GetEffectiveColor("alternate row color" )
8673
+ put _GetEffectiveColor("alternate row color" ) into tNewBackgroundColor
8572
8674
else
8573
- set the backgroundColor of graphic "Background" of pControl to _GetEffectiveColor("row color" )
8675
+ put _GetEffectiveColor("row color" ) into tNewBackgroundColor
8574
8676
end if
8575
8677
end if
8678
+
8679
+ # # [[ ColorRedraw ]] Only update the background color if it has actually
8680
+ # # changed.
8681
+ if the backgroundColor of graphic "Background" of pControl is not tNewBackgroundColor then
8682
+ set the backgroundColor of graphic "Background" of pControl to tNewBackgroundColor
8683
+ end if
8576
8684
end if
8577
8685
8578
8686
local msgsAreLocked
@@ -10827,6 +10935,7 @@ function DG2_CustomisableControlsGetDefaultEditModeReorderControl
10827
10935
reset the templateGroup
10828
10936
create invisible group "DG2 Default Edit Mode Reorder Control" in _TemplateControl()
10829
10937
set the margins of it to kEditModeReorderControlMargins
10938
+ set the layerMode of it to "dynamic"
10830
10939
10831
10940
create widget as "com.livecode.widget.svgpath" in it
10832
10941
set the iconPresetName of it to kEditModeReorderControlIcon
@@ -10848,6 +10957,7 @@ function DG2_CustomisableControlsGetDefaultEditModeActionSelectControl
10848
10957
reset the templateGroup
10849
10958
create invisible group "DG2 Default Edit Mode Action Select Control" in _TemplateControl()
10850
10959
set the margins of it to kEditModeActionSelectControlMargins
10960
+ set the layerMode of it to "dynamic"
10851
10961
10852
10962
create widget as "com.livecode.widget.svgpath" in it
10853
10963
set the iconPresetName of it to kEditModeActionSelectControlIcon
@@ -10872,6 +10982,7 @@ function DG2_CustomisableControlsGetDefaultEditModeActionControl
10872
10982
reset the templateGroup
10873
10983
create invisible group "DG2 Default Action Control" in _TemplateControl()
10874
10984
set the margins of it to 0
10985
+ set the layerMode of it to "dynamic"
10875
10986
10876
10987
reset the templateButton
10877
10988
create button "DG2 Default Action Control" in it
@@ -10903,6 +11014,7 @@ private function DG2_CustomisableControlsGetDefaultSwipeControl pName
10903
11014
reset the templateGroup
10904
11015
create invisible group pName in _TemplateControl()
10905
11016
set the margins of it to 0
11017
+ set the layerMode of it to "dynamic"
10906
11018
put it into tGroup
10907
11019
10908
11020
reset the templateGraphic
0 commit comments