From 701eab02701fb280fd51ca79e0829889d9953b86 Mon Sep 17 00:00:00 2001 From: utak3r Date: Tue, 28 Jun 2005 20:06:46 +0000 Subject: [PATCH] + Added triangle scale buttons in editor. + Shift-Alt-Ctrl mouse actions in editor are bound to the values on the triangle tab. --- 2.10/Source/Editor.dfm | 89 +++++++++++++++++++--- 2.10/Source/Editor.pas | 169 +++++++++++++++++++++++++++++++++++------ 2 files changed, 222 insertions(+), 36 deletions(-) diff --git a/2.10/Source/Editor.dfm b/2.10/Source/Editor.dfm index 54762c8..7de2899 100644 --- a/2.10/Source/Editor.dfm +++ b/2.10/Source/Editor.dfm @@ -1,6 +1,6 @@ object EditForm: TEditForm - Left = 392 - Top = 208 + Left = 398 + Top = 205 Width = 582 Height = 471 Caption = 'Editor' @@ -52,7 +52,7 @@ object EditForm: TEditForm Left = 0 Top = 0 Width = 394 - Height = 422 + Height = 429 Align = alClient BevelOuter = bvLowered Color = clBlack @@ -72,7 +72,7 @@ object EditForm: TEditForm end object StatusBar: TStatusBar Left = 0 - Top = 422 + Top = 429 Width = 574 Height = 15 Panels = < @@ -90,14 +90,14 @@ object EditForm: TEditForm Left = 394 Top = 0 Width = 180 - Height = 422 + Height = 429 Align = alRight Alignment = taLeftJustify BevelOuter = bvNone TabOrder = 2 DesignSize = ( 180 - 422) + 429) object lblTransform: TLabel Left = 10 Top = 128 @@ -136,7 +136,7 @@ object EditForm: TEditForm Width = 57 Height = 21 Style = csDropDownList - ItemHeight = 0 + ItemHeight = 13 TabOrder = 1 OnChange = cbTransformsChange end @@ -158,6 +158,7 @@ object EditForm: TEditForm Width = 159 Height = 231 HorzScrollBar.Visible = False + VertScrollBar.Position = 121 VertScrollBar.Smooth = True VertScrollBar.Style = ssFlat VertScrollBar.Tracking = True @@ -168,9 +169,9 @@ object EditForm: TEditForm TabOrder = 0 object TrianglePanel: TPanel Left = 0 - Top = 0 + Top = -121 Width = 155 - Height = 302 + Height = 352 BevelOuter = bvNone TabOrder = 0 object Label9: TLabel @@ -220,6 +221,7 @@ object EditForm: TEditForm Top = 184 Width = 33 Height = 24 + Hint = 'Rotate triangle clockwise around its center' Flat = True Glyph.Data = { F6000000424DF600000000000000760000002800000010000000100000000100 @@ -230,6 +232,8 @@ object EditForm: TEditForm FFFF7007FFFFFFFFFFFFF0007FFFFF7FFFFFF7000788FF70FFFFF80000077770 0FFFFF770000000000FFFFF770000000000FFFFF777000000078FFFFF8777770 078FFFFFFFFF870078FFFFFFFFFFFF778FFFFFFFFFFFFF78FFFF} + ParentShowHint = False + ShowHint = True OnClick = btTrgRotateRightClick end object btTrgRotateLeft: TSpeedButton @@ -237,6 +241,7 @@ object EditForm: TEditForm Top = 184 Width = 33 Height = 24 + Hint = 'Rotate triangle counter clockwise around its center' Flat = True Glyph.Data = { 36030000424D3603000000000000360000002800000010000000100000000100 @@ -265,6 +270,8 @@ object EditForm: TEditForm FFFFFFC0C0C0808080404040FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0C0C0808080FFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} + ParentShowHint = False + ShowHint = True OnClick = btTrgRotateLeftClick end object btTrgMoveUp: TSpeedButton @@ -272,6 +279,7 @@ object EditForm: TEditForm Top = 226 Width = 33 Height = 24 + Hint = 'Move triangle up' Flat = True Glyph.Data = { 36030000424D3603000000000000360000002800000010000000100000000100 @@ -300,6 +308,8 @@ object EditForm: TEditForm FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF808080000000FFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFF808080FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} + ParentShowHint = False + ShowHint = True OnClick = btTrgMoveUpClick end object btTrgMoveRight: TSpeedButton @@ -307,6 +317,7 @@ object EditForm: TEditForm Top = 250 Width = 33 Height = 24 + Hint = 'Move triangle right' Flat = True Glyph.Data = { 36030000424D3603000000000000360000002800000010000000100000000100 @@ -335,6 +346,8 @@ object EditForm: TEditForm FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} + ParentShowHint = False + ShowHint = True OnClick = btTrgMoveRightClick end object btTrgMoveLeft: TSpeedButton @@ -342,6 +355,7 @@ object EditForm: TEditForm Top = 250 Width = 33 Height = 24 + Hint = 'Move triangle left' Flat = True Glyph.Data = { 36030000424D3603000000000000360000002800000010000000100000000100 @@ -370,6 +384,8 @@ object EditForm: TEditForm FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} + ParentShowHint = False + ShowHint = True OnClick = btTrgMoveLeftClick end object btTrgMoveDown: TSpeedButton @@ -377,6 +393,7 @@ object EditForm: TEditForm Top = 274 Width = 33 Height = 24 + Hint = 'Move triangle down' Flat = True Glyph.Data = { 36030000424D3603000000000000360000002800000010000000100000000100 @@ -405,13 +422,55 @@ object EditForm: TEditForm FFFFFFFFFFFFFFFFFFFFFFFF808080000000000000FFFFFFFFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0C0C000 0000404040FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} + ParentShowHint = False + ShowHint = True OnClick = btTrgMoveDownClick end + object btTrgScaleUp: TSpeedButton + Left = 90 + Top = 318 + Width = 33 + Height = 24 + Hint = 'Scale triangle up' + Flat = True + Glyph.Data = { + F6000000424DF600000000000000760000002800000010000000100000000100 + 0400000000008000000000000000000000001000000000000000000000000000 + 8000008000000080800080000000800080008080000080808000C0C0C0000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FFFFFFFFFFFF + FFFFF00000000000000FF00000000000000FFF000FFFFFFFF00FFFF000FFFFFF + F00FFFFF000FFFFFF00FFFFFF000FFFFF00FFFFFFF000FFFF00FFFFFFFF000FF + F00FFFFFFFFF000FF00FFFFFFFFFF000F00FFFFFFFFFFF00000FFFFFFFFFFFF0 + 000FFFFFFFFFFFFF000FFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFF} + ParentShowHint = False + ShowHint = True + OnClick = btTrgScaleUpClick + end + object btTrgScaleDown: TSpeedButton + Left = 22 + Top = 318 + Width = 33 + Height = 24 + Hint = 'Scale triangle down' + Flat = True + Glyph.Data = { + F6000000424DF600000000000000760000002800000010000000100000000100 + 0400000000008000000000000000000000001000000000000000000000000000 + 8000008000000080800080000000800080008080000080808000C0C0C0000000 + FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FFFFFFFFFFFF + FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000 + 0FFFF000000000000FFFFF0000FFFFF00FFFFFF0000FFFF00FFFFFFFF000FFF0 + 0FFFFFFFFF000FF00FFFFFFFFFF000000FFFFFFFFFFF00000FFFFFFFFFFFFF00 + 0FFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} + ParentShowHint = False + ShowHint = True + OnClick = btTrgScaleDownClick + end object txtTrgRotateValue: TEdit Left = 56 Top = 184 Width = 33 - Height = 24 + Height = 21 TabOrder = 7 Text = '5' end @@ -419,7 +478,7 @@ object EditForm: TEditForm Left = 56 Top = 250 Width = 33 - Height = 24 + Height = 21 TabOrder = 8 Text = '0.05' end @@ -499,6 +558,14 @@ object EditForm: TEditForm State = cbChecked TabOrder = 6 end + object txtTrgScaleValue: TEdit + Left = 56 + Top = 320 + Width = 33 + Height = 21 + TabOrder = 9 + Text = '0.1' + end end end end diff --git a/2.10/Source/Editor.pas b/2.10/Source/Editor.pas index e958349..e29f500 100644 --- a/2.10/Source/Editor.pas +++ b/2.10/Source/Editor.pas @@ -124,6 +124,9 @@ type btTrgMoveRight: TSpeedButton; btTrgMoveLeft: TSpeedButton; btTrgMoveDown: TSpeedButton; + txtTrgScaleValue: TEdit; + btTrgScaleUp: TSpeedButton; + btTrgScaleDown: TSpeedButton; procedure FormCreate(Sender: TObject); procedure GraphImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer); @@ -187,6 +190,8 @@ type procedure btTrgMoveRightClick(Sender: TObject); procedure btTrgMoveUpClick(Sender: TObject); procedure btTrgMoveDownClick(Sender: TObject); + procedure btTrgScaleUpClick(Sender: TObject); + procedure btTrgScaleDownClick(Sender: TObject); private bm: TBitmap; cmap: TColorMap; @@ -980,6 +985,7 @@ procedure TEditForm.GraphImageMouseUp(Sender: TObject; Button: TMouseButton; var fx, fy: double; i: integer; + transformvalue: double; begin Scale(fx, fy, x, y, EditForm.GraphImage.Width, EditForm.GraphImage.Height); { Mouse inside a triangle?} @@ -1002,27 +1008,59 @@ begin else if Button = mbLeft then if Shift = [ssAlt] then begin - MainTriangles[i] := RotateTriangleCenter(MainTriangles[i], -(PI / 20)); - HasChanged := True; - UpdateFlame(False); + try + transformvalue := StrToFloat(txtTrgRotateValue.Text); + except + transformvalue := 0; + txtTrgRotateValue.Text := '0'; + end; + if transformvalue <> 0 then + begin + MainTriangles[i] := RotateTriangleCenter(MainTriangles[i], -((PI/180) * transformvalue)); + HasChanged := True; + end; end else if Shift = [ssCtrl, ssAlt] then begin - MainTriangles[i] := RotateTriangleCenter(MainTriangles[i], PI / 20); - HasChanged := True; - UpdateFlame(False); + try + transformvalue := StrToFloat(txtTrgRotateValue.Text); + except + transformvalue := 0; + txtTrgRotateValue.Text := '0'; + end; + if transformvalue <> 0 then + begin + MainTriangles[i] := RotateTriangleCenter(MainTriangles[i], (PI/180) * transformvalue); + HasChanged := True; + end; end else if Shift = [ssShift] then begin - MainTriangles[i] := ScaleTriangleCenter(MainTriangles[i], 1.1); - HasChanged := True; - UpdateFlame(False); + try + transformvalue := StrToFloat(txtTrgScaleValue.Text); + except + transformvalue := 0.0; + txtTrgScaleValue.Text := '0.0'; + end; + if transformvalue <> 0 then + begin + MainTriangles[i] := ScaleTriangleCenter(MainTriangles[i], transformvalue+1.0); + HasChanged := True; + end; end else if Shift = [ssCtrl, ssShift] then begin - MainTriangles[i] := ScaleTriangleCenter(MainTriangles[i], 0.9); - HasChanged := True; - UpdateFlame(False); + try + transformvalue := StrToFloat(txtTrgScaleValue.Text); + except + transformvalue := 0.0; + txtTrgScaleValue.Text := '0.0'; + end; + if transformvalue <> 0 then + begin + MainTriangles[i] := ScaleTriangleCenter(MainTriangles[i], 1.0-transformvalue); + HasChanged := True; + end; end; end; CornerCaught := False; @@ -1035,31 +1073,75 @@ begin end; procedure TEditForm.mnuRotateRightClick(Sender: TObject); +var + offset: double; begin - MainTriangles[SelectedTriangle] := RotateTriangleCenter(MainTriangles[SelectedTriangle], -(PI / 20)); - HasChanged := True; - UpdateFlame(true); + try + offset := StrToFloat(txtTrgRotateValue.Text); + except + offset := 0; + txtTrgRotateValue.Text := '0'; + end; + if offset <> 0 then + begin + MainTriangles[SelectedTriangle] := RotateTriangleCenter(MainTriangles[SelectedTriangle], -((PI/180) * offset)); + HasChanged := True; + UpdateFlame(true); + end; end; procedure TEditForm.mnuRotateLeftClick(Sender: TObject); +var + offset: double; begin - MainTriangles[SelectedTriangle] := RotateTriangleCenter(MainTriangles[SelectedTriangle], PI / 20); - HasChanged := True; - UpdateFlame(true); + try + offset := StrToFloat(txtTrgRotateValue.Text); + except + offset := 0; + txtTrgRotateValue.Text := '0'; + end; + if offset <> 0 then + begin + MainTriangles[SelectedTriangle] := RotateTriangleCenter(MainTriangles[SelectedTriangle], (PI/180) * offset); + HasChanged := True; + UpdateFlame(true); + end; end; procedure TEditForm.mnuScaleUpClick(Sender: TObject); +var + scale: double; begin - MainTriangles[SelectedTriangle] := ScaleTriangleCenter(MainTriangles[SelectedTriangle], 1.1); - HasChanged := True; - UpdateFlame(true); + try + scale := StrToFloat(txtTrgScaleValue.Text); + except + scale := 0.0; + txtTrgScaleValue.Text := '0.0'; + end; + if scale <> 0 then + begin + MainTriangles[SelectedTriangle] := ScaleTriangleCenter(MainTriangles[SelectedTriangle], scale+1.0); + HasChanged := True; + UpdateFlame(true); + end; end; procedure TEditForm.mnuScaleDownClick(Sender: TObject); +var + scale: double; begin - MainTriangles[SelectedTriangle] := ScaleTriangleCenter(MainTriangles[SelectedTriangle], 0.9); - HasChanged := True; - UpdateFlame(true); + try + scale := StrToFloat(txtTrgScaleValue.Text); + except + scale := 0.0; + txtTrgScaleValue.Text := '0.0'; + end; + if scale <> 0 then + begin + MainTriangles[SelectedTriangle] := ScaleTriangleCenter(MainTriangles[SelectedTriangle], 1.0-scale); + HasChanged := True; + UpdateFlame(true); + end; end; procedure TEditForm.FormShow(Sender: TObject); @@ -1963,7 +2045,8 @@ begin end; if offset <> 0 then begin - MainTriangles[SelectedTriangle] := RotateTriangleCenter(MainTriangles[SelectedTriangle], (PI/180) * offset); HasChanged := True; + MainTriangles[SelectedTriangle] := RotateTriangleCenter(MainTriangles[SelectedTriangle], (PI/180) * offset); + HasChanged := True; UpdateFlame(true); end; end; @@ -2070,5 +2153,41 @@ begin end; end; +procedure TEditForm.btTrgScaleUpClick(Sender: TObject); +var + scale: double; +begin + try + scale := StrToFloat(txtTrgScaleValue.Text); + except + scale := 0.0; + txtTrgScaleValue.Text := '0.0'; + end; + if scale <> 0 then + begin + MainTriangles[SelectedTriangle] := ScaleTriangleCenter(MainTriangles[SelectedTriangle], scale+1.0); + HasChanged := True; + UpdateFlame(true); + end; +end; + +procedure TEditForm.btTrgScaleDownClick(Sender: TObject); +var + scale: double; +begin + try + scale := StrToFloat(txtTrgScaleValue.Text); + except + scale := 0.0; + txtTrgScaleValue.Text := '0.0'; + end; + if scale <> 0 then + begin + MainTriangles[SelectedTriangle] := ScaleTriangleCenter(MainTriangles[SelectedTriangle], 1.0-scale); + HasChanged := True; + UpdateFlame(true); + end; +end; + end.