Recent

Author Topic: [SOLVED] ATTabs howto, OptShowXButtons := atbxShowActive, but not on last tab  (Read 2298 times)

d7_2_laz

  • Hero Member
  • *****
  • Posts: 511
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.

« Last Edit: March 05, 2021, 04:14:50 pm by d7_2_laz »
Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #1 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.

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #2 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.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 511
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #3 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.
Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #4 on: March 04, 2021, 09:16:31 pm »
Yes, pls add  the testcase here. Compilable demo.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 511
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #5 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.
Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #6 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.

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #7 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?

d7_2_laz

  • Hero Member
  • *****
  • Posts: 511
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #8 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

Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #9 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.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 511
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #10 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.
Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #11 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.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 511
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #12 on: March 05, 2021, 12:37:00 pm »
Oh, see that with the today's github version ..... ok, thank you!   :D
Lazarus 3.2  FPC 3.2.2 Win10 64bit

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #13 on: March 05, 2021, 12:46:33 pm »
Consider (feel free) to report any further issues, too.

d7_2_laz

  • Hero Member
  • *****
  • Posts: 511
[SOLVED) ATTabs howto, OptShowXButtons := atbxShowActive, but not on ....
« Reply #14 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
Lazarus 3.2  FPC 3.2.2 Win10 64bit

 

TinyPortal © 2005-2018