Lazarus

Programming => LCL => Topic started by: d7_2_laz on March 04, 2021, 06:52:43 pm

Title: [SOLVED] ATTabs howto, OptShowXButtons := atbxShowActive, but not on last tab
Post by: d7_2_laz on March 04, 2021, 06:52:43 pm
How to achieve the following aims alltogether correctly?
-  show close button, but only on the active tab (OptShowXButtons := atbxShowActive)
-  but not on the last tab opened (don't close last opened tab), ie. with atbxShowNone depending on the TabCount

-  After the tab originally had been created with a provisional caption text; somehow by AddTab(-1, 'something', ...
-  then afterwards the app should be able to redefine the caption with another text ..... Data.TabCaption := 'yy'

Very Roughly condensed somehow like:

Code: Pascal  [Select][+][-]
  1. Data :=  FATtabs.AddTab(-1, 'something', ts, False, clSilver, FTabImageIndex);
  2. FATtabs.OptShowXButtons := atbxShowNone;   // init setting had been atbxShowActive
  3. // and later, triggered from some event:
  4. Data.TabCaption := 'yy';

Should that work?
At me (without code patch) it results in an unexpected rectangle calculation, see picture.

Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 04, 2021, 07:32:21 pm
TATTabData (use TATTabs.GetTabData method to get it) has the property TabHideXButton.
So try to set it.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 04, 2021, 07:36:37 pm
Quote
then afterwards the app should be able to redefine the caption with another text

Demo program does it, it changes tab's caption by changing the TEdit.
d:= mytabs.GetTabData(N),
then it changes d.TabCaption, then calls mytabs.Invalidate.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: d7_2_laz on March 04, 2021, 08:38:29 pm
Data.TabCaption works fine, but not the TextRect within my demo
tabs.OptShowXButtons := atbxShowNone  and  Data.TabHideXButton:=True behave equally in this context. See example.jpg.  Without TabHideXButton: see example_ok.jpg

Code: Pascal  [Select][+][-]
  1.   Data :=  FATtabs.AddTab(-1, 'something', ts, False, clSilver, FTabImageIndex);   // Data: TATTabData;
  2.  
  3.    // Both are behaving equally here::
  4.   //FATtabs.OptShowXButtons := atbxShowNone;
  5.   Data.TabHideXButton := True;
  6.  
  7.   // And later ...:
  8.   S := 'yy ';
  9.   Data.TabCaption := S;
  10.   FATtabs.Invalidate;  // test-only, should be called internally

Again it must be something trivia. ,But it appears to me as if the width for the close button area is subtracted from the textwidth twice when recalculating the space. If needed i add the slightly adapted testcase here.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 04, 2021, 09:16:31 pm
Yes, pls add  the testcase here. Compilable demo.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: d7_2_laz on March 04, 2021, 09:25:47 pm
Attached. 'For Lazarus/Windows.  Pls. note, the lines mentioned are a simplification from the intended flow. - Hopefully it's my own error. But i'm interested to learn how it is intended to work.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 04, 2021, 09:53:59 pm
Good! Fixed a bug-- UpdateTabRects ignored 'space between icon and caption'.
Pls test again, get from Github.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 04, 2021, 10:08:14 pm
Another little bug is black pixels (black pixels matter) on tab corners. You can do
OptTabRounded:= false;

but I cannot solve it with "true".
Maybe your testcase settings matter? any small demo?
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: d7_2_laz on March 04, 2021, 10:18:12 pm
Yes Alextp, that's it!  :D  ;) :D Works exactly as expected at that point for the steps mentioned  (using either tabs.OptShowXButtons or Data.TabHideXButton. Thousand thanks for your superfast solution, that is very impressive!  ;D

Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 04, 2021, 10:32:33 pm
I fixed corner black pixels-- ParentColor is set to false. you need to set more colors in testcase.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: d7_2_laz on March 04, 2021, 10:43:09 pm
About the black corner thing: "you need to set more colors in testcase." .. could you explain this a bit?

I found another little glitch too. That would be part of my second (and hopefully last) howto question here,  maybe tomorrow. I'll try to describe it as best i can.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 05, 2021, 10:46:57 am
Of coz.
before: you don't set ftabs.Color, it's from parent (ParentColor=true).
now: you need to set ftabs.Color, because ParentColor is now false.
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: d7_2_laz on March 05, 2021, 12:37:00 pm
Oh, see that with the today's github version ..... ok, thank you!   :D
Title: Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: AlexTP on March 05, 2021, 12:46:33 pm
Consider (feel free) to report any further issues, too.
Title: [SOLVED) ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
Post by: d7_2_laz on March 05, 2021, 04:04:35 pm
Thank you Alextp, it's very appreciated!
Meanwhile it's hard for me to find more of them  .... it simply works smooth  :) ;D
TinyPortal © 2005-2018