Page 1 of 3

Libs : dashed splitterbar (PB4.20b1)

Posted: Fri Sep 07, 2007 2:05 am
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

Posted: Fri Sep 07, 2007 7:08 am
by milan1612
Cool, gonna try this today. Could be useful for my current project...

Posted: Fri Sep 07, 2007 8:44 am
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.

Posted: Fri Sep 07, 2007 2:42 pm
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! :)

Posted: Fri Sep 07, 2007 3:00 pm
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.

Posted: Fri Sep 07, 2007 8:03 pm
by DoubleDutch
Another thing I've noticed is that "Show window contents while dragging" is disabled after using the library. Any reason why?

Posted: Fri Sep 07, 2007 8:31 pm
by eddy
I found the problem ... #SPI_SETDRAGFULLWINDOWS
I dont remember exactly why I used this.

Its perhaps a bug

Posted: Fri Sep 07, 2007 9:21 pm
by DoubleDutch
Have you updated the lib, i'll give it a test if you want?

Posted: Sun Sep 09, 2007 4:50 pm
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


Posted: Sun Sep 09, 2007 6:32 pm
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.

Posted: Mon Sep 10, 2007 12:23 am
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... :?

Posted: Mon Sep 10, 2007 12:39 am
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?

Posted: Sat Sep 15, 2007 5:07 pm
by eddy
can you post an example

Posted: Sat Sep 15, 2007 5:20 pm
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

Posted: Sun Sep 23, 2007 11:41 am
by DoubleDutch
Is there a threadsafe version available?