interface fixes

This commit is contained in:
zueuk 2006-09-19 16:03:17 +00:00
parent eac94ba8a1
commit 3b2ef8ab92
4 changed files with 145 additions and 88 deletions

View File

@ -2146,7 +2146,7 @@ begin
Screen.Cursor := crDefault; Screen.Cursor := crDefault;
SetCaptureControl(nil); SetCaptureControl(nil);
if viewDragged=false then // haven't dragged - popup menu then if viewDragged = false then // haven't dragged - popup menu then
begin begin
GetCursorPos(mousepos); // hmmm GetCursorPos(mousepos); // hmmm
if mouseOverTriangle < 0 then if mouseOverTriangle < 0 then
@ -3380,6 +3380,29 @@ begin
EditForm.StatusBar.Panels[2].Text := Format('Zoom: %f', [GraphZoom]); EditForm.StatusBar.Panels[2].Text := Format('Zoom: %f', [GraphZoom]);
TriangleView.Invalidate; TriangleView.Invalidate;
end; end;
VK_ESCAPE:
begin
if TriangleCaught or CornerCaught or EdgeCaught then begin
if modeHack then begin
assert(oldMode <> modeNone);
editMode := oldMode;
oldMode := modeNone;
modeHack := false;
end;
if HasChanged then
begin
MainTriangles[SelectedTriangle] := OldTriangle;
HasChanged := False;
end;
EdgeCaught := false;
CornerCaught := false;
TriangleCaught := false;
TriangleView.Invalidate;
UpdateFlameX;
end;
end
end; end;
end; end;

View File

@ -119,7 +119,7 @@ object RenderForm: TRenderForm
Caption = 'Shutdown on complete' Caption = 'Shutdown on complete'
TabOrder = 6 TabOrder = 6
end end
object cbPostProcess: TCheckBox object chkPostProcess: TCheckBox
Left = 8 Left = 8
Top = 377 Top = 377
Width = 121 Width = 121

View File

@ -35,7 +35,7 @@ type
chkSave: TCheckBox; chkSave: TCheckBox;
StatusBar: TStatusBar; StatusBar: TStatusBar;
chkShutdown: TCheckBox; chkShutdown: TCheckBox;
cbPostProcess: TCheckBox; chkPostProcess: TCheckBox;
chkSaveIncompleteRenders: TCheckBox; chkSaveIncompleteRenders: TCheckBox;
PageCtrl: TPageControl; PageCtrl: TPageControl;
TabSettings: TTabSheet; TabSettings: TTabSheet;
@ -152,11 +152,12 @@ begin
chkLimitMem.Enabled := true; chkLimitMem.Enabled := true;
cbMaxMemory.enabled := chkLimitMem.Checked; cbMaxMemory.enabled := chkLimitMem.Checked;
cbBitsPerSample.Enabled := true; cbBitsPerSample.Enabled := true;
cbPostProcess.Enabled := not chkLimitMem.Checked; chkPostProcess.Enabled := not chkLimitMem.Checked;
chkSaveIncompleteRenders.Enabled := not chkLimitMem.Checked;
btnRender.Enabled := true; btnRender.Enabled := true;
cmbPreset.enabled := true; cmbPreset.enabled := true;
chkSave.enabled := true; chkSave.enabled := true;
cbPostProcess.enabled := true; chkPostProcess.enabled := true;
chkShutdown.enabled := true; chkShutdown.enabled := true;
btnSavePreset.enabled := true; btnSavePreset.enabled := true;
btnDeletePreset.enabled := true; btnDeletePreset.enabled := true;
@ -230,7 +231,7 @@ begin
Output.Lines.Add(' Total time:' + TimeToString(EndTime - StartTime)); Output.Lines.Add(' Total time:' + TimeToString(EndTime - StartTime));
Output.Lines.Add(''); Output.Lines.Add('');
if not chkLimitMem.Checked and cbPostProcess.checked then if not chkLimitMem.Checked and chkPostProcess.checked then
DoPostProcess; DoPostProcess;
Renderer.Free; Renderer.Free;
@ -253,14 +254,8 @@ begin
end; end;
Output.Lines.Add(TimeToStr(Now) + ' : Rendering terminated!'); Output.Lines.Add(TimeToStr(Now) + ' : Rendering terminated!');
sndPlaySound(pchar(SND_ALIAS_SYSTEMEXCLAMATION), SND_ALIAS_ID or SND_NOSTOP or SND_ASYNC);
(*
if SaveIncompleteRenders and not chkLimitMem.Checked then begin
Output.Lines.Add('Saving incomplete image...');
Renderer.SaveImage(FileName);
end;
*)
Output.Lines.Add(''); Output.Lines.Add('');
sndPlaySound(pchar(SND_ALIAS_SYSTEMEXCLAMATION), SND_ALIAS_ID or SND_NOSTOP or SND_ASYNC);
Renderer.Free; Renderer.Free;
Renderer := nil; Renderer := nil;
@ -419,7 +414,7 @@ begin
cbBitsPerSample.Enabled := false; cbBitsPerSample.Enabled := false;
cmbPreset.enabled := false; cmbPreset.enabled := false;
chkSave.enabled := false; chkSave.enabled := false;
// cbPostProcess.enabled := false; // chkPostProcess.enabled := false;
// chkShutdown.enabled := false; // chkShutdown.enabled := false;
btnSavePreset.enabled := false; btnSavePreset.enabled := false;
btnDeletePreset.enabled := false; btnDeletePreset.enabled := false;
@ -592,9 +587,13 @@ begin
end; end;
procedure TRenderForm.chkLimitMemClick(Sender: TObject); procedure TRenderForm.chkLimitMemClick(Sender: TObject);
var
mm: boolean;
begin begin
cbMaxMemory.enabled := chkLimitMem.Checked; mm := chkLimitMem.Checked;
cbPostProcess.Enabled := not chkLimitMem.Checked; cbMaxMemory.enabled := mm;
chkPostProcess.Enabled := not mm;
chkSaveIncompleteRenders.Enabled := not mm;
end; end;
procedure TRenderForm.txtFilenameChange(Sender: TObject); procedure TRenderForm.txtFilenameChange(Sender: TObject);

View File

@ -284,10 +284,9 @@ type
Renderer: TRenderThread; Renderer: TRenderThread;
FMouseMoveState: TMouseMoveState; FMouseMoveState: TMouseMoveState;
FSelectRect: TRect; FSelectRect, FClickRect: TRect;
DrawSelection: boolean; DrawSelection: boolean;
FRotateAngle: double; FRotateAngle: double;
FClickPos: TPoint;
FClickAngle: double; FClickAngle: double;
FViewImage: TPngObject; FViewImage: TPngObject;
FViewPos, FViewOldPos: TSPoint; FViewPos, FViewOldPos: TSPoint;
@ -301,7 +300,7 @@ type
XMLPaletteCount: integer; XMLPaletteCount: integer;
procedure DrawImageView; procedure DrawImageView;
procedure DrawZoomWindow(ARect: TRect); procedure DrawZoomWindow;
procedure DrawRotatelines(Angle: double); procedure DrawRotatelines(Angle: double);
procedure FillVariantMenu; procedure FillVariantMenu;
@ -389,7 +388,7 @@ uses
FullScreen, FormRender, Mutate, Adjust, Browser, Save, About, CmapData, FullScreen, FormRender, Mutate, Adjust, Browser, Save, About, CmapData,
HtmlHlp, ScriptForm, FormFavorites, FormExport, msMultiPartFormData, HtmlHlp, ScriptForm, FormFavorites, FormExport, msMultiPartFormData,
ImageColoring, RndFlame, ImageColoring, RndFlame,
Tracer; Tracer, Types;
{$R *.DFM} {$R *.DFM}
@ -2674,8 +2673,8 @@ begin
FMouseMoveState := msDrag; FMouseMoveState := msDrag;
scale := FViewScale * Image.Width / FViewImage.Width; scale := FViewScale * Image.Width / FViewImage.Width;
FViewPos.X := FViewPos.X - (FSelectRect.Right - FSelectRect.Left) / scale; FViewPos.X := FViewPos.X - (FClickRect.Right - FClickRect.Left) / scale;
FViewPos.Y := FViewPos.Y - (FSelectRect.Bottom - FSelectRect.Top) / scale; FViewPos.Y := FViewPos.Y - (FClickRect.Bottom - FClickRect.Top) / scale;
end; end;
msRotateMove: msRotateMove:
FMouseMoveState := msRotate; FMouseMoveState := msRotate;
@ -4230,52 +4229,29 @@ procedure TMainForm.ImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); Shift: TShiftState; X, Y: Integer);
begin begin
if button <> mbLeft then exit; if button <> mbLeft then exit;
FClickPos := Point(x, y); FClickRect.TopLeft := Point(x, y);
FClickRect.BottomRight := FclickRect.TopLeft;
case FMouseMoveState of case FMouseMoveState of
msZoomWindow: msZoomWindow:
begin begin
FSelectRect.TopLeft := Point(x, y); FSelectRect.TopLeft := Point(x, y);
FSelectRect.BottomRight := Point(x, y); FSelectRect.BottomRight := Point(x, y);
DrawZoomWindow(FSelectRect); DrawZoomWindow;
FMouseMoveState := msZoomWindowMove; FMouseMoveState := msZoomWindowMove;
end; end;
msZoomOutWindow: msZoomOutWindow:
begin begin
FSelectRect.TopLeft := Point(x, y); FSelectRect.TopLeft := Point(x, y);
FSelectRect.BottomRight := Point(x, y); FSelectRect.BottomRight := Point(x, y);
DrawZoomWindow(FSelectRect); DrawZoomWindow;
FMouseMoveState := msZoomOutWindowMove; FMouseMoveState := msZoomOutWindowMove;
end; end;
msDrag: msDrag:
begin begin
if not assigned(FViewImage) then exit; if not assigned(FViewImage) then exit;
{
if not assigned(FViewBMP) then
FViewBMP := TBitmap.Create;
FViewBMP.Width := ClientWidth + 100;
FViewBMP.Height := ClientHeight + 100;
FViewBMP.Canvas.Brush.Color := clWhite;
DestRect.Left := 0; // FSelectRect.TopLeft := Point(x, y);
DestRect.Right := FViewBMP.Width; // FSelectRect.BottomRight := Point(x, y);
DestRect.Top := 0;
DestRect.Bottom := FViewBMP.Height;
FviewBMP.Canvas.Pen.Color := RGB(MainCP.background[0], MainCP.background[1], MainCP.background[2]);
FviewBMP.Canvas.Brush.Color := RGB(MainCP.background[0], MainCP.background[1], MainCP.background[2]);
FViewBMP.Canvas.Rectangle(DestRect);
SourceRect := ClientRect;
DestRect := SourceRect;
DestRect.TopLeft.X := DestRect.TopLeft.X + 50;
DestRect.TopLeft.Y := DestRect.TopLeft.Y + 50;
DestRect.BottomRight.X := DestRect.BottomRight.X + 50;
DestRect.BottomRight.Y := DestRect.BottomRight.Y + 50;
FViewBMP.Canvas.CopyRect(DestRect, Image.Canvas, SourceRect);
}
FSelectRect.TopLeft := Point(x, y);
FSelectRect.BottomRight := Point(x, y);
FMouseMoveState := msDragMove; FMouseMoveState := msDragMove;
end; end;
msRotate: msRotate:
@ -4283,7 +4259,7 @@ begin
FClickAngle := arctan2(y-Image.Height/2, Image.Width/2-x); FClickAngle := arctan2(y-Image.Height/2, Image.Width/2-x);
FRotateAngle := 0; FRotateAngle := 0;
FSelectRect.Left := x; // FSelectRect.Left := x;
DrawRotateLines(FRotateAngle); DrawRotateLines(FRotateAngle);
FMouseMoveState := msRotateMove; FMouseMoveState := msRotateMove;
end; end;
@ -4312,51 +4288,51 @@ begin
msZoomWindowMove, msZoomWindowMove,
msZoomOutWindowMove: msZoomOutWindowMove:
begin begin
if DrawSelection then DrawZoomWindow(FSelectRect); if DrawSelection then DrawZoomWindow;
dx := x - FClickPos.X; FClickRect.BottomRight := Point(x, y);
dy := y - FClickPos.Y; dx := x - FClickRect.TopLeft.X;
dy := y - FClickRect.TopLeft.Y;
if ssAlt in Shift then begin if ssAlt in Shift then begin
if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then
dy := Round(dx / Image.Width * Image.Height) dy := Round(dx / Image.Width * Image.Height)
else else
dx := Round(dy / Image.Height * Image.Width); dx := Round(dy / Image.Height * Image.Width);
FSelectRect.Left := FClickPos.X - dx; FSelectRect.Left := FClickRect.TopLeft.X - dx;
FSelectRect.Top := FClickPos.Y - dy; FSelectRect.Top := FClickRect.TopLeft.Y - dy;
FSelectRect.Right := FClickPos.X + dx; FSelectRect.Right := FClickRect.TopLeft.X + dx;
FSelectRect.Bottom := FClickPos.Y + dy; FSelectRect.Bottom := FClickRect.TopLeft.Y + dy;
end end
else if ssShift in Shift then begin else if ssShift in Shift then begin
FSelectRect.Left := FClickPos.X; FSelectRect.TopLeft := FClickRect.TopLeft;
FSelectRect.Top := FClickPos.Y;
sgn := IfThen(dy*dx >=0, 1, -1); sgn := IfThen(dy*dx >=0, 1, -1);
if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then begin if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then begin
FSelectRect.Right := x; FSelectRect.Right := x;
FSelectRect.Bottom := FClickPos.Y + sgn * Round(dx / Image.Width * Image.Height); FSelectRect.Bottom := FClickRect.TopLeft.Y + sgn * Round(dx / Image.Width * Image.Height);
end end
else begin else begin
FSelectRect.Right := FClickPos.X + sgn * Round(dy / Image.Height * Image.Width); FSelectRect.Right := FClickRect.TopLeft.X + sgn * Round(dy / Image.Height * Image.Width);
FSelectRect.Bottom := y; FSelectRect.Bottom := y;
end; end;
end end
else begin else begin
sgn := IfThen(dy*dx >=0, 1, -1); sgn := IfThen(dy*dx >=0, 1, -1);
if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then begin if (dy = 0) or (abs(dx/dy) >= Image.Width/Image.Height) then begin
cy := (y + FClickPos.Y) div 2; cy := (y + FClickRect.TopLeft.Y) div 2;
FSelectRect.Left := FClickPos.X; FSelectRect.Left := FClickRect.TopLeft.X;
FSelectRect.Right := x; FSelectRect.Right := x;
FSelectRect.Top := cy - sgn * Round(dx / 2 / Image.Width * Image.Height); FSelectRect.Top := cy - sgn * Round(dx / 2 / Image.Width * Image.Height);
FSelectRect.Bottom := cy + sgn * Round(dx / 2 / Image.Width * Image.Height); FSelectRect.Bottom := cy + sgn * Round(dx / 2 / Image.Width * Image.Height);
end end
else begin else begin
cx := (x + FClickPos.X) div 2; cx := (x + FClickRect.TopLeft.X) div 2;
FSelectRect.Left := cx - sgn * Round(dy / 2 / Image.Height * Image.Width); FSelectRect.Left := cx - sgn * Round(dy / 2 / Image.Height * Image.Width);
FSelectRect.Right := cx + sgn * Round(dy / 2 / Image.Height * Image.Width); FSelectRect.Right := cx + sgn * Round(dy / 2 / Image.Height * Image.Width);
FSelectRect.Top := FClickPos.Y; FSelectRect.Top := FClickRect.TopLeft.Y;
FSelectRect.Bottom := y; FSelectRect.Bottom := y;
end; end;
end; end;
DrawZoomWindow(FSelectRect); DrawZoomWindow;
DrawSelection := true; DrawSelection := true;
end; end;
msDragMove: msDragMove:
@ -4365,9 +4341,9 @@ begin
assert(FViewScale <> 0); assert(FViewScale <> 0);
scale := FViewScale * Image.Width / FViewImage.Width; scale := FViewScale * Image.Width / FViewImage.Width;
FViewPos.X := FViewPos.X + (x - FSelectRect.Right) / scale; FViewPos.X := FViewPos.X + (x - FClickRect.Right) / scale;
FViewPos.Y := FViewPos.Y + (y - FSelectRect.Bottom) / scale; FViewPos.Y := FViewPos.Y + (y - FClickRect.Bottom) / scale;
FSelectRect.BottomRight := Point(x, y); //FClickRect.BottomRight := Point(x, y);
DrawImageView; DrawImageView;
end; end;
@ -4378,7 +4354,7 @@ begin
FRotateAngle := arctan2(y-Image.Height/2, Image.Width/2-x) - FClickAngle; FRotateAngle := arctan2(y-Image.Height/2, Image.Width/2-x) - FClickAngle;
if ssShift in Shift then // angle snap if ssShift in Shift then // angle snap
FRotateAngle := Round(FRotateAngle/snap_angle)*snap_angle; FRotateAngle := Round(FRotateAngle/snap_angle)*snap_angle;
FSelectRect.Left := x; //SelectRect.Left := x;
// pdjpointgen.Rotate(FRotateAngle); // pdjpointgen.Rotate(FRotateAngle);
// FRotateAngle := 0; // FRotateAngle := 0;
@ -4394,6 +4370,7 @@ end;
} }
end; end;
end; end;
FClickRect.BottomRight := Point(x, y);
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -4405,7 +4382,7 @@ begin
case FMouseMoveState of case FMouseMoveState of
msZoomWindowMove: msZoomWindowMove:
begin begin
DrawZoomWindow(FSelectRect); DrawZoomWindow;
FMouseMoveState := msZoomWindow; FMouseMoveState := msZoomWindow;
if (abs(FSelectRect.Left - FSelectRect.Right) < 10) or if (abs(FSelectRect.Left - FSelectRect.Right) < 10) or
(abs(FSelectRect.Top - FSelectRect.Bottom) < 10) then (abs(FSelectRect.Top - FSelectRect.Bottom) < 10) then
@ -4425,7 +4402,7 @@ begin
end; end;
msZoomOutWindowMove: msZoomOutWindowMove:
begin begin
DrawZoomWindow(FSelectRect); DrawZoomWindow;
FMouseMoveState := msZoomOutWindow; FMouseMoveState := msZoomOutWindow;
if (abs(FSelectRect.Left - FSelectRect.Right) < 10) or if (abs(FSelectRect.Left - FSelectRect.Right) < 10) or
(abs(FSelectRect.Top - FSelectRect.Bottom) < 10) then (abs(FSelectRect.Top - FSelectRect.Bottom) < 10) then
@ -4447,16 +4424,16 @@ begin
end; end;
msDragMove: msDragMove:
begin begin
FSelectRect.BottomRight := Point(x, y); FClickRect.BottomRight := Point(x, y);
FMouseMoveState := msDrag; FMouseMoveState := msDrag;
if ((x = 0) and (y = 0)) or // double clicked if ((x = 0) and (y = 0)) or // double clicked
((FSelectRect.left = FSelectRect.right) and (FSelectRect.top = FSelectRect.bottom)) ((FClickRect.left = FClickRect.right) and (FClickRect.top = FClickRect.bottom))
then Exit; then Exit;
StopThread; StopThread;
UpdateUndo; UpdateUndo;
MainCp.MoveRect(FSelectRect); MainCp.MoveRect(FClickRect);
RedrawTimer.Enabled := True; RedrawTimer.Enabled := True;
UpdateWindows; UpdateWindows;
@ -4570,9 +4547,9 @@ var
begin begin
bkuPen := TPen.Create; bkuPen := TPen.Create;
bkuPen.Assign(Image.Canvas.Pen); bkuPen.Assign(Image.Canvas.Pen);
Image.Canvas.Pen.Mode := pmNotXor; Image.Canvas.Pen.Mode := pmXor;
Image.Canvas.Pen.Color := clBlack; Image.Canvas.Pen.Color := clWhite;
Image.Canvas.Pen.Style := psDash; Image.Canvas.Pen.Style := psDot; //psDash;
Image.Canvas.Brush.Style := bsClear; Image.Canvas.Brush.Style := bsClear;
// Image.Canvas.Rectangle(FSelectRect); // Image.Canvas.Rectangle(FSelectRect);
@ -4603,20 +4580,72 @@ begin
end; end;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
procedure TMainForm.DrawZoomWindow(ARect: TRect); procedure TMainForm.DrawZoomWindow;
const
cornerSize = 32;
var var
bkuPen: TPen; bkuPen: TPen;
dx, dy: integer;
l, r, t, b: integer;
begin begin
bkuPen := TPen.Create; bkuPen := TPen.Create;
bkuPen.Assign(Image.Canvas.Pen); bkuPen.Assign(Image.Canvas.Pen);
Image.Canvas.Pen.Mode := pmNotXor; with Image.Canvas do begin
Image.Canvas.Pen.Color := clBlack; Pen.Mode := pmXor;
Image.Canvas.Pen.Style := psDash; Pen.Color := clWhite;
Image.Canvas.Brush.Style := bsClear; Brush.Style := bsClear;
Image.Canvas.Rectangle(FSelectRect); Pen.Style := psDot; //psDash;
Image.Canvas.Pen.Assign(bkuPen); if ssAlt in FShiftState then
begin
dx := FClickRect.Right - FClickRect.Left;
dy := FClickRect.Bottom - FClickRect.Top;
Rectangle(FClickRect.Left - dx, FClickRect.Top - dy, FClickRect.Right, FClickRect.Bottom);
end
else Rectangle(FClickRect);
dx := FSelectRect.Right - FSelectRect.Left;
if dx >= 0 then begin
l := FSelectRect.Left - 1;
r := FSelectRect.Right;
end
else begin
dx := -dx;
l := FSelectRect.Right - 1;
r := FSelectRect.Left;
end;
dx := min(dx div 2 - 1, cornerSize);
dy := FSelectRect.Bottom - FSelectRect.Top;
if dy >= 0 then begin
t := FSelectRect.Top - 1;
b := FSelectRect.Bottom;
end
else begin
dy := -dy;
t := FSelectRect.Bottom - 1;
b := FSelectRect.Top;
end;
dy := min(dy div 2, cornerSize);
pen.Style := psSolid;
MoveTo(l + dx, t);
LineTo(l, t);
LineTo(l, t + dy);
MoveTo(r - dx, t);
LineTo(r, t);
LineTo(r, t + dy);
MoveTo(r - dx, b);
LineTo(r, b);
LineTo(r, b - dy);
MoveTo(l + dx, b);
LineTo(l, b);
LineTo(l, b - dy);
Pen.Assign(bkuPen);
end;
bkuPen.Free; bkuPen.Free;
end; end;
@ -4769,7 +4798,13 @@ begin
SetCursorPos(MousePos.x, MousePos.y); SetCursorPos(MousePos.x, MousePos.y);
end; end;
FShiftState := Shift; if (FMouseMoveState in [msZoomWindowMove, msZoomOutWindowMove]) then
begin
DrawZoomWindow;
FShiftState := Shift;
DrawZoomWindow;
end
else FShiftState := Shift;
end; end;
end; end;