[Module] Extended ToolBar-Gadget (all OS / DPI)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
Mesa
Enthusiast
Enthusiast
Posts: 345
Joined: Fri Feb 24, 2012 10:19 am

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by Mesa »

The icon "help" is not visible but it reappears when i comment this line
; ToolBar::TrackBar(#ToolBar, 100, 34, 0, 10, #TrackBar, "trackID", #PB_TrackBar_Ticks)


May i say, if you have the idea to use the tabgadget from STARGÅTE here
http://www.purebasic.fr/english/viewtop ... 12&t=47588
with you toolbar gadget, you should create a ribbongadget like that
https://docs.microsoft.com/en-us/window ... md-ribbons
:wink:

M.
User avatar
HeX0R
Addict
Addict
Posts: 980
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by HeX0R »

Mesa wrote:The icon "help" is not visible but it reappears when i comment this line
; ToolBar::TrackBar(#ToolBar, 100, 34, 0, 10, #TrackBar, "trackID", #PB_TrackBar_Ticks)
The help icon gets overwritten by the trackbar, change line 405 from

Code: Select all

Case #SpinGadget
into

Code: Select all

Case #SpinGadget, #TrackBar
And give the example window a little more width (640, instead of 600, line 1972)
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by Thorsten1867 »

Bugfixes
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
tatanas
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by tatanas »

Sorry it's me again :?

A small change should me made concerning the buttons :
When you push down a button, behaviour is ok (background changes color and image shift a little) but when you release the button (_LeftButtonUpHandler()) it doesn't revert back the look of the button.
Windows 10 Pro x64
PureBasic 6.04 x64
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by Thorsten1867 »

Bugfix
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
tatanas
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by tatanas »

Thank you.

I found a weird one :
The imagebutton tooltip follow the cursor when a spacer is inserted before the imagebutton. All following ImageButton tooltip get the bug.


You can test it in your example by replacing the "Cut" button by a spacer

Code: Select all

ToolBar::Spacer(#ToolBar)
;ToolBar::ImageButton(#ToolBar, #IMG_Cut,   #TB_Cut,   "Cut",   "cutID")

Question : Is it possible to disable the entire toolbar and all the gadgets inside (to grey all of them) ?
Windows 10 Pro x64
PureBasic 6.04 x64
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by Thorsten1867 »

Try it again!
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
tatanas
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by tatanas »

Sorry, i've got the same problem. And I suspect it generates a event triggering problem with the ImageButton too with 2 spacers.

In your example (with or without ToolBar::SetPostEvent(#ToolBar, #PB_Event_Menu)) :

Code: Select all

    ;ToolBar::ImageButton(#ToolBar, #IMG_New,   #TB_New,   "New",   "newID") 
    ToolBar::TextButton(#ToolBar, "New", #TB_New, "newID") 
    ToolBar::ImageButton(#ToolBar, #IMG_Save,  #TB_Save,  "Save",  "saveID")
;     ToolBar::Separator(#ToolBar)
ToolBar::Spacer(#ToolBar)
    ToolBar::ImageButton(#ToolBar, #IMG_Copy,  #TB_Copy,  "Copy",  "copyID")
;     ToolBar::ImageButton(#ToolBar, #IMG_Cut,   #TB_Cut,   "Cut",   "cutID")
ToolBar::Spacer(#ToolBar)
    ToolBar::ImageButton(#ToolBar, #IMG_Paste, #TB_Paste, "Paste", "pasteID")
Windows 10 Pro x64
PureBasic 6.04 x64
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by Thorsten1867 »

Can't understand the problem. Both examples seem to work for me.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
tatanas
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by tatanas »

Weird...
I'm using PB 5.73 64bits on win10.

I can see in _MouseMoveHandler() that the ImageButtons before the spacer are drawn only once when the mouse is hovering them (and stand on it).
But the ImageButtons after the spacer are redrawn continuously. It is passing in the "Default" case at each iteration.

EDIT : I added a "Case #Spacer" in _MouseMoveHandler() and it seems to work correctly now.
Windows 10 Pro x64
PureBasic 6.04 x64
tatanas
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by tatanas »

Concerning the button event not triggered, it seems the ImageButton next to the spacer got a wrong "Type".
I can see it in _LeftButtonDownHandler() because it got the #spacer value "6" instead of "1" (#imagebutton).
Could it be a problem with the "If X > TBEx()\Items()\X And X < TBEx()\Items()\X + TBEx()\Items()\Width" and "If Y > ..." test ? The position of the ImageButtons seems wrong because of the spacers (even if they are well displayed).
Windows 10 Pro x64
PureBasic 6.04 x64
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by Thorsten1867 »

Update:
  • Bugfixes
  • DPI-Handling
  • MouseEvents reworked
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
tatanas
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by tatanas »

Sorry. Same test as before, bug's still present (modified example below) :

Code: Select all

   ToolBar::TextButton(#ToolBar, "New", #TB_New, "newID") 
    ToolBar::ImageButton(#ToolBar, #IMG_Save,  #TB_Save,  "Save",  "saveID")
ToolBar::Spacer(#ToolBar)
;     ToolBar::Separator(#ToolBar)
    ToolBar::ImageButton(#ToolBar, #IMG_Copy,  #TB_Copy,  "Copy",  "copyID")
ToolBar::Spacer(#ToolBar)
;     ToolBar::ImageButton(#ToolBar, #IMG_Cut,   #TB_Cut,   "Cut",   "cutID")
    ToolBar::ImageButton(#ToolBar, #IMG_Paste, #TB_Paste, "Paste", "pasteID")
    ToolBar::Separator(#ToolBar)
    CompilerIf ToolBar::#EnableToolBarGadgets
The Paste Button is only triggered when the mouse Y is between 40 and 43.

The tooltip is following the mouse on every ImageButton (on your unmodified example).


EDIT : I think I got it. The position of the spacer is overlapping the position of the button, so it break the loop inside _LeftButtonDownHandler() before processing the button. (in black, the draws of the spacers)
Image

EDIT 2 : Adding

Code: Select all

If TBEx()\Items()\Type = #Spacer : Continue  : EndIf
inside _LeftButtonUpHandler() and _LeftButtonDownHandler() seems to fix the problem
Windows 10 Pro x64
PureBasic 6.04 x64
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by Thorsten1867 »

The problem with overlapping should now be solved. Does this also solve your problem?
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
tatanas
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Nov 06, 2019 10:28 am
Location: France

Re: [Module] Extended ToolBar-Gadget (all OS / DPI)

Post by tatanas »

It seems Ok.
Thank you very much !


I added a DisableToolBar() procedure too :

Code: Select all

  	Procedure   DisableToolBar(GNum.i, State.i)	
		If FindMapElement(TBEx(), Str(GNum))
			ForEach TBEx()\Items()
				If State
					TBEx()\Items()\Flags | #Disable
				Else
					TBEx()\Items()\Flags & ~#Disable
				EndIf
			Next
			If TBEx()\ReDraw : Draw_() : EndIf	
		EndIf
	EndProcedure
Windows 10 Pro x64
PureBasic 6.04 x64
Post Reply