You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Method TBaseVirtualTree.GetOffsets (introduced in #369) incorrectly applies FImagesMargin for TVTElement.ofsCheckBox when no check image is needed. Thus, its out-param pOffsets then contains values two pixels too high for TVTElement.ofsCheckBox and all following elements.
Observations
This can, for example, cause a wrong result of TBaseVirtualTree.GetMaxColumnWidth, making autosized columns wider than necessary.
It might also be causing #811, I guess.
Reproduction
It's nicely reproducible by extending Minimal demo project:
Get write access to private field FImagesMargin using the with Self do class helper hack:
type
TVirtualTreeHelper = class helper for TBaseVirtualTree
procedure SetImagesMargin(const AValue: Integer);
end;
procedure TVirtualTreeHelper.SetImagesMargin(const AValue: Integer);
begin
with Self do
FImagesMargin := AValue;
end;
Add a TSpinEdit control to TMainForm.dfm and set its Value to 2 as it is the hard coded value of FImagesMargin:
object SpinEdit1: TSpinEdit
Value = 2
end
Implement the spin edit's OnChangeEvent to apply its value to FImagesMargin:
procedure TMainForm.SpinEdit1Change(Sender: TObject);
begin
VST.SetImagesMargin(SpinEdit1.Value);
VST.Invalidate;
end;
Compile and start to initially see the unchanged behavior:
Use the spin edit to change FImagesMargin and unexpectibly see the nodes' labels move to the right when increasing it or to the left when decreasing it:
As there are no images visible at all, FImagesMargin shouldn't change the display at all.
The text was updated successfully, but these errors were encountered:
hermannoffen
added a commit
to hermannoffen/Virtual-TreeView
that referenced
this issue
May 10, 2023
- updated method `TBaseVirtualTree.GetOffsets`:
- added new local variable `lNodeIdent` to calculate `MainColumn`'s indentation
- initialized `pOffsets` elements `ofsToggleButton` and `ofsCheckBox` neutrally with `ofsMargin`
- for `MainColumn`:
- increase `pOffsets` for `ofsToggleButton` by full value of `lNodeIndent` first
- then decrease it, as before, to center the toggle button's position
- increase `ofsCheckBox` by full value of `lNodeIdent`
- eventually apply `fImagesMargin` to ` `ofsCheckBox` only if conditions for check image display are met
- note that `fImagesMargin` is applied for `ofsStateImage` and `ofsImage` within the respective calls of `GetImageSize` as needed
Problem
Method
TBaseVirtualTree.GetOffsets
(introduced in #369) incorrectly appliesFImagesMargin
forTVTElement.ofsCheckBox
when no check image is needed. Thus, its out-parampOffsets
then contains values two pixels too high forTVTElement.ofsCheckBox
and all following elements.Observations
This can, for example, cause a wrong result of
TBaseVirtualTree.GetMaxColumnWidth
, making autosized columns wider than necessary.It might also be causing #811, I guess.
Reproduction
It's nicely reproducible by extending Minimal demo project:
FImagesMargin
using thewith Self do
class helper hack:TSpinEdit
control toTMainForm.dfm
and set itsValue
to2
as it is the hard coded value ofFImagesMargin
:OnChangeEvent
to apply its value toFImagesMargin
:FImagesMargin
and unexpectibly see the nodes' labels move to the right when increasing it or to the left when decreasing it:FImagesMargin
shouldn't change the display at all.The text was updated successfully, but these errors were encountered: