Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
albireo77 committed Jan 6, 2025
1 parent 96095d4 commit afd634b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
38 changes: 18 additions & 20 deletions Blocks/Base_Block.pas
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ TBlock = class(TCustomControl, IWithId, IWithFocus, IExportable, IMemoEx)
procedure SetPage(APage: TBlockTabSheet); virtual;
function GetPage: TBlockTabSheet; virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure OnWindowPosChanging(AWindowPos: PWindowPos); virtual;
procedure OnCommentPosChanging(AComment: TComment; dx, dy: integer); virtual;
function ProcessComments: boolean;
function IsAncestor(AParent: TObject): boolean;
function GetErrorMsg(AEdit: TCustomEdit): string;
Expand Down Expand Up @@ -1069,7 +1069,16 @@ function TBlock.IsInFront(AControl: TWinControl): boolean;

procedure TBlock.WMWindowPosChanging(var Msg: TWMWindowPosChanging);
begin
OnWindowPosChanging(Msg.WindowPos);
if FPosChanged and ((Msg.WindowPos.flags and SWP_NOMOVE) = 0) then
begin
var dx := Msg.WindowPos.x - Left;
var dy := Msg.WindowPos.y - Top;
if (dx <> 0) or (dy <> 0) then
begin
for var comment in GetComments(True) do
OnCommentPosChanging(comment, dx, dy);
end;
end;
inherited;
end;

Expand All @@ -1080,25 +1089,14 @@ procedure TBlock.WMWindowPosChanged(var Msg: TWMWindowPosChanged);
inherited;
end;

procedure TBlock.OnWindowPosChanging(AWindowPos: PWindowPos);
procedure TBlock.OnCommentPosChanging(AComment: TComment; dx, dy: integer);
begin
if FPosChanged and ((AWindowPos.flags and SWP_NOMOVE) = 0) then
begin
var dx := AWindowPos.x - Left;
var dy := AWindowPos.y - Top;
if (dx <> 0) or (dy <> 0) then
begin
for var comment in GetComments(True) do
begin
if not comment.Moved then
begin
if comment.Visible then
TInfra.MoveWinTopZ(comment, comment.Left+dx, comment.Top+dy);
comment.Moved := True;
end;
end;
end;
end;
if not AComment.Moved then
begin
if AComment.Visible then
TInfra.MoveWinTopZ(AComment, AComment.Left+dx, AComment.Top+dy);
AComment.Moved := True;
end;
end;

function TBlock.GetPinComments: IEnumerable<TComment>;
Expand Down
25 changes: 7 additions & 18 deletions Blocks/Main_Block.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
interface

uses
WinApi.Windows, WinApi.Messages, Vcl.Graphics, Vcl.ComCtrls, System.Classes,
System.Math, Base_Block, OmniXML, Interfaces, Types, BlockTabSheet;
WinApi.Windows, Vcl.Graphics, Vcl.ComCtrls, System.Classes, System.Math, Base_Block,
OmniXML, Interfaces, Types, BlockTabSheet, Comment;

type

Expand Down Expand Up @@ -58,7 +58,7 @@ TMainBlock = class(TGroupBlock, IWinControl)
FStopLabel: string;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure Paint; override;
procedure OnWindowPosChanging(AWindowPos: PWindowPos); override;
procedure OnCommentPosChanging(AComment: TComment; dx, dy: integer); override;
procedure SetPage(APage: TBlockTabSheet); override;
function GetFunctionLabel(var ARect: TRect): string;
function GetPage: TBlockTabSheet; override;
Expand All @@ -73,7 +73,7 @@ implementation

uses
Vcl.Forms, System.SysUtils, System.StrUtils, Infrastructure, XMLProcessor, OmniXMLUtils,
Navigator_Form, UserFunction, Comment, Constants;
Navigator_Form, UserFunction, Constants;

constructor TMainBlock.Create(APage: TBlockTabSheet; const ABlockParms: TBlockParms);
begin
Expand Down Expand Up @@ -466,21 +466,10 @@ function TMainBlock.IsBoldDesc: boolean;
result := True;
end;

procedure TMainBlock.OnWindowPosChanging(AWindowPos: PWindowPos);
procedure TMainBlock.OnCommentPosChanging(AComment: TComment; dx, dy: integer);
begin
if FPosChanged and ((AWindowPos.flags and SWP_NOMOVE) = 0) then
begin
var dx := AWindowPos.x - Left;
var dy := AWindowPos.y - Top;
if (dx <> 0) or (dy <> 0) then
begin
for var comment in GetComments(True) do
begin
if comment.Visible then
TInfra.MoveWinTopZ(comment, comment.Left+dx, comment.Top+dy);
end;
end;
end;
if AComment.Visible then
TInfra.MoveWinTopZ(AComment, AComment.Left+dx, AComment.Top+dy);
end;

function TMainBlock.GetUndoObject: TObject;
Expand Down

0 comments on commit afd634b

Please # to comment.