confirm, its a update problem in this example (not from the include), will be fixed.davido wrote:I did, however, notice a small problem with the editor: When entering text the cursor repositions to the beginning after each keypress. It is not so bad with new entry as it can simply be entered backwards!
TabBarGadget - Tabs like in a browser
Re: TabBarGadget - Tabs like in 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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: TabBarGadget - Tabs like in a browser
After a long break, it is time for a new update...
Thanks a lot, getting even better!
-
- Enthusiast
- Posts: 271
- Joined: Thu Dec 17, 2009 12:00 pm
- Location: Llangadog, Wales, UK
- Contact:
Re: TabBarGadget - Tabs like in a browser
I totally agree with netmaestro -- Stargåte you are a hero!netmaestro wrote:Thanks for this! It's a lot of work and a very useful control indeed. Your sharing it with the community is much appreciated
I have just updated a large project from TabBarGadget 1.3 to 1.5 beta 1. No problems so far - all working fine. I will post here if I find any issues. Tested on Windows XP SP3 and Win 7 64-bit, using PB 5.20 x86 and x64.
I'm using the gadget in quite a standard way, so not trying all features. However, the project makes active use of it and there are many procedure calls. Changing from version 1.3 to 1.5b1 was easy and only took about 5 minutes. Most of the syntax differences were handled by Find & Replace in the PB IDE (I can post some details if anyone is interested).
One small documentation issue in the Help file:-
For TabBarGadget() the [] optional brackets need to be removed
Ergebnis.i = TabBarGadget(#Gadget, X.i, Y.i, Width.i, Height.i [, Attributes.i [, Window.i]])
to
Ergebnis.i = TabBarGadget(#Gadget, X.i, Y.i, Width.i, Height.i, Attributes.i, Window.i)
- netmaestro
- PureBasic Bullfrog
- Posts: 8433
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: TabBarGadget - Tabs like in a browser
If I'm not mistaken didn't the team tap this code for the ide? If so, I don't see many bug reports about it, seems quite solid.
BERESHEIT
Re: TabBarGadget - Tabs like in a browser
Thank you for this! It's brilliant. I am using it in my application.
One thing...it doesn't seem possible to use it inside a ContainerGadget(). Is it?
One thing...it doesn't seem possible to use it inside a ContainerGadget(). Is it?
Re: TabBarGadget - Tabs like in a browser
The tab bar gadget is a normal canvas gadget, so it is possible to insert this gadget in an opened container gadget.
The window number (in case of the current beta version) is also the parent window.
The window number (in case of the current beta version) is also the parent window.
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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Enthusiast
- Posts: 271
- Joined: Thu Dec 17, 2009 12:00 pm
- Location: Llangadog, Wales, UK
- Contact:
Re: TabBarGadget - Tabs like in a browser
@wombats - STARGÅTE is right (naturally!) TabBarGadget is fine inside a ContainerGadget and also inside a ScrollAreaGadget, as used in my main application.
While I'm here, I had a small issue of my own:
When converting my application over to Mac OS (in progress ) the first compilation threw an error in the debug window for the TabBarGadget_Update procedure code - "FontID is NULL". The issue is inside Procedure TabBarGadget as it uses GetGadgetFont(#PB_Default). Fine on Windows but on the Mac returns 0 (see PB Help).
I made a simple workaround, but maybe there is a better way?
In Procedure TabBarGadget I added an extra variable and changed this code:
With that little glitch sorted TabBarGadget works perfectly on the Mac and looks great
(PB 5.21 LTS, TabBarGadget 1.5 beta 1)
While I'm here, I had a small issue of my own:
When converting my application over to Mac OS (in progress ) the first compilation threw an error in the debug window for the TabBarGadget_Update procedure code - "FontID is NULL". The issue is inside Procedure TabBarGadget as it uses GetGadgetFont(#PB_Default). Fine on Windows but on the Mac returns 0 (see PB Help).
I made a simple workaround, but maybe there is a better way?
In Procedure TabBarGadget I added an extra variable and changed this code:
Code: Select all
myFontDefault = TextGadget(#PB_Any,0,0,10,10) ; NEW LINE
With *TabBarGadget
\Attributes = Attributes
\Number = Gadget
\Window = Window
\NewTabItem\Color\Text = TabBarGadgetInclude\TextColor
\NewTabItem\Color\Background = TabBarGadgetInclude\FaceColor
\Radius = TabBarGadgetInclude\Radius
\MinTabLength = TabBarGadgetInclude\MinTabLength
\MaxTabLength = TabBarGadgetInclude\MaxTabLength
\NormalTabLength = TabBarGadgetInclude\NormalTabLength
; \FontID = GetGadgetFont(#PB_Default);TabBarGadgetInclude\FontID OLD LINE
\FontID = GetGadgetFont(myFontDefault) ; AMENDED LINE
\EventTab = #TabBarGadgetItem_None
EndWith
FreeGadget(myFontDefault) ; NEW LINE
(PB 5.21 LTS, TabBarGadget 1.5 beta 1)
Re: TabBarGadget - Tabs like in a browser
@deeproot
As you can see, if had used "TabBarGadgetInclude\FontID" instead of GetGadgetFont(#PB_Default).
But the problem was, if some one used: SetGadgetFont(#PB_Default, Font)
my gadget ignore this setted font. So I have changed it.
Problem now on MacOS ... (bug from PB with GetGadgetFont()?).
The idea with the fake-gadget is oke.
I will include this (but with CompilerIf).
thx for report
As you can see, if had used "TabBarGadgetInclude\FontID" instead of GetGadgetFont(#PB_Default).
But the problem was, if some one used: SetGadgetFont(#PB_Default, Font)
my gadget ignore this setted font. So I have changed it.
Problem now on MacOS ... (bug from PB with GetGadgetFont()?).
The idea with the fake-gadget is oke.
I will include this (but with CompilerIf).
thx for report
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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Enthusiast
- Posts: 271
- Joined: Thu Dec 17, 2009 12:00 pm
- Location: Llangadog, Wales, UK
- Contact:
Re: TabBarGadget - Tabs like in a browser
Thanks STARGÅTE
Yes, understandable issue. 'CompileIf' sounds good to me for a future version.
MacOS is still very new to me and I'm still learning about differences! TabBarGadet was no big problem and I'm very happy that it needed no other changes in my code. Excellent work
Die besten Wünsche an Sie für Weihnachten und das neue Jahr.
Yes, understandable issue. 'CompileIf' sounds good to me for a future version.
MacOS is still very new to me and I'm still learning about differences! TabBarGadet was no big problem and I'm very happy that it needed no other changes in my code. Excellent work
Die besten Wünsche an Sie für Weihnachten und das neue Jahr.
Re: TabBarGadget - Tabs like in a browser
Thank you. My apologies. It certainly does, and very well. I was making a stupid mistake when I tried before.
Re: TabBarGadget - Tabs like in a browser
Hello Stargate, thanks for the new update! I have been using v1.3 with modifications in a big project, but I will download v1.5 and start testing it today. The changes look great.
I actually checked your website last week for an update, before I noticed there was an update here!
EDIT - I got v1.5 working with my project easily, including my own modifications. I like the cleaned up event handling!
One thing I still wish for in your "native" TabBarGadget is right-click events (eg. to trigger popup menus). I made a new constant and added it in TabBarGadget_Examine() like this:
I actually checked your website last week for an update, before I noticed there was an update here!
EDIT - I got v1.5 working with my project easily, including my own modifications. I like the cleaned up event handling!
One thing I still wish for in your "native" TabBarGadget is right-click events (eg. to trigger popup menus). I made a new constant and added it in TabBarGadget_Examine() like this:
Code: Select all
Case #PB_EventType_RightClick
PostEvent(#PB_Event_Gadget, \Window, \Number, #TabBarGadget_EventType_RightClick, \EventTab)
Re: TabBarGadget - Tabs like in a browser
I don't need a copy of all PB-events.
If the CanvasGadget gets an event, you can examine this event with basic PB-functions like this:
With GetTabBarGadgetItemPosition(Gadget, #TabBarGadgetItem_Event) you can get the Position of the event.
The special position of the Popup button, i will added.
If the CanvasGadget gets an event, you can examine this event with basic PB-functions like this:
Code: Select all
Case #MyGadget
If EventType() = #PB_EventType_RightClick
; Code here
EndIf
The special position of the Popup button, i will added.
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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Re: TabBarGadget - Tabs like in a browser
Ah OK. I guess I didn't realize that GetTabBarGadgetItemPosition(Gadget, #TabBarGadgetItem_Event) would return the correct tab with #PB_EventType_RightClick. I thought it was necessary to post a custom event with the hover tab number. Thanks!
Re: TabBarGadget - Tabs like in a browser
Hello again Stargate, I have some more feedback for you!
I have found 2 bugs... one is only on Mac and I don't know how to fix it (can you test it?) and the other is on Windows (I have a workaround, but no consistent demonstration code).
1. The TabBarGadget on Mac seems to have some update/redraw issues. Check out this example (it works as expected on Windows):
On Mac, the TabBarGadget is initially blank until I move the mouse over it, then it appears drawn with two tabs. Also, if I click "Change #0" then "Change #1", the first tab's icon changes, but the second tab's icon doesn't update until I move the mouse over it! (Maybe this has to do with the BindEvent() changes, are some redraws not happening immediately?) I noticed this because I call SetTabBarGadgetItemImage() in various places, and I noticed sometimes I have to trigger mouse events for the TabBar to update.
2. I have had some crashes on Windows when exiting my program. It crashes in TabBarGadget_Callback(). I think what is happening is: due to BindEvent(), the callback function sometimes executes AFTER (maybe DURING?) FreeTabBarGadget(), when the gadget and/or allocated memory is no longer valid. I added some safety checks to the callback (IsGadget, null pointer check, etc.) and it doesn't crash anymore. Sorry I don't have a good crash example to post here
Thank you again for the TabBarGadget, it's one of the best uses of the CanvasGadget I have seen! Is there any plan for an "officia" version 1.5 release?
I have found 2 bugs... one is only on Mac and I don't know how to fix it (can you test it?) and the other is on Windows (I have a workaround, but no consistent demonstration code).
1. The TabBarGadget on Mac seems to have some update/redraw issues. Check out this example (it works as expected on Windows):
Code: Select all
Macro GetGadgetFont(Dummy)
LoadFont(0, "Arial", 12)
EndMacro
IncludeFile "TabBarGadget.pbi"
DisableExplicit
CreateImage(0, 16, 16)
If (StartDrawing(ImageOutput(0)))
Box(0, 0, 16, 16, $00FF00)
StopDrawing()
EndIf
CreateImage(1, 16, 16)
If (StartDrawing(ImageOutput(1)))
Box(0, 0, 16, 16, $0000FF)
StopDrawing()
EndIf
OpenWindow(0, 0, 0, 320, 240, "Canvas Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
tabbargadget(0, 10, 10, WindowWidth(0)-20, 25, 0, 0)
settabbargadgetfont(0, LoadFont(0, "Arial", 12))
addtabbargadgetitem(0, 0, "Item #0", ImageID(0))
addtabbargadgetitem(0, 1, "Item #1", ImageID(0))
ButtonGadget(1, 10, 50, 100, 25, "Change #0")
ButtonGadget(2, 130, 50, 100, 25, "Change #1")
SetActiveGadget(1)
Repeat
Event = WaitWindowEvent()
If (event = #PB_Event_Gadget) And (EventGadget() > 0)
settabbargadgetitemimage(0, EventGadget() - 1, ImageID(1))
EndIf
Until Event = #PB_Event_CloseWindow
FreeTabBarGadget(0)
2. I have had some crashes on Windows when exiting my program. It crashes in TabBarGadget_Callback(). I think what is happening is: due to BindEvent(), the callback function sometimes executes AFTER (maybe DURING?) FreeTabBarGadget(), when the gadget and/or allocated memory is no longer valid. I added some safety checks to the callback (IsGadget, null pointer check, etc.) and it doesn't crash anymore. Sorry I don't have a good crash example to post here
Thank you again for the TabBarGadget, it's one of the best uses of the CanvasGadget I have seen! Is there any plan for an "officia" version 1.5 release?
Re: TabBarGadget - Tabs like in a browser
I have fixed the GetGadgetFont-Bug in TabBarGadget() on Mac system with your code with the dummy TextGadget.
I can't test my code in Mac.
In the current beta, I don't update the TabBarGadget directly.
In this case SetTabBarGadgetItemImage() don't redraw the canvas gadget directly, but I use PostEvent() to send an event, in combination with BindEvent(@TabBarGadget_Callback()), to update/redraw the gadget.
Please test this code on Mac, with this PostEvent/BindEvent combination:
If you click "New Color", the canvas gadget should be get a new color.
I can't test my code in Mac.
In the current beta, I don't update the TabBarGadget directly.
In this case SetTabBarGadgetItemImage() don't redraw the canvas gadget directly, but I use PostEvent() to send an event, in combination with BindEvent(@TabBarGadget_Callback()), to update/redraw the gadget.
Please test this code on Mac, with this PostEvent/BindEvent combination:
If you click "New Color", the canvas gadget should be get a new color.
Code: Select all
Enumeration
#Window
#Gadget
#ButtonGadget
EndEnumeration
OpenWindow(#Window, 0, 0, 800, 600, "WindowTitle", #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
CanvasGadget(#Gadget, 10, 10, 100, 100)
ButtonGadget(#ButtonGadget, 10, 120, 100, 20, "New Color")
Procedure Update()
If StartDrawing(CanvasOutput(#Gadget))
Box(0, 0, 100, 100, Random($FFFFFF))
StopDrawing()
EndIf
EndProcedure
Procedure Callback()
If EventType() = #PB_EventType_FirstCustomValue
Update()
EndIf
EndProcedure
BindGadgetEvent(#Gadget, @Callback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_Gadget
Select EventGadget()
Case #ButtonGadget
PostEvent(#PB_Event_Gadget, #Window, #Gadget, #PB_EventType_FirstCustomValue, -1)
EndSelect
EndSelect
ForEver
You are right. I will add this tests too. And I will add a UnbindGadgetEvent() before I delete the memory and the gadget.2. I have had some crashes on Windows when exiting my program. It crashes in TabBarGadget_Callback(). I think what is happening is: due to BindEvent(), the callback function sometimes executes AFTER (maybe DURING?) FreeTabBarGadget(), when the gadget and/or allocated memory is no longer valid. I added some safety checks to the callback (IsGadget, null pointer check, etc.) and it doesn't crash anymore.
Thank you. Yes I have forget it ^^. maybe if we fixed the mac problems, I can release the final version 1.5Thank you again for the TabBarGadget, it's one of the best uses of the CanvasGadget I have seen! Is there any plan for an "officia" version 1.5 release?
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 more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module