TabBarGadget - Tabs like in a browser

Share your advanced PureBasic knowledge/code with the community.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: TabBarGadget - Tabs like in a browser

Post by Dude »

D'oh! :( I won't bother using it for this current project, then. Too many gadgets involved to be re-coded. Thanks for clarifying, anyway.
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 »

GenRabbit wrote:This is awesome. Any chance of getting a Module version of it?
This is a good idea, I think I will implement that.
Niffo wrote:You can resize the gadget then call UpdateTabBarGadget()
Right. I saw, that we have a new constant (#PB_EventType_Resize), I will try it to implement this, that you haven't call UpdateTabBarGadget().
Dude wrote:Do you mean I have to put a ContainerGadget inside each TabBarGadget tab, with all gadgets inside those containers?
The TabBarGadget is no direct replacement for the PanelGadget. The TabBarGadget tabs have no own conainer.
Typically, when you use a TabBarGadget you have only one container for all tabs and you just change the content (like in an editor or a browser)
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 »

Hi,

Is this a bug? I cannot move tab 0 to position 1. It seems to expect a 1-based position, but the documentation says it starts at 0. Am I missing something?

Code: Select all

XIncludeFile "TabBarGadget.pbi"

Enumeration
  #Window
  #TabGadget
  #MoveButton
EndEnumeration

OpenWindow(#Window, 0, 0, 320, 240, "TabBarGadget", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)

TabBarGadget(#TabGadget, 0, 0, WindowWidth(#Window), 32, #TabBarGadget_None, #Window)
AddTabBarGadgetItem(#TabGadget, #PB_Default, "One")
AddTabBarGadgetItem(#TabGadget, #PB_Default, "Two")
AddTabBarGadgetItem(#TabGadget, #PB_Default, "Three")

ButtonGadget(#MoveButton, 10, 45, 90, 25, "Move")

Repeat
  
  Select WaitWindowEvent()
      
    Case #PB_Event_CloseWindow
      End

    Case #PB_Event_Gadget
      If EventGadget() = #MoveButton
        SetTabBarGadgetItemPosition(#TabGadget, 0, 1)
      EndIf
      
  EndSelect
  
ForEver
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 »

Thanks for the bug report.
You are right, it is a bug in the procedure.
Please replace this procedure in the include and check whether is works.

Code: Select all

Procedure SetTabBarGadgetItemPosition(Gadget.i, Tab.i, Position.i)
	
	Protected *TabBarGadget.TabBarGadget = GetGadgetData(Gadget)
	Protected *NewItem.TabBarGadgetItem = TabBarGadget_ItemID(*TabBarGadget, Position)
	Protected *Item.TabBarGadgetItem = TabBarGadget_ItemID(*TabBarGadget, Tab)
	
	If *Item And *Item <> *TabBarGadget\NewTabItem
		If *NewItem And *NewItem <> *TabBarGadget\NewTabItem
			If Position > Tab
				MoveElement(*TabBarGadget\Item(), #PB_List_After, *NewItem)
			Else
				MoveElement(*TabBarGadget\Item(), #PB_List_Before, *NewItem)
			EndIf
		Else
			MoveElement(*TabBarGadget\Item(), #PB_List_Last)
		EndIf
		TabBarGadget_PostUpdate(*TabBarGadget)
	EndIf
	
EndProcedure
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 »

That seems to fix it.

Thanks for the fast response and fix!
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: TabBarGadget - Tabs like in a browser

Post by Dude »

wombats wrote:That seems to fix it.
Are the download links in the first post fixed?
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 »

I have replaced the Include in the Link (only for the Version 1.5)
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
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: TabBarGadget - Tabs like in a browser

Post by infratec »

Hi STARGÅTE,

a feature request:

Allow rectangle images, not only square ones.

We 'abuse' the entry to show an additional status icon.
(a circle with a number inside)
Now we have to show 2 status values. Instead of 16 by 16 it would be nice if we can use 32 by 16.

I also looked in the source code. Adding/changing ImageSize to ImageWidth and ImageHeight is not a big deal,
but I don't know where I have to make the changes to size the tab accordingly.

Tal'ma'te
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: TabBarGadget - Tabs like in a browser

Post by infratec »

Ok,

for our personal use I changed NewImageID to NewImage. (TabBarGadget_ReplaceImage())
So it is possible to get the size via ImageWidth() and ImageHeight().

Code: Select all

*Item\Image = CreateImage(#PB_Any, ImageWidth(NewImage), ImageHeight(NewImage), 32, #PB_Image_Transparent)
And in TabBarGadget_RotateImage():

Code: Select all

*Item\DrawedImage = CreateImage(#PB_Any, ImageHeight(*Item\Image), ImageWidth(*Item\Image), 32, #PB_Image_Transparent)
Ok, it is a bit difficult since man applications are already using the TabBarGadget.
But maybe in V2.0 :wink:
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 »

I am very interested in a screenshot of your application with my TabBarGadget and your status icon, can you show me?

To your feature request:
Fun fact: the constant #TabBarGadget_ImageSize is already declared but never used ^^
I can implement this attribute as follows?:
  • By default the image is scaled to the value set in TabBarGadgetInclude\ImageSize, as it is already implemented.
  • You can set the image size with SetTabBarGadgetAttribute(Gadget, #TabBarGadget_ImageSize, Size)
  • With Size = #PB_Default, the TabBarGadget uses the original size of each image.
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
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: TabBarGadget - Tabs like in a browser

Post by infratec »

Hi,

we use it as a part of our CTI solution.
In this case we use it to show the state of the scheduled calls.
Red for calls where the time is exited and blue for calls which should be done in the next 2 hours.

Image

Image

Also for our english speakers :wink:

Image
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: TabBarGadget - Tabs like in a browser

Post by StarBootics »

Hello Stargate,

I have some "Invalid Memory Access" on all DrawingFont(\FontID) lines (Line 1613, Line 1937 , Line 2189 and Line 2268). I'm under Ubuntu 19.10 x64 and I'm using PB 5.71 LTS.
If I comment these lines everything work except the text is draw using the default font.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
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 »

This \FontID comes from this code part (Line 2581-2588):

Code: Select all

		CompilerSelect #PB_Compiler_OS
			CompilerCase #PB_OS_Windows
				\FontID                  = GetGadgetFont(#PB_Default)
			CompilerDefault
				DummyGadget = TextGadget(#PB_Any, 0, 0, 10, 10, "Dummy")
				\FontID                  = GetGadgetFont(DummyGadget)
				FreeGadget(DummyGadget)
		CompilerEndSelect
On non-Windows system, I create a dummy gadget to get the standard gadget font of the system.
My idea is that this part does not work on your system.
You can modify the code and use your one font like this:

Code: Select all

\FontID                  = FontID(LoadFont(#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
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 »

Hi STARGATE, I am wondering:

1. Do you have any TabBarGadget changes since v1.5 beta 2?

2. Do you use GitHub?

3. Would you be interested in hosting the TabBarGadget on GitHub?


Over the years, I have made changes to the TabBarGadget which have never been shared, but I would be happy to share.

And with the PB IDE going open-source, it looks very likely there will be edits to the TabBarGadget, and it would be nice to track and maintain bugfixes and new features in a public place like GitHub.


Thanks for all your hard work, by the way!
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 »

kenmo wrote: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.
kenmo wrote:2. Do you use GitHub?
No.
kenmo wrote:3. Would you be interested in hosting the TabBarGadget on GitHub?
What do I have to do if i "host" the TabBarGadget code 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
Post Reply