Author |
Topic |
|
PeterPanino
933 Posts |
Posted - Oct 18 2022 : 16:08:51
|
1. I create an Image Layer with this code:
ImageEnView1.LayersNewLayerDialog(ielkImage, True);
ImageEnView1.CurrentLayer.Selectable := True;
However, the created Layer is not selectable. How can I make it selectable after creation? Also, the LayersNewLayerDialog shows only a few properties of the Image-Layer to insert. Isn't there a more extensive dialog?
2. When I create an Image Layer with the above code in an ImageEnView with NO PRELOADED IMAGE and then load an image in ImageEnView, the loaded image assumes the size of the previously loaded Image Layer which does not look well. Obviously, ImageEnView assumes that the previously loaded Image Layer is the Background. How to avoid this?
3. When I select a Layer (any kind), is it possible to invoke a built-in dialog that allows configuring all (I mean ALL) properties applicable to the selected Layer? |
|
PeterPanino
933 Posts |
Posted - Oct 18 2022 : 17:46:33
|
To partly answer question #1: If I set mlMoveLayers, mlResizeLayers, mlRotateLayers in MouseInteractLayers at design-time, then the Layer can be selected at run-time after creation. Obviously, the statement ImageEnView1.CurrentLayer.Selectable := True; cannot overrule the MouseInteractLayers settings made at design-time.
But although I have set mlMoveLayers, mlResizeLayers, mlRotateLayers in MouseInteractLayers at design-time, the Layer can be selected and rotated but NOT MOVED at run-time, although mlMoveLayers has been selected at design-time! So how can I make the Layer movable?
UPDATE: Obviously, miSelect and Layer-Moving are MUTUALLY EXCLUSIVE. How to overcome this dilemma? Moving a Layer by CTRL-dragging while miSelect = True? |
|
|
xequte
38608 Posts |
Posted - Oct 18 2022 : 18:34:10
|
Hi Peter
I'm not able to reproduce that.
I added the following code to a button in the layers demo and was able to move the new layer with the keyboard and mouse:
ImageEnView1.LayersNewLayerDialog(ielkImage, True);
ImageEnView1.CurrentLayer.Selectable := True;
ImageEnView1.MouseInteractLayers := [mlMoveLayers, mlResizeLayers, mlRotateLayers];
ImageEnView1.SetFocus();
Nigel Xequte Software www.imageen.com
|
|
|
PeterPanino
933 Posts |
Posted - Oct 18 2022 : 18:46:56
|
Hi Nigel
Thank you for the information.
miSelect is the culprit. It is mutually exclusive with Layer-moving. But I need the user to be able to make a selection. How can this dilemma be solved? |
|
|
xequte
38608 Posts |
Posted - Oct 18 2022 : 20:10:18
|
Hi Peter
There's not a mechanism within ImageEn to handle it because their interactions are the same. You might try changing the mouse interaction in the mouse down event based on whether Ctrl is down, for instance.
Nigel Xequte Software www.imageen.com
|
|
|
PeterPanino
933 Posts |
Posted - Oct 19 2022 : 13:38:05
|
Hi Nigel
I've tried it:
procedure TformMain.ImageEnViewMouseDown(Sender: TObject; Button:
TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Winapi.Windows.GetKeyState(VK_CONTROL) < 0) then
begin
CodeSite.Send('ssCtrl');
ImageEnView.MouseInteractGeneral := ImageEnView.MouseInteractGeneral - [miSelect];
end
else
begin
CodeSite.Send('no modifier');
ImageEnView.MouseInteractGeneral := ImageEnView.MouseInteractGeneral + [miSelect];
end;
end;
However, holding down the CTRL key DUPLICATES the clicked Layer instead of moving it. Is this a hidden feature? I have not found it in the documentation.
BTW, have you ever thought to give Layers an additional (optional) handle that can be used only for moving the Layer by dragging with the mouse?
Or some graphics programs allow the user to move a Layer by using the edge of the Layer (not a handle).
BTW, clicking on a Layer or on the Background image gives back the index for the PREVIOUSLY selected Layer or Background. So the first time I click on a floating Layer it gives me back 0 for the previously selected Background. Or when clicking on the Background it gives me back an index number > 0 for the previously selected floating Layer:
CodeSite.Send('LayerIndex', ImageEnView.CurrentLayer.LayerIndex); |
|
|
xequte
38608 Posts |
|
PeterPanino
933 Posts |
Posted - Oct 20 2022 : 07:10:45
|
Hi Nigel
I am now trying this solution:
procedure TformMain.ImageEnView1MouseDown(Sender: TObject; Button:
TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbleft then
begin
var ThisLayer := ImageEnView1.FindLayerAt(X, Y);
if ThisLayer = 0 then // user has left-clicked the image-background
begin
CodeSite.Send('MouseDown: background');
//ImageEnView1.LayersDeselectAll(); // ?
ImageEnView1.Layers[0].Selected := True; // does not work!!!
end
else // user has left-clicked a layer
begin
CodeSite.Send('MouseDown: layer');
FOldMouseInteractGeneral := ImageEnView1.MouseInteractGeneral;
ImageEnView1.MouseInteractGeneral := [];
ImageEnView1.MouseInteractLayers := [mlMoveLayers, mlResizeLayers, mlRotateLayers];
end;
end;
end;
procedure TformMain.ImageEnView1MouseUp(Sender: TObject; Button:
TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbleft then
begin
var ThisLayer := ImageEnView1.FindLayerAt(X, Y);
if ThisLayer = 0 then // user has left-clicked the image-background
begin
CodeSite.Send('MouseUp: background');
ImageEnView1.LayersDeselectAll();
ImageEnView1.MouseInteractGeneral := FOldMouseInteractGeneral;
ImageEnView1.Layers[0].Selected := True; // does not work!!!
end
else // user has left-clicked a layer
begin
CodeSite.Send('MouseUp: layer');
ImageEnView1.MouseInteractLayers := [];
ImageEnView1.MouseInteractGeneral := FOldMouseInteractGeneral;
end;
end;
end;
It seems to work well: With this code, I can now move a Layer without holding down any modifier key. BUT selecting the Background Layer 0 with ImageEnView1.Layers[0].Selected := True; again does not work after having previously selected a floating Layer! HOW can I select the Background Layer 0 when clicking on it? |
|
|
PeterPanino
933 Posts |
Posted - Oct 20 2022 : 16:16:23
|
I have tried to simplify and improve the code:
procedure TformMain.ImageEnView1MouseDown(Sender: TObject; Button:
TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbleft then // Left click
begin
// Remember MouseInteractGeneral at Left-click DOWN:
FOldMouseInteractGeneral := ImageEnView1.MouseInteractGeneral;
var ThisLayer := ImageEnView1.FindLayerAt(X, Y);
if (Winapi.Windows.GetKeyState(VK_CONTROL) < 0) then // holding down CTRL key
begin
if ThisLayer > 0 then // left-clicked a floating Layer (not the Background)
begin
CodeSite.Send('MouseDown: CTRL-left-clicked a floating Layer (not the Background)');
ImageEnView1.MouseInteractGeneral := [];
ImageEnView1.MouseInteractLayers := [mlMoveLayers, mlResizeLayers, mlRotateLayers];
end;
end;
end;
end;
procedure TformMain.ImageEnView1MouseUp(Sender: TObject; Button:
TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button = mbleft then
begin
var ThisLayer := ImageEnView1.FindLayerAt(X, Y);
if ThisLayer = 0 then // user has left-clicked the image-background
begin
CodeSite.Send('MouseUp: left-clicked Background');
//ImageEnView1.LayersDeselectAll();
ImageEnView1.Layers[0].Selected := True; // this does not work when e.g. BrushTool is active!!!
ImageEnView1.Update;
end;
// Restore MouseInteractGeneral at Left-click UP
ImageEnView1.MouseInteractGeneral := FOldMouseInteractGeneral;
end;
end;
However, ImageEnView1.Layers[0].Selected := True; still does not work when e.g. BrushTool is active!
Why? |
|
|
xequte
38608 Posts |
Posted - Oct 20 2022 : 23:36:00
|
Hi
Please email me for an update that supports miSelect and mlMoveLayers being used together (because dragging by the edge is supported in that configuration).
Nigel Xequte Software www.imageen.com
|
|
|
|
Topic |
|
|
|