Skip to content

Commit

Permalink
Adjustment on new optional behavior of Tree panel
Browse files Browse the repository at this point in the history
Applied a little delay before restoring Editor width on certain events.
Minor fixes
  • Loading branch information
dpradov committed Mar 7, 2024
1 parent cc526f1 commit 39320c0
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions kn_Main.pas
Expand Up @@ -1014,7 +1014,7 @@ TForm_Main = class(TForm)
procedure TVClick(Sender: TObject);
procedure SplitterNoteMoved(Sender: TObject);
procedure TVOnHint(Sender: TObject; Node: TTreeNTNode; var NewText: string);
procedure CheckRestoreTreeWidth;
procedure CheckRestoreTreeWidth(Delayed: boolean);
procedure CheckExpandTreeWidth;
{
procedure TVBeforeItemPaint(Sender: TObject;
Expand Down Expand Up @@ -3542,8 +3542,9 @@ procedure TForm_Main.RxRTFSelectionChange(Sender: TObject);
end;
end;

CheckRestoreTreeWidth;
end;

CheckRestoreTreeWidth (True);
end; // RxRTFSelection Change

procedure TForm_Main.RxRTFChange(Sender: TObject);
Expand Down Expand Up @@ -5039,6 +5040,9 @@ procedure TForm_Main.SplitterNoteMoved(Sender: TObject);
NoteFile.Modified := true;
UpdateNoteFileState( [fscModified] );
end;

if keyOptions.AltMargins then
ActiveNote.Editor.Refresh;
end;


Expand All @@ -5060,19 +5064,24 @@ procedure TForm_Main.CheckExpandTreeWidth;
else
Width := myNote.TV.Width;

if (myNote.TreeMaxWidth > 0) and (myNote.TreeMaxWidth > Width) then
if (myNote.TreeMaxWidth > 0) and (myNote.TreeMaxWidth > Width) then begin
if myNote.VerticalLayout then
myNote.TV.Height:= myNote.TreeMaxWidth
else
myNote.TV.Width:= myNote.TreeMaxWidth;

if keyOptions.AltMargins then
ActiveNote.Editor.Refresh;
end;
end;
end;

procedure TForm_Main.CheckRestoreTreeWidth;
procedure TForm_Main.CheckRestoreTreeWidth (Delayed: boolean);
var
Width: integer;
myNote: TTreeNote;
begin

if (ActiveNote.Kind = ntTree) then begin
myNote:= TTreeNote(ActiveNote);

Expand All @@ -5083,6 +5092,8 @@ procedure TForm_Main.CheckRestoreTreeWidth;
Width := myNote.TV.Width;

if (Width > TTreeNote(ActiveNote).TreeWidth) then begin
if Delayed then
Sleep(250);
if myNote.VerticalLayout then
myNote.TV.Height:= myNote.TreeWidth
else
Expand All @@ -5095,7 +5106,7 @@ procedure TForm_Main.CheckRestoreTreeWidth;

procedure TForm_Main.RxRTFEnter(Sender: TObject);
begin
CheckRestoreTreeWidth;
CheckRestoreTreeWidth (False);
end;

procedure TForm_Main.TVEnter(Sender: TObject);
Expand Down Expand Up @@ -6877,7 +6888,7 @@ procedure TForm_Main.MMViewResPanelClick(Sender: TObject);
if (Sender = nil) and KeyOptions.ResPanelShow and assigned(ActiveNote) then begin
if ActiveNote.Editor.Focused or ((ActiveNote.Kind = ntTree) and TTreeNote(ActiveNote).TV.Focused) then begin
FocusResourcePanel;
CheckRestoreTreeWidth;
CheckRestoreTreeWidth (False);
exit;
end;
end;
Expand All @@ -6897,7 +6908,7 @@ procedure TForm_Main.MMViewResPanelClick(Sender: TObject);
else
FocusActiveNote;

CheckRestoreTreeWidth;
CheckRestoreTreeWidth (False);
end; // MMViewResPanelClick


Expand Down

0 comments on commit 39320c0

Please sign in to comment.