TabBarGadget - Tabs like in a browser

Share your advanced PureBasic knowledge/code with the community.
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: TabBarGadget - Tabs like in a browser

Post by kenmo »

Stargate, yes your test code works OK for me. But guess what, I found and fixed the Mac problem -- and it only involves swapping two lines of code :shock:

Inside your PostUpdate() function, simply change

Code: Select all

PostEvent(#PB_Event_Gadget, *TabBarGadget\Window, *TabBarGadget\Number, #TabBarGadget_EventType_Updated, -1)
*TabBarGadget\UpdatePosted = #True
to

Code: Select all

*TabBarGadget\UpdatePosted = #True
PostEvent(#PB_Event_Gadget, *TabBarGadget\Window, *TabBarGadget\Number, #TabBarGadget_EventType_Updated, -1)
I think PostEvent() + BindEvent() behave differently on Mac and PC. On Mac, your Callback is called IMMEDIATELY upon PostEvent(). I have verified this by placing Debug statements where UpdatePosted is set #True and where it is set #False, then ran it and checked the order they appear.

So the problem was:
1. I call SetTabBarGadgetItemImage() on the first tab...
2. The ImageID is changed...
3. PostEvent() with #TabBarGadget_EventType_Updated...
4. The Callback() function IMMEDIATELY redraws the TabBar, and sets UpdatePosted #False...
5. THEN UpdatePosted is set to #True...
6. Now I call SetTabBarGadgetItemImage() on the second tab...
7. The ImageID is changed...
8. Since UpdatePosted is set to #True, no event is posted, no callback is executed, the TabBar is not redrawn!!!
9. Moving the mouse over the TabBar causes it to redraw the new icon correctly

To fix it, swap those two lines. Now UpdatePosted is set #True before the Callback runs. I hope this all makes sense! :)
User avatar
deeproot
Enthusiast
Enthusiast
Posts: 284
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by deeproot »

STARGÅTE wrote:Please test this code on Mac, with this PostEvent/BindEvent combination:
Also works OK for me - OSX 10.6.8, Xcode 3.2.6

Interesting report from kenmo. My project does not do the same things, so I didn't see any other problem. Though I only use TabBarGadet 1.5b1 in a simple way, everything I need is working fine on Mac and Windows. Also just starting with Linux and looks good so far.
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: TabBarGadget - Tabs like in a browser

Post by kenmo »

Hi deeproot. I have only tested on two Macs (OSX 10.5 and 10.8 I think) but I saw the same problem on both.

Did you test my 2-tab example, and did you make sure to click both ButtonGadgets without clicking or even hovering over the TabBarGadget in between? For me, I see the first tab change icon; the second icon will not redraw until I interact with it.

Just to clarify, the TabBarGadget looks fine and works fine otherwise. Haven't tried it on Linux!
User avatar
deeproot
Enthusiast
Enthusiast
Posts: 284
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by deeproot »

@kenmo

I just tried your example and yes - I get the same effect you described. Well spotted!

As mentioned, it didn't show up in my project. The initialisation of my main window is quite involved and always calls UpdateTabBarGadget - I think that fixes the first display (pure coincidence!). Then I don't need to replace the tab images (so far).

I agree it's great work by Stargåte - well worth sorting any glitches.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: TabBarGadget - Tabs like in a browser

Post by Fangbeast »

StarGate, there are no example codes in the archive when expanded?
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

Examples are in the help file (in the archive) or in the online help:
http://www.unionbytes.de/help/tabbargad ... piele.html
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: TabBarGadget - Tabs like in a browser

Post by Fangbeast »

STARGÅTE wrote:Examples are in the help file (in the archive) or in the online help:
http://www.unionbytes.de/help/tabbargad ... piele.html
I meant the examples that used to be provided with code and icons?

If it's all in the help, no worries then.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
aaaaaaaargh
User
User
Posts: 55
Joined: Thu Jul 27, 2006 1:24 pm

Re: TabBarGadget - Tabs like in a browser

Post by aaaaaaaargh »

:shock: This is really awesome!

Thanks ever so much for sharing!
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: TabBarGadget - Tabs like in a browser

Post by mestnyi »

STARGÅTE And it is impossible to do so when the tabs do not fit (ie, when the locomotive) two buttons appear before the other one back and not left as Sach one another right?
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

Re: TabBarGadget - Tabs like in a browser

Post by staringfrog »

STARGÅTE,

your lib looks so alluring, really. By the way, does TabBarGadget support bottom (vertically flipped) tabbars? Somehow I can't figure it out in your panzergemachtkaputt of a helpfile :D

P.S. Dankeschon for your quick reply.
Last edited by staringfrog on Sat Jul 05, 2014 11:58 pm, edited 1 time in total.
Coding's men's knitwork.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

Yes.
You can use #TabBarGadget_MirroredTabs (as flag) to flip the Tabs.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

Re: TabBarGadget - Tabs like in a browser

Post by staringfrog »

Dear Stargate,

from what I get from gTranslate and your examples, it's not quite clear how to apply the DefaultHeight constant:
Specify the position (X, Y) and the dimensions (width, height) of the tab bar. # TabBarGadget_DefaultHeight can be used for Height or Width to take advantage of automatic optimal height map.
Can it be reset (and where, as I found only one mention of it in .pbi) or applied to Width as well? Sort of nebulous description, especially in that optimum height part. Is it meant to be font-size dependent or what? Can you elucidate, please?

The other question is how to set specific attributes to a single tab item in a TabBar. Say, I want all tabs but the first one be fitted up with a CloseButton (which might be a regular situation with some common application tasks, I guess). The way I see it from your snippets, you can only combine two instances (two gadgets) of TabBar to achieve this, is it so?

Thank you in advance for your kind replies.
Coding's men's knitwork.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

  1. If you use #TabBarGadget_DefaultHeight (not a real height value), the height of the tab bar will calculated automatically, depending on the font height of the operating system:

    Code: Select all

    XIncludeFile "TabBarGadget.pbi"
    
    OpenWindow(1, 0, 0, 800, 600, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
    TabBarGadget(1, 0, 0, 800, #TabBarGadget_DefaultHeight, #TabBarGadget_CloseButton, 1)
    	AddTabBarGadgetItem(1, -1, "Alpha")
    	AddTabBarGadgetItem(1, -1, "Beta")
    
    SetGadgetFont(#PB_Default, LoadFont(1, "Arial", 20))
    
    TabBarGadget(2, 0, 50, 800, #TabBarGadget_DefaultHeight, #TabBarGadget_CloseButton, 1)
    	AddTabBarGadgetItem(2, -1, "Alpha")
    	AddTabBarGadgetItem(2, -1, "Beta")
    
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  2. Currently there is no way to change attributes of tabs individually.
    But this feature was wished from other members also.
    So I will try to implement this feature, like SetTabBarGadgetItemAttribute().
  3. "Is there any plan for an "officia" version 1.5 release?"
    I have add some new features (vertical tabs, multi-select, checkboxes, autoscroll) in this beta, but I haven't got feedback.
    I also know, that some of you need a good english documentation, so I am working on it.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

Re: TabBarGadget - Tabs like in a browser

Post by staringfrog »

Stargate, I hate to ask you again, and yet, do you ever plan to implement text alignment for tabs (in case of really wide, stretched ones), or do I miss something again (haven't found it in 1.5 b1 either)? Probably, it's not that easy, I realize it, given all those frills and images one can pin to tabs, besides text labels. Nonetheless, do you think it is possible to employ (things like) #PB_Text_Center (say, for tabs w/o images only) in your future versions?
Coding's men's knitwork.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

Tabs have always the width of the text (+ image), so you can't align the text in the tab.
If you have set a minimal tab width, you get an empty space, yes.
For this case you need some like align: left, right, center?
I add it on my to do list, but I can not say when I have time to implement it (sry).

But thank you for using the gadget.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Post Reply