TabBarGadget - Tabs like in a browser

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

Re: TabBarGadget - Tabs like in a browser

Post by kenmo »

No. Only Freak did some changes for the DPI compatibility during his implementation into the PB IDE.
Oh interesting. I will compare and see what they changed for the IDE.
What do I have to do if i "host" the TabBarGadget code on GitHub?
If the TabBarGadget file never changes, then there's not much benefit. It's just a place to host open source code, documentation, demos. Free account, simple to use. I have hosted PB includefiles there for a while.

But it's best for collaboration, people can write bugfixes and new features, submit them, you and others can review them, merge the changes into the latest "master" version. The PB IDE project is starting to get some contributions.

Maybe it's worth discussing later, if some TabBarGadget changes are made in the IDE project. :)
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: TabBarGadget - Tabs like in a browser

Post by kenmo »

It looks like the IDE is using your "1.5 Beta 2" (2014) but your latest "1.5 Beta 2a" (2019) has some bugfixes.

The IDE should probably use your latest version (I will handle that).
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: TabBarGadget - Tabs like in a browser

Post by kenmo »

1. Do you have any TabBarGadget changes since v1.5 beta 2?
No. Only Freak did some changes for the DPI compatibility during his implementation into the PB IDE.
You know, I have compared the TabBarGadget files in the open source IDE and your releases, and I don't see any DPI changes by the PB team. :?:


Any plans to make version "1.5 Beta 2a" an official release? It looks like you improved the layout functions.


Also, back to GitHub, would you be OK with me hosting a copy of the "1.5 Beta 2a" PBI on GitHub with cosmetic changes? So that it matches the rules of the IDE project:

- convert file from ASCII to UTF-8 with BOM
- remove IDE settings appended to bottom
- reformat via the IDE's "Format indentation" function
- remove trailing whitespace on code lines

All code and comments would remain as you wrote them, all credit to you.
fryquez
Enthusiast
Enthusiast
Posts: 362
Joined: Mon Dec 21, 2015 8:12 pm

Re: TabBarGadget - Tabs like in a browser

Post by fryquez »

kenmo wrote:You know, I have compared the TabBarGadget files in the open source IDE and your releases, and I don't see any DPI changes by the PB team. :?:
There aren't any, else you would see some DesktopScaledX/Y() and DesktopUnScaledX/Y() lines, like:

Code: Select all

\PaddingX                     = DesktopScaledX(6)  ; Space from tab border to text
\PaddingY                     = DesktopScaledX(5)  ; Space from tab border to text
\Margin                       = DesktopScaledX(4)  ; Space from tab to border
\ImageSpace                   = DesktopScaledX(3)  ; Space from image zu text
\ImageSize                    = DesktopScaledX(16)
\CloseButtonSize              = DesktopScaledX(13) ; Size of the close cross
\CheckBoxSize                 = DesktopScaledX(10)
\ArrowSize                    = DesktopScaledX(5)  ; Size of the Arrow in the button in navigation
\ArrowWidth                   = DesktopScaledX(12) ; Width of the Arrow-Button in navigation
\ArrowHeight                  = DesktopScaledX(18) ; Height of the Arrow-Button in navigation
\Radius                       = DesktopScaledX(3)  ; Radius of the edge of the tab

...

ResizeGadget(\Number, #PB_Ignore, #PB_Ignore, #PB_Ignore, DesktopUnscaledY(Rows*\TabSize+TabBarGadgetInclude\Margin))
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

Any plans to make version "1.5 Beta 2a" an official release? It looks like you improved the layout functions.

Also, back to GitHub, would you be OK with me hosting a copy of the "1.5 Beta 2a" PBI on GitHub with cosmetic changes?
My plan was to convert the last version (1.5 Beta 2a) to a PB Module and than call it version 1.6, but I never come to this work.
Now, because of the open source project of the IDE, it is more important to help the community with a module version of the TabBarGadget. If you give me roughly one week I try to do this step.

In any case, yes, I agree if you host the last version (perhaps the module version) on GitHub.
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
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: TabBarGadget - Tabs like in a browser

Post by kenmo »

Great! Thanks again for it, it's one of the best PB includes of all time. :mrgreen:

Before the Module version, which would be a large code change, would you release a "final" version 1.5? For existing projects which use it as an IncludeFile?
cyril
User
User
Posts: 15
Joined: Sun Feb 23, 2020 4:28 pm

Re: TabBarGadget - Tabs like in a browser

Post by cyril »

Hi

I think i found a bug with the function GetTabBarGadgetItemColor. I doesn't get the same color as set by SetTabBarGadgetItemColor.
The color I get is something like black instead of the color of the tab.

Or am i using it wrong ? I'am still a new user to purebasic ;)

Here is the code I'm using:

Code: Select all

  Define color = GetTabBarGadgetItemColor(#Gadget_TabBar, GetTabBarGadgetState(#Gadget_TabBar), #PB_Gadget_BackColor)
  color = ColorRequester(color)
  If color > -1
    SetTabBarGadgetItemColor(#Gadget_TabBar, GetTabBarGadgetState(#Gadget_TabBar), #PB_Gadget_BackColor, color)
  EndIf
Last edited by cyril on Sun Feb 23, 2020 4:46 pm, edited 2 times in total.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

Welcome to the PB board.
Without the full code I can not test it.
But from your code snippet it looks like, if not item is selected, GetTabBarGadgetState(#Gadget_TabBar) returns #TabBarGadgetItem_None and with no valid position GetTabBarGadgetItemColor returns 0 -> black.
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
cyril
User
User
Posts: 15
Joined: Sun Feb 23, 2020 4:28 pm

Re: TabBarGadget - Tabs like in a browser

Post by cyril »

Thanks

The library code that is called is:

Code: Select all

; Ändert die Farbe der angegebenen Registerkarte.
Procedure SetTabBarGadgetItemColor(Gadget.i, Tab.i, Type.i, Color.i) ; Code OK, Hilfe OK
	
	Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab)
	
	If *Item
		Select Type
			Case #PB_Gadget_FrontColor
				If Color = #PB_Default
					Color = TabBarGadgetInclude\TextColor
				EndIf
				*Item\Color\Text = Color | $FF<<24
			Case #PB_Gadget_BackColor
				If Color = #PB_Default
					Color = TabBarGadgetInclude\FaceColor
				EndIf
				*Item\Color\Background = Color | $FF<<24
		EndSelect
		TabBarGadget_PostUpdate(GetGadgetData(Gadget))
	EndIf
	
EndProcedure



; Gibt die Farbe der angegebenen Registerkarte zurück.
Procedure.i GetTabBarGadgetItemColor(Gadget.i, Tab.i, Type.i) ; Code OK, Hilfe OK
	
	Protected *Item.TabBarGadgetItem = TabBarGadgetItemID(Gadget, Tab)
	
	If *Item
		Select Type
			Case #PB_Gadget_FrontColor
				ProcedureReturn *Item\Color\Text
			Case #PB_Gadget_BackColor
				ProcedureReturn *Item\Color\Background
		EndSelect
	EndIf
	
EndProcedure
I can see | $FF<<24 as a difference between the getter and the setter. Must be the problem. How do I do the reverse operation ?

I added a saveguard to my code, just in case ;) Thanks STARGÅTE !
The problem however doesn't come from this but from the value of the getter.
Last edited by cyril on Sun Feb 23, 2020 4:54 pm, edited 1 time in total.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

You are right.
The internal color format is 32bit (with alpha channel). Therefore "| $FF<<24" is important.
And since Set only requires a 24 bit color, Get should only return 24 bit.
You can change the lines:

Code: Select all

			Case #PB_Gadget_FrontColor
				ProcedureReturn *Item\Color\Text
			Case #PB_Gadget_BackColor
				ProcedureReturn *Item\Color\Background
into

Code: Select all

			Case #PB_Gadget_FrontColor
				ProcedureReturn *Item\Color\Text & $FFFFFF
			Case #PB_Gadget_BackColor
				ProcedureReturn *Item\Color\Background & $FFFFFF
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
cyril
User
User
Posts: 15
Joined: Sun Feb 23, 2020 4:28 pm

Re: TabBarGadget - Tabs like in a browser

Post by cyril »

With your suggestion it's working great now !

Thanks :)
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: TabBarGadget - Tabs like in a browser

Post by kenmo »

STARGÅTE wrote:You are right.
The internal color format is 32bit (with alpha channel). Therefore "| $FF<<24" is important.
And since Set only requires a 24 bit color, Get should only return 24 bit.
You can change the lines:
A change for v1.5 Final ? :wink:

PS. Last month I put the TabBarGadget on GitHub here
https://github.com/kenmo-pb/TabBarGadget
You can see the list of small changes I made, to make it compatible with the IDE project.
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: TabBarGadget - Tabs like in a browser

Post by wombats »

I'm experiencing a couple of problems with the TabBarGadget.

I use it in one part of my project inside a ContainerGadget. It's on a tab, so when the tab is closed, I unbind all of the TabBarGadget's events and free it. However, often, when the tab is reopened, I get a Pointer is null error on the last If StartDrawing(CanvasOutput(*TabBarGadget\Number)) line of TabBarGadget_Callback(). Could events for the freed TabBarGadget still be in the event queue?

Secondly - and this only seems to happen on Windows - sometimes the TabBarGadget seems to receive events the #TabBarGadge_EventType_Change event when a ButtonGadget is clicked. So when I click a ButtonGadget, the event for it happens, but the TabBarGadget changes its state so that no tab is selected. I have been wondering if it's because when I use BindGadgetEvent with a ButtonGadget, there are no specific events to bind it to, so what does PB actually bind the event to? This doesn't happen all the time - it happens once and then goes away when I recompile.
User avatar
STARGÅTE
Addict
Addict
Posts: 2067
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: TabBarGadget - Tabs like in a browser

Post by STARGÅTE »

Dear wombats,

thanks for using my TabBarGadget include.
To your first questions:
wombats wrote:However, often, when the tab is reopened, I get a Pointer is null error on the last If StartDrawing(CanvasOutput(*TabBarGadget\Number)) line of TabBarGadget_Callback(). Could events for the freed TabBarGadget still be in the event queue?
So you receive no error during the free of the gadget and also some time after it? The error occurs during the creation?
I'm not exactly sure, how the BindEvents will handled, if you free a Gadget, but to my knowledge, all bind events should be also erased.
I think it is the same problem posted here:
https://www.purebasic.fr/english/viewto ... 43#p437543

Can you try to change the procedure FreeTabBarGadget() with this code:
(I added an unbind and free the gadget before releasing the memory)

Code: Select all

Procedure FreeTabBarGadget(Gadget.i) ; Code OK, Hilfe OK
	
	Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget)
	
	UnbindGadgetEvent(*TabBarGadget\Number, @TabBarGadget_Callback())
	FreeGadget(Gadget)
	ForEach *TabBarGadget\Item()
		TabBarGadget_ClearItem(*TabBarGadget, *TabBarGadget\Item())
	Next
	ClearStructure(*TabBarGadget, TabBarGadget)
	FreeMemory(*TabBarGadget)
	
EndProcedure
____________________________

To your second question:
Do you use fixed numbers for your gadgets or all gadget are created with #PB_Any?
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
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: TabBarGadget - Tabs like in a browser

Post by wombats »

STARGÅTE wrote:Dear wombats,

thanks for using my TabBarGadget include.
Of course! Thank you for making it. Aside from the problems I have, it's incredible.
STARGÅTE wrote:To your first questions:
wombats wrote:However, often, when the tab is reopened, I get a Pointer is null error on the last If StartDrawing(CanvasOutput(*TabBarGadget\Number)) line of TabBarGadget_Callback(). Could events for the freed TabBarGadget still be in the event queue?
So you receive no error during the free of the gadget and also some time after it? The error occurs during the creation?
I'm not exactly sure, how the BindEvents will handled, if you free a Gadget, but to my knowledge, all bind events should be also erased.
I think it is the same problem posted here:
https://www.purebasic.fr/english/viewto ... 43#p437543

Can you try to change the procedure FreeTabBarGadget() with this code:
(I added an unbind and free the gadget before releasing the memory)

Code: Select all

Procedure FreeTabBarGadget(Gadget.i) ; Code OK, Hilfe OK
	
	Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget)
	
	UnbindGadgetEvent(*TabBarGadget\Number, @TabBarGadget_Callback())
	FreeGadget(Gadget)
	ForEach *TabBarGadget\Item()
		TabBarGadget_ClearItem(*TabBarGadget, *TabBarGadget\Item())
	Next
	ClearStructure(*TabBarGadget, TabBarGadget)
	FreeMemory(*TabBarGadget)
	
EndProcedure
I changed it to that and the problem went away. However, now I'm experiencing a complete freeze (with no report from PB's debugger) after reopening the tab after a few times, which seems to vary. I will have to check my code thoroughly to see if I'm doing something wrong. The Purifier doesn't tell me anything, but I don't know how that thing works anyway. It never tells me anything.
STARGÅTE wrote:To your second question:
Do you use fixed numbers for your gadgets or all gadget are created with #PB_Any?
They are all created with #PB_Any. It's a very strange problem that only occurs sometimes and only on Windows.
Post Reply