fixed unnecessary undo in variation editor

This commit is contained in:
zueuk 2005-09-11 11:28:26 +00:00
parent 638118e984
commit 5b6645bca1

View File

@ -259,6 +259,7 @@ type
Shift: TShiftState); Shift: TShiftState);
procedure tbFullViewClick(Sender: TObject); procedure tbFullViewClick(Sender: TObject);
procedure ColorImageMouseDown(Sender: TObject; Button: TMouseButton; procedure ColorImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
procedure ColorImageMouseMove(Sender: TObject; Shift: TShiftState; X, procedure ColorImageMouseMove(Sender: TObject; Shift: TShiftState; X,
@ -305,8 +306,6 @@ type
colorDragX, colorOldX: integer; colorDragX, colorOldX: integer;
// -- // --
// intoldx, intoldy: integer;
{ Options } { Options }
UseFlameBackground, UseTransformColors: boolean; UseFlameBackground, UseTransformColors: boolean;
BackGroundColor, ReferenceTrianglecolor: integer; BackGroundColor, ReferenceTrianglecolor: integer;
@ -318,12 +317,10 @@ type
function GetPivot: TSPoint; function GetPivot: TSPoint;
function GetTriangleColor(n: integer): TColor; function GetTriangleColor(n: integer): TColor;
// procedure MouseInTriangle(fx, fy: double);
// --Z-- functions moved from outside // --Z-- functions moved from outside (?)
procedure ShowSelectedInfo; procedure ShowSelectedInfo;
procedure Scale(var fx, fy: double; x, y, Width, Height: integer); procedure Scale(var fx, fy: double; x, y, Width, Height: integer);
//unused: function InsideSelected(x, y: double): boolean;
procedure ReadjustWeights(var cp: TControlPoint); procedure ReadjustWeights(var cp: TControlPoint);
public public
@ -2531,9 +2528,8 @@ begin
Allow := False; Allow := False;
end; end;
end; end;
NewVal := Round6(StrToFloat(VEVars.Values[VarNames(i)])); NewVal := Round6(StrToFloat(VEVars.Values[VarNames[i]]));
// if NewVal < 0 then NewVal := 0; VEVars.Values[VarNames[i]] := Format('%.6g', [NewVal]);
VEVars.Values[VarNames(i)] := Format('%.6g', [NewVal]);
{ If it's not the same as the old value and it was valid } { If it's not the same as the old value and it was valid }
if (NewVal <> OldVal) and Allow then if (NewVal <> OldVal) and Allow then
@ -2541,8 +2537,7 @@ begin
MainForm.UpdateUndo; MainForm.UpdateUndo;
// EditedVariation := i; // EditedVariation := i;
cp.xform[SelectedTriangle].vars[i] := NewVal; cp.xform[SelectedTriangle].vars[i] := NewVal;
// VarNormalize(cp); VEVars.Values[VarNames[i]] := Format('%.6g', [cp.xform[SelectedTriangle].vars[i]]);
VEVars.Values[VarNames(i)] := Format('%.6g', [cp.xform[SelectedTriangle].vars[i]]);
ShowSelectedInfo; ShowSelectedInfo;
UpdateFlame(True); UpdateFlame(True);
end; end;
@ -2929,7 +2924,7 @@ begin
tbScale.Down := (editMode = modeScale); tbScale.Down := (editMode = modeScale);
end; end;
// --Z-- Value List Editor // --Z-- Variation List Editor
procedure TEditForm.VEVarsMouseDown(Sender: TObject; Button: TMouseButton; procedure TEditForm.VEVarsMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
@ -2948,7 +2943,7 @@ begin
varDragPos:=x; varDragPos:=x;
SetCaptureControl(VEVars); SetCaptureControl(VEVars);
MainForm.UpdateUndo; HasChanged := False;
end; end;
end; end;
@ -2956,14 +2951,13 @@ procedure TEditForm.VEVarsMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer); Y: Integer);
var var
v: double; v: double;
// i: integer;
cell: TGridCoord; cell: TGridCoord;
begin begin
cell := VEVars.MouseCoord(x, y); cell := VEVars.MouseCoord(x, y);
if (cell.Y > 0) and (cell.X = 0) then VEVars.Cursor := crHandPoint if (cell.Y > 0) and (cell.X = 0) then VEVars.Cursor := crHandPoint
else VEVars.Cursor := crDefault; else VEVars.Cursor := crDefault;
if varMM then if varMM then // hack
begin begin
varMM:=false; varMM:=false;
varDragPos:=x; varDragPos:=x;
@ -2971,10 +2965,11 @@ begin
else else
if varDragMode and (x <> varDragPos) then if varDragMode and (x <> varDragPos) then
begin begin
// i := EditForm.VEVars.Row - 1;
v := cp.xform[SelectedTriangle].vars[varDragIndex]; v := cp.xform[SelectedTriangle].vars[varDragIndex];
v := RoundTo(v + ((x-varDragPos)*2)/1000.0, -3); v := RoundTo(v + ((x-varDragPos)*2)/1000.0, -3);
// someone keeps rounding my variation values... grrrr >:-((
varDragPos:=x; varDragPos:=x;
SetCursorPos(MousePos.x, MousePos.y); // hmmm SetCursorPos(MousePos.x, MousePos.y); // hmmm
varMM:=true; varMM:=true;
@ -2999,6 +2994,7 @@ begin
if HasChanged then if HasChanged then
begin begin
MainForm.UpdateUndo;
UpdateFlame(true); UpdateFlame(true);
HasChanged := False; HasChanged := False;
end; end;
@ -3006,12 +3002,10 @@ begin
end; end;
procedure TEditForm.VEVarsDblClick(Sender: TObject); procedure TEditForm.VEVarsDblClick(Sender: TObject);
//var
// i: integer;
begin begin
MainForm.UpdateUndo; if cp.xform[SelectedTriangle].vars[varDragIndex] = 0 then exit;
// i := EditForm.VEVars.Row - 1; MainForm.UpdateUndo;
cp.xform[SelectedTriangle].vars[varDragIndex] := 0; cp.xform[SelectedTriangle].vars[varDragIndex] := 0;
VEVars.Values[VarNames(varDragIndex)] := '0'; VEVars.Values[VarNames(varDragIndex)] := '0';
HasChanged := True; HasChanged := True;
@ -3022,18 +3016,18 @@ procedure TEditForm.VEVarsDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState); Rect: TRect; State: TGridDrawState);
begin begin
{ {
// if gdFocused in State then if ARow = VEVars.Row then
with eqListBox.Canvas do with VEVars.Canvas do
begin begin
Brush.Color:=clBlue; Brush.Color := clHighlight;
FillRect(Rect); FillRect(Rect);
// VEVars.Refresh;
end; end;
// VEVars.DrawCell(Sender, ACol, ARow, Rect, State); //inherited;
} }
end; end;
procedure TEditForm.cbKeyDown(Sender: TObject; var Key: Word; procedure TEditForm.cbKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
Shift: TShiftState);
begin begin
key:=0; key:=0;
end; end;
@ -3043,7 +3037,7 @@ begin
MainForm.mnuFullScreenClick(Sender); MainForm.mnuFullScreenClick(Sender);
end; end;
// --Z-- // transform color scroller // --Z-- // transform color scroller - TODO
procedure TEditForm.ColorImageMouseDown(Sender: TObject; procedure TEditForm.ColorImageMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
@ -3063,12 +3057,13 @@ procedure TEditForm.ColorImageMouseMove(Sender: TObject;
var var
i, offset: integer; i, offset: integer;
begin begin
{
if colorDrag and (oldX<>x) then if colorDrag and (oldX<>x) then
begin begin
oldX:=x; oldX:=x;
offset := ( ((x - colorDragX) shl 8) div ColorImage.Width ) mod 256; offset := ( ((x - colorDragX) shl 8) div ColorImage.Width ) mod 256;
colorChanged := true; colorChanged := true;
{
for i := 0 to 255 do for i := 0 to 255 do
begin begin
Palette[i][0] := BackupPal[(255 + i - offset) and $FF][0]; Palette[i][0] := BackupPal[(255 + i - offset) and $FF][0];
@ -3078,9 +3073,10 @@ begin
cp.CmapIndex := cmbPalette.ItemIndex; cp.CmapIndex := cmbPalette.ItemIndex;
cp.cmap := Palette; cp.cmap := Palette;
}
colorImage.Refresh; colorImage.Refresh;
end; end;
}
end; end;
procedure TEditForm.ColorImageMouseUp(Sender: TObject; procedure TEditForm.ColorImageMouseUp(Sender: TObject;