Alexey-T / ATFlatControls

Controls for Delphi/Lazarus, used in CudaText: ATTabs, ATButton, ATListbox, ATScrollbar, ATStatusbar, ATGroups, ATGauge
Other
101 stars 29 forks source link

IsTabVisible/MakeTabVisible issue #71

Closed petko closed 2 months ago

petko commented 3 years ago

It seems that there is some bug in IsTabVisible and MakeTabVisible methods.

I have a tab control with many tabs. When the app starts, I for example set the last tab active. It is selected properly, but it is not visible (i.e. the tabs control is not scrolled). So I try to use the following code to make it visible:

if(!ATTabs1->IsTabVisible(tabs_->TabIndex))
{
  ATTabs1->MakeVisible(tabs_->TabIndex);
}

In my app this call to IsTabVisible returns true even though the tab is not currently visible.

I've also created a demo where there is nothing else except a tab control and many tabs. There the IsTabVisible correctly detects that the active tab is not visible, however MakeVisible does nothing..

In both cases I have only the following options set:

    OptTabWidthMinimal = 80
    OptShowXButtons = atbxShowNone
    OptScalePercents = 200;
Alexey-T commented 3 years ago

That prop needs that tab-control is repainted first. so can you make a demo in Delphi- which shows many tabs, then you press a button and it calls MakeVisible for last tab?

petko commented 3 years ago

Yes, calling it via button works. However I can't do it programatically even after calling Refresh, Repaint or Invalidate.

What are my options here?

Alexey-T commented 3 years ago

tabs.Invalidate; Application.ProcessMessages;

then try it again?

petko commented 3 years ago

It kinda works that way. The correct tab is set, but there is always a flash of content, which is not optimal. The tabs are first painted without being scrolled and then they are scrolled to the correct place.

Alexey-T commented 3 years ago

Then please try Repaint or Paint, without App.ProcessMessages, after setting the correct sizes of control.

petko commented 3 years ago

Using Repaint without ProcessMessages is better. There is still a quick flash, but I guess there is no way to pre-scroll to the tab before painting the control currently..

Alexey-T commented 3 years ago

I guess we can pre render it, even with Visible off state Paint method must work (not tested)

petko commented 9 months ago

I can confirm the problem and the fix. I am not sure in which combinations of settings it does occur, but here are screenshot from my app if Size is used instead of Height:

On the High DPI monitor: high-dpi-bug

When moved to the low-DPI monitor (notice the missing closing bracket): low-dpi-bug

When the Height fix is applied it shows on both monitors as on the high-dpi above.

Alexey-T commented 9 months ago

Was it message for #75 ?

Alexey-T commented 2 months ago

I am puzzled today, how to see the issue, is it fixed or not yet? can you give very small example to show the problem? better in Pascal.

petko commented 2 months ago

Yes, these messages were for #75.

Alexey-T commented 2 months ago

75 was solved. So seems this is also solved? Will close then.