Hi Nigel,
Thank you for the information.
I wrote this code to TOGGLE the selected Layers between Grouped and UnGrouped modes:
procedure TformMain.ButtonToggleLayerGroupingClick(Sender: TObject);
begin
// Iterate through all selected layers (except background):
with ImageEnView1 do
begin
LockUpdate();
try
var ThisGroupIndex := Random(Max_Int);
for var i := 1 to LayersCount - 1 do
begin
if Layers[i].Selected then
begin
if Layers[i].GroupIndex = 0 then // if Layer is UNGROUPED
Layers[i].GroupIndex := ThisGroupIndex
else // if Layer is GROUPED
Layers[i].GroupIndex := 0;
end;
end;
finally
UnlockUpdate();
end;
end;
end;
But to select only Grouped or only Ungrouped Layers to toggle, the user needs a visual indication of whether a Layer is Grouped or not Grouped. Otherwise, this code could not work as intended. Otherwise, I would have to implement TWO buttons: One for Grouping and one for Ungrouping.