Skip to content

Commit

Permalink
Further work on #770: After hint animation was removed, we can also r…
Browse files Browse the repository at this point in the history
…emove the global variable FHintWindowDestroyed, which was needed for coordinating hint animations.
  • Loading branch information
joachimmarder committed Oct 27, 2018
1 parent 0a157c2 commit ae85218
Showing 1 changed file with 14 additions and 72 deletions.
86 changes: 14 additions & 72 deletions Source/VirtualTrees.pas
Original file line number Diff line number Diff line change
Expand Up @@ -850,16 +850,12 @@ TVirtualTreeHintWindow = class(THintWindow)
FTextHeight: Integer;
procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
procedure WMShowWindow(var Message: TWMShowWindow); message WM_SHOWWINDOW;
strict protected
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;

property HintData: TVTHintData read FHintData;
function HintWindowDestroyed(): Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function CalcHintRect(MaxWidth: Integer; const AHint: string; AData: Pointer): TRect; override;
function IsHintMsg(var Msg: TMsg): Boolean; override;
end;
Expand Down Expand Up @@ -5432,34 +5428,8 @@ function TVTDragManager.QueryContinueDrag(EscapePressed: BOOL; KeyState: Integer
Result := S_OK;
end;

//----------------- TVirtualTreeHintWindow -----------------------------------------------------------------------------

var
// This variable is necessary to coordinate the complex interaction between different hints in the application
// and animated hints in our own class. Under certain conditions it can happen that our hint window is destroyed
// while it is still in the animation loop.
FHintWindowDestroyed: Boolean = True;

//----------------------------------------------------------------------------------------------------------------------


constructor TVirtualTreeHintWindow.Create(AOwner: TComponent);

begin
inherited;
FHintWindowDestroyed := False;
end;

//----------------------------------------------------------------------------------------------------------------------

destructor TVirtualTreeHintWindow.Destroy;

begin
FHintWindowDestroyed := True;
inherited;
end;

//----------------------------------------------------------------------------------------------------------------------
//----------------- TVirtualTreeHintWindow -----------------------------------------------------------------------------

procedure TVirtualTreeHintWindow.CMTextChanged(var Message: TMessage);

Expand All @@ -5469,16 +5439,6 @@ procedure TVirtualTreeHintWindow.CMTextChanged(var Message: TMessage);

//----------------------------------------------------------------------------------------------------------------------

function TVirtualTreeHintWindow.HintWindowDestroyed;

// This function exists to inform descendants if the hint window has been destroyed.

begin
Result := FHintWindowDestroyed;
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TVirtualTreeHintWindow.WMEraseBkgnd(var Message: TWMEraseBkgnd);

// The control is fully painted by own code so don't erase its background as this causes flickering.
Expand All @@ -5488,22 +5448,6 @@ procedure TVirtualTreeHintWindow.WMEraseBkgnd(var Message: TWMEraseBkgnd);
end;


//----------------------------------------------------------------------------------------------------------------------

procedure TVirtualTreeHintWindow.WMShowWindow(var Message: TWMShowWindow);

// Clear hint data when the window becomes hidden.

begin
if not Message.Show then
begin
// If the hint window destruction flag to stop any hint window animation was set by a tree
// during its destruction then reset it here to allow other tree instances to still use
// this hint window.
FHintWindowDestroyed := False;
end;
end;

//----------------------------------------------------------------------------------------------------------------------

procedure TVirtualTreeHintWindow.CreateParams(var Params: TCreateParams);
Expand Down Expand Up @@ -16035,9 +15979,6 @@ procedure TBaseVirtualTree.CMHintShowPause(var Message: TCMHintShowPause);
// Tells the application that the tree (and only the tree) does not want a delayed tool tip.
// Normal hints / header hints use the default delay (except for the first time).

var
P: TPoint;

begin
// A little workaround is needed here to make the application class using the correct hint window class.
// Once the application gets ShowHint set to true (which is the case when we want to show hints in the tree) then
Expand All @@ -16046,15 +15987,19 @@ procedure TBaseVirtualTree.CMHintShowPause(var Message: TCMHintShowPause);
// hints for the non-client area to show up (e.g. for the header) by calling CancelHint whenever certain messages
// arrive. By setting the hint show pause to 0 if our hint class was not used recently we make sure
// that the hint timer (in Forms.pas) is not used and our class is created immediately.
if FHintWindowDestroyed then
begin
GetCursorPos(P);
// Check if the mouse is in the header or tool tips are enabled, which must be shown without delay anyway.
if FHeader.UseColumns and (hoShowHint in FHeader.FOptions) and FHeader.InHeader(ScreenToClient(P)) or
(FHintMode = hmToolTip) then
Message.Pause^ := 0;
end
else
//
// Note for newer Delphi versions: Does not work because TApplication.HintMouseMessage() not only checks (Pause = 0) but also TApplication.FHintActive,
// which is initally False. So this code has been commented. See also issue #728.
// if FHintWindowDestroyed then
// begin
// GetCursorPos(P);
// // Check if the mouse is in the header or tool tips are enabled, which must be shown without delay anyway.
// if FHeader.UseColumns and (hoShowHint in FHeader.FOptions) and FHeader.InHeader(ScreenToClient(P)) or
// (FHintMode = hmToolTip) then
// Message.Pause^ := 0;
// end
// else

if FHintMode = hmToolTip then
Message.Pause^ := 0;
end;
Expand Down Expand Up @@ -17526,9 +17471,6 @@ procedure TBaseVirtualTree.WMNCDestroy(var Message: TWMNCDestroy);
// Clean up other stuff.
DeleteObject(FDottedBrush);
FDottedBrush := 0;
if tsInAnimation in FStates then
FHintWindowDestroyed := True; // Stop any pending animation.

inherited;
end;

Expand Down

0 comments on commit ae85218

Please sign in to comment.