more shift/ctrl/alt stuff

This commit is contained in:
zueuk 2005-09-28 15:40:33 +00:00
parent 92464f11cd
commit 17e6f74a65

View File

@ -292,6 +292,7 @@ type
// --Z-- // --Z--
viewDragMode, viewDragged: boolean; viewDragMode, viewDragged: boolean;
editMode, oldMode: (modeNone, modeMove, modeRotate, modeScale); editMode, oldMode: (modeNone, modeMove, modeRotate, modeScale);
modeKey: word;
key_handled: boolean; key_handled: boolean;
MousePos: TPoint; // in screen coordinates MousePos: TPoint; // in screen coordinates
@ -318,7 +319,6 @@ type
colorDrag, colorChanged: boolean; colorDrag, colorChanged: boolean;
colorDragX, colorOldX: integer; colorDragX, colorOldX: integer;
// --
{ Options } { Options }
UseFlameBackground, UseTransformColors: boolean; UseFlameBackground, UseTransformColors: boolean;
@ -1346,7 +1346,6 @@ FoundCorner:
if CornerCaught then // Modify a point /////////////////////////////////////// if CornerCaught then // Modify a point ///////////////////////////////////////
begin begin
// if (Shift = [ssAlt]) or ((editMode = modeRotate) and (Shift = [])) then
if (editMode = modeRotate) then // rotate point if (editMode = modeRotate) then // rotate point
begin // rotate point around pivot begin // rotate point around pivot
d := dist(Pivot.X, Pivot.Y, fx, fy); d := dist(Pivot.X, Pivot.Y, fx, fy);
@ -1385,7 +1384,6 @@ Skip1:
if vy > PI then vy := 2*PI - vy; if vy > PI then vy := 2*PI - vy;
StatusBar.Panels[2].Text := Format('Rotate: %3.2f° <ABC: %3.2f°', [a*180/PI, vy*180/PI]); StatusBar.Panels[2].Text := Format('Rotate: %3.2f° <ABC: %3.2f°', [a*180/PI, vy*180/PI]);
end end
// else if (Shift = [ssCtrl]) or ((editMode = modeScale) and (Shift = [])) then
else if (editMode = modeScale) then else if (editMode = modeScale) then
begin // move point along vector ("scale") begin // move point along vector ("scale")
if olddist<>0 then begin if olddist<>0 then begin
@ -1400,7 +1398,7 @@ Skip1:
end; end;
end end
else begin // snap/move else begin // snap/move
if Shift = [ssShift] then // snap to axis if ssShift in Shift then // snap to axis
begin begin
if abs(fx-Pivot.X) > abs(fy-Pivot.Y) then begin if abs(fx-Pivot.X) > abs(fy-Pivot.Y) then begin
vx := fx; vx := fx;
@ -1428,7 +1426,6 @@ Skip1:
end end
else if TriangleCaught then // Modify a whole triangle /////////////////////// else if TriangleCaught then // Modify a whole triangle ///////////////////////
begin begin
// if (Shift = [ssAlt]) or ((editMode = modeRotate) and (Shift = [])) then // rotate
if (editMode = modeRotate) then // rotate triangle if (editMode = modeRotate) then // rotate triangle
begin begin
a := arctan2(fy-Pivot.Y, fx-Pivot.X) - arctan2(oldy, oldx); a := arctan2(fy-Pivot.Y, fx-Pivot.X) - arctan2(oldy, oldx);
@ -1457,7 +1454,6 @@ Skip2:
StatusBar.Panels[2].Text := Format('Rotate: %3.2f° Local axis: %3.2f°', [a*180/PI, arctan2(vy, vx)*180/PI]) StatusBar.Panels[2].Text := Format('Rotate: %3.2f° Local axis: %3.2f°', [a*180/PI, arctan2(vy, vx)*180/PI])
else StatusBar.Panels[2].Text := Format('Rotate: %3.2f°', [a*180/PI]); else StatusBar.Panels[2].Text := Format('Rotate: %3.2f°', [a*180/PI]);
end end
// else if (Shift = [ssCtrl]) or ((editMode = modeScale) and (Shift = [])) then
else if (editMode = modeScale) then // scale else if (editMode = modeScale) then // scale
begin begin
if olddist<>0 then begin if olddist<>0 then begin
@ -1471,7 +1467,7 @@ Skip2:
else begin // snap/move else begin // snap/move
vx := fx - (Pivot.x + oldx); vx := fx - (Pivot.x + oldx);
vy := fy - (Pivot.y + oldy); vy := fy - (Pivot.y + oldy);
if Shift = [ssShift] then // snap to axis if ssShift in Shift then // snap to axis
begin begin
if abs(vx) > abs(vy) then vy := 0 if abs(vx) > abs(vy) then vy := 0
else vx := 0; else vx := 0;
@ -1495,7 +1491,7 @@ Skip2:
if (mouseOverTriangle >= 0) then if (mouseOverTriangle >= 0) then
StatusBar.Panels[2].Text := Format('Transform #%d', [mouseOverTriangle+1]) StatusBar.Panels[2].Text := Format('Transform #%d', [mouseOverTriangle+1])
else StatusBar.Panels[2].Text := ''; else StatusBar.Panels[2].Text := '';
TriangleView.Refresh;; TriangleView.Refresh;
end end
end; end;
@ -1992,7 +1988,6 @@ end;
procedure TEditForm.FormDestroy(Sender: TObject); procedure TEditForm.FormDestroy(Sender: TObject);
begin begin
// bm.free;
cp.free; cp.free;
Render.free; Render.free;
end; end;
@ -2605,15 +2600,13 @@ begin
if varDragMode and (x <> varDragOld) then if varDragMode and (x <> varDragOld) then
begin begin
Inc(varDragPos, x - varDragOld); Inc(varDragPos, x - varDragOld);
// v := StrToFloat(TValueListEditor(Sender).Values[VarNames(varDragIndex)]);
{ if GetKeyState(VK_MENU) < 0 then v := 100000
if Sender = VEVars then else if GetKeyState(VK_CONTROL) < 0 then v := 10000
v := cp.xform[SelectedTriangle].vars[varDragIndex] else if GetKeyState(VK_SHIFT) < 0 then v := 100
else else v := 1000;
cp.xform[SelectedTriangle].GetVariable(vleVariables.Keys[varDragIndex+1], v);
v := v + (varDragPos*2)/1000.0; v := Round6(varDragValue + varDragPos/v);
}
v := Round6(varDragValue + varDragPos/500.0);
SetCursorPos(MousePos.x, MousePos.y); // hmmm SetCursorPos(MousePos.x, MousePos.y); // hmmm
// this Delphi is WEIRD! // this Delphi is WEIRD!
@ -2881,33 +2874,56 @@ procedure TEditForm.TriangleViewKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); Shift: TShiftState);
begin begin
if (oldMode = modeNone) and if (oldMode = modeNone) and
(key in [VK_SHIFT, VK_MENU, VK_CONTROL]) then (key in [{VK_SHIFT,} VK_MENU, VK_CONTROL]) then
begin begin
oldMode := editMode; oldMode := editMode;
modeKey := key;
if key = VK_MENU then
if editMode <> modeRotate then
begin
editMode := modeRotate;
TriangleView.Cursor := crEditRotate;
end
else begin
editMode := modeMove;
TriangleView.Cursor := crEditMove;
end
else {if key = VK_CONTROL then}
begin
if editMode <> modeScale then
begin
editMode := modeScale;
TriangleView.Cursor := crEditScale;
end
else begin
editMode := modeMove;
TriangleView.Cursor := crEditMove;
end
end;
{
case key of case key of
VK_MENU: VK_MENU:
begin begin
editMode := modeRotate; editMode := modeRotate;
// tbRotate.Down := true; // tbRotate.Down := true;
// if (mouseOverTriangle >= 0) or (SelectMode = false) then
TriangleView.Cursor := crEditRotate; TriangleView.Cursor := crEditRotate;
end; end;
VK_CONTROL: VK_CONTROL:
begin begin
editMode := modeScale; editMode := modeScale;
// tbScale.Down := true; // tbScale.Down := true;
// if (mouseOverTriangle >= 0) or (SelectMode = false) then
TriangleView.Cursor := crEditScale; TriangleView.Cursor := crEditScale;
end; end;
else //VK_SHIFT: else //VK_SHIFT:
begin begin
editMode := modeMove; editMode := modeMove;
// tbMove.Down := true; // tbMove.Down := true;
// if (mouseOverTriangle >= 0) or (SelectMode = false) then
TriangleView.Cursor := crEditMove; TriangleView.Cursor := crEditMove;
end; end;
end; end;
EditorToolBar.Refresh; // EditorToolBar.Refresh;
}
end end
else else
case key of case key of
@ -2935,13 +2951,10 @@ end;
procedure TEditForm.TriangleViewKeyUp(Sender: TObject; var Key: Word; procedure TEditForm.TriangleViewKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState); Shift: TShiftState);
begin begin
if (oldMode <> modeNone) and (key = modeKey) then
if (oldMode <> modeNone) and (
((key = VK_SHIFT) and (editMode = modeMove)) or
((key = VK_MENU) and (editMode = modeRotate)) or
((key = VK_CONTROL) and (editMode = modeScale))
) then
begin begin
assert(key in [VK_MENU, VK_CONTROL]);
editMode := oldMode; editMode := oldMode;
oldMode := modeNone; oldMode := modeNone;
// tbMove.Down := (editMode = modeMove); // tbMove.Down := (editMode = modeMove);
@ -3235,9 +3248,16 @@ begin
end; end;
procedure TEditForm.mnuResetClick(Sender: TObject); procedure TEditForm.mnuResetClick(Sender: TObject);
var
i: integer;
begin begin
MainForm.UpdateUndo; MainForm.UpdateUndo;
MainTriangles[SelectedTriangle] := MainTriangles[-1]; MainTriangles[SelectedTriangle] := MainTriangles[-1];
cp.xform[SelectedTriangle].vars[0] := 1;
for i := 1 to NRVAR - 1 do
begin
cp.xform[SelectedTriangle].vars[i] := 0;
end;
UpdateFlame(True); UpdateFlame(True);
end; end;