Libs : dashed splitterbar (PB4.20b1)

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Libs : dashed splitterbar (PB4.20b1)

Post by eddy »

It's a beta version because PB & Tailbite are in BETA state. :?

[PB 4.10 - 4.20b1] download : here ( Extract to your PB folder and restart your PB compiler. )

DashedBar feature:
- PB commands ( ADDED )
- skinnable grip button
- snapping border
- swap gadgets
- replace gadget
- hand cursor
- new eventtype ( NOT YET )
- helpfile
- two lib versions : normal mode / threadsafe mode

Image

new constants

Code: Select all

;Bar maxwidth
#DashedBar_ThicknessMax=16

;Flags for CreateGadget 
#DashedBar_Horizontal=0
#DashedBar_Vertical=1  
#DashedBar_FavoriteBorder1=2
#DashedBar_FavoriteBorder2=4

;Flags for SetGadgetState
#DashedBar_Snap1=-101
#DashedBar_Snap2=-102

;Flags for SetGadgetAttribute / GetGadgetAttribute
#DashedBar_Favorite=100
#DashedBar_MagnetBorder1=101
#DashedBar_MagnetBorder2=102
#DashedBar_Drawer=103
example

Code: Select all

Enumeration
  #win
  #gd1
  #gd2
  #dashed
EndEnumeration

If OpenWindow(#win, 0, 0, 600, 600, "DashedBar Test",#PB_Window_MinimizeGadget) 
  CreateGadgetList(WindowID(#win)) 

  ButtonGadget(#gd1,10,10,30,30,"LEFT")
  ButtonGadget(#gd2,90,90,30,30,"RIGHT")
  DashedBarGadget(#dashed, 5, 5, 590, 590,8,100,#gd1,#gd2,#DashedBar_Vertical | #DashedBar_FavoriteBorder2)  
  SetGadgetAttribute(#dashed,#DashedBar_MagnetBorder1,100)
  SetGadgetAttribute(#dashed,#DashedBar_MagnetBorder2,100)
  SetGadgetState(#dashed,30)
EndIf 

Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_Gadget 
      Debug ""
      Debug "EventType()="+Str(EventType())
      Debug "EventGadget()="+Str(EventGadget())
    Case #PB_Event_CloseWindow 
      Break       
  EndSelect 
ForEver
Last edited by eddy on Tue Jan 08, 2008 1:53 am, edited 9 times in total.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Cool, gonna try this today. Could be useful for my current project...
Windows 7 & PureBasic 4.4
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

Great eddy! Though you mention it's for PB 4.02b, it seems to work well on PB 4.10b3. Thank you very much.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

There is a problem with ResizeGadget():

Code: Select all

Enumeration 
  #win 
  #gd1 
  #gd2 
  #dashed 
EndEnumeration 

If OpenWindow(#win, 0, 0, 600, 600, "DashedBar Test",#PB_Window_MinimizeGadget) 
  CreateGadgetList(WindowID(#win)) 

  ButtonGadget(#gd1,10,10,30,30,"LEFT") 
  ButtonGadget(#gd2,90,90,30,30,"RIGHT") 
  DashedBarGadget(#dashed, 5, 5, 590, 590,8,100,#gd1,#gd2,#DashedBar_Vertical | #DashedBar_FavoriteBorder2)  
  SetGadgetAttribute(#dashed,#DashedBar_MagnetBorder1,100) 
  SetGadgetAttribute(#dashed,#DashedBar_MagnetBorder2,100) 
  SetGadgetState(#dashed,30) 
EndIf 

ResizeGadget(#dashed,10,10,400,400)
SetGadgetState(#dashed,GetGadgetState(#dashed))  ; <--- comment this line to see the problem

Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_Gadget 
      Debug "" 
      Debug "EventType()="+Str(EventType()) 
      Debug "EventGadget()="+Str(EventGadget()) 
    Case #PB_Event_CloseWindow 
      Break        
  EndSelect 
ForEver 
I've found a slight problem with it with a horizonal bar, it doesn't happen on your example - it maybe something to do with containers or the resize thing mentioned above. If I can isolate it I'll get back to you.

Otherwise its great! :)
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

:o Oh... i didn't code the resizeGadget command.
So, my gadget uses the default PB command for resizing.

I'll fix that.
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Another thing I've noticed is that "Show window contents while dragging" is disabled after using the library. Any reason why?
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

I found the problem ... #SPI_SETDRAGFULLWINDOWS
I dont remember exactly why I used this.

Its perhaps a bug
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Have you updated the lib, i'll give it a test if you want?
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

[UPDATED]
- add help file
- bug fixed : drawing window content
- bug fixed : resizegadget
- minor changes

Code: Select all

- GetGadgetState(): Get the current splitter position, in pixels.  
- SetGadgetState(): Set the current splitter position, in pixels. The following constants are valid: 
 
	#DashedBar_SnapBorder1	= -101	:	Snap to border1
	#DashedBar_SnapBorder2	= -102	:	Snap to border2

- SetGadgetAttribute()
- GetGadgetAttribute(): With one of the following attribute: 

	#DashedBar_Favorite		=100	:	Get / Change FavoriteBorder
	#DashedBar_MagnetBorder1	=101	:	Enable snap-to-border for border1, in pixels. ( disabled if zero )	
	#DashedBar_MagnetBorder2	=102	:	Enable snap-to-border for border2, in pixels. ( disabled if zero )
	#DashedBar_Drawer		=103	:	Get / Change the drawing procedure.
	#DashedBar_FirstGadget	=104	:	Get / Change first gadget
	#DashedBar_SecondGadget	=105	:	Get / Change second gadget

Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

I'm using SRod's SetEventHandler to do the resizing of gadgets below other gadgets and things don't quite work right with the Dashed Gadget.

Is the drawing order changed somehow within the gadget? It doesn't behave the same as a splitter gadget.

For normal programs the gadget works fine.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

the drawing order is not changed.

All are contained in the same gadgetlist : ID1, ID2, grip button.
But I don't know how to code gadgetlist system... :?
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

All are contained in the same gadgetlist : ID1, ID2, grip button
I don't know what you mean, do you mean that you start a new CreateGadgetList, or do you mean you put them in a ContainerGadget?

I think that nesting CreateGadgetList's can cause problems, but I'm not certain?
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

can you post an example
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

I'm trying to figure out what is causing the problem. I'll try post some source when I can figure out what its caused by.

-Anthony
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Is there a threadsafe version available?
Post Reply