Splitter separator size

Windows specific forum
User avatar
ChrisR
Addict
Addict
Posts: 1150
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Splitter separator size

Post by ChrisR »

Is there a way to enlarge the height (or width if vertical) of the Splitter separator (on Windows) ?
To apply with the DPI scaling factor or other.

Code: Select all

EnableExplicit

Enumeration Window
  #Window_0
EndEnumeration

Enumeration Gadgets
	#Track_1
	#Btn_1
  #Btn_2
  #Splitter
EndEnumeration

Macro Scale(XY) : Round(XY * ScaleXY, #PB_Round_Down) : EndMacro

Declare Resize_Window_0()
Declare Open_Window_0(X = 0, Y = 0, Width = 220, Height = 150)

Global ScaleXY.f = 1.00

Procedure Resize_Window_0()
	ResizeWindow(#Window_0, #PB_Ignore, #PB_Ignore, Scale(220), Scale(150))
	ResizeGadget(#Track_1, Scale(10), Scale(10), Scale(200), Scale(20))
	ResizeGadget(#Splitter, Scale(10), Scale(40), WindowWidth(#Window_0) - Scale(20), WindowHeight(#Window_0) - Scale(50))
EndProcedure

Procedure Open_Window_0(X = 0, Y = 0, Width = 220, Height = 150)
	If OpenWindow(#Window_0, X, Y, Scale(Width), Scale(Height), "Splitter Separator Size!", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TrackBarGadget(#Track_1, Scale(10), Scale(10), Scale(200), Scale(20), 100, 200)
    SetGadgetState(#Track_1, ScaleXY * 100)
		ButtonGadget(#Btn_1, 0, 0, 0, 0, "Button 1")
    ButtonGadget(#Btn_2, 0, 0, 0, 0, "Button 2")
    SplitterGadget(#Splitter, Scale(10), Scale(40), WindowWidth(#Window_0) - Scale(20), WindowHeight(#Window_0) - Scale(50), #Btn_1, #Btn_2, #PB_Splitter_Separator)
    SetGadgetState(#Splitter, GadgetHeight(#Splitter) / 2)
  EndIf
EndProcedure

Open_Window_0()

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
    	Select EventGadget()
    		Case #Track_1
    			ScaleXY = GetGadgetState(#Track_1) / 100
    			Resize_Window_0()
    	EndSelect
  EndSelect
ForEver
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Splitter separator size

Post by RASHAD »

Maybe if you used CanvasGadget() so you can change the size and color too :)

Code: Select all


Procedure sizeCB()
  ResizeGadget(0,#PB_Ignore,#PB_Ignore,WindowWidth(0)-20,WindowHeight(0,#PB_Window_InnerCoordinate)-40)
  ResizeGadget(1,#PB_Ignore,#PB_Ignore,#PB_Ignore,WindowHeight(0,#PB_Window_InnerCoordinate)-40)
  ResizeGadget(2,#PB_Ignore,#PB_Ignore,#PB_Ignore,WindowHeight(0,#PB_Window_InnerCoordinate)-40)
  ResizeGadget(3,#PB_Ignore,#PB_Ignore,WindowWidth(0)-340,WindowHeight(0,#PB_Window_InnerCoordinate)-40)
  ResizeImage(0,WindowWidth(0),WindowHeight(0))       
  SetGadgetAttribute(0,#PB_Canvas_Image ,ImageID(0)) 
EndProcedure

sgcolor = $67DBF7

flags = #PB_Window_Invisible | #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,800,600,"Test",Flags)

If CreateStatusBar(0, WindowID(0))
  AddStatusBarField(100)
  AddStatusBarField(50)
  AddStatusBarField(100)
EndIf

StatusBarText(0, 0, "Area 1")
StatusBarText(0, 1, "Area 2", #PB_StatusBar_BorderLess)
StatusBarText(0, 2, "Area 3", #PB_StatusBar_Right | #PB_StatusBar_Raised) 

CreateImage(0,800,600,24,sgcolor)
CanvasGadget(0,10,10,780,560,#PB_Canvas_Container)
SetGadgetAttribute(0,#PB_Canvas_Image ,ImageID(0))

ListIconGadget(1,0,0,188,560,"Column 0",100,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)

ExplorerListGadget(2,192,0,188,560,"c:\")

ExplorerListGadget(3,384,0,396,560,"c:\")

CloseGadgetList()
While WindowEvent() : Wend 
BindEvent(#PB_Event_SizeWindow,@sizeCB()) 
HideWindow(0,0)

Repeat
  
  Select WaitWindowEvent()
      
    Case #PB_Event_CloseWindow
      Quit = 1
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_MouseEnter
              SetGadgetAttribute(0,#PB_Canvas_Cursor,#PB_Cursor_LeftRight)
              
            Case #PB_EventType_MouseLeave
              SetGadgetAttribute(0,#PB_Canvas_Cursor,#PB_Cursor_Default)
              
            Case #PB_EventType_LeftButtonDown
              cx = GetGadgetAttribute(0,#PB_Canvas_MouseX)               
              Downflag = 1
              If cx > GadgetX(2)
                split = 2
                ww = GadgetWidth(2)+GadgetWidth(3)+4
              Else
                split = 1
                ww = GadgetWidth(1)+GadgetWidth(2)+4
              EndIf             
              
            Case #PB_EventType_MouseMove
              If Downflag = 1
                cx = GetGadgetAttribute(0,#PB_Canvas_MouseX)
                If (cx < GadgetX(3)-12 And split = 1) Or (cx > GadgetX(2)+4 And split = 2)
                  If split = 1
                    ResizeGadget(1,#PB_Ignore,#PB_Ignore,cx,#PB_Ignore)                      
                    ResizeGadget(2,cx+4,#PB_Ignore,ww-cx-4,#PB_Ignore)
                  Else
                    ResizeGadget(2,#PB_Ignore,#PB_Ignore,cx-GadgetWidth(1)-4,#PB_Ignore)
                    While WindowEvent() : Wend                           
                    ResizeGadget(3,cx+4,#PB_Ignore,ww-GadgetWidth(2)-4,#PB_Ignore)                     
                  EndIf
                EndIf
              EndIf
              
            Case #PB_EventType_LeftButtonUp
              Downflag = 0                          
              ;ResizeGadget(3,#PB_Ignore,#PB_Ignore,#PB_Ignore,#PB_Ignore)
              
          EndSelect                   
      EndSelect         
      
  EndSelect 
  
Until Quit = 1
End

Edit :Modified
Edit :Modified 2
Last edited by RASHAD on Tue Nov 16, 2021 11:00 pm, edited 2 times in total.
Egypt my love
User avatar
ChrisR
Addict
Addict
Posts: 1150
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Splitter separator size

Post by ChrisR »

Thanks Rashad for your nice and complete Canvas-Splitter example :)
I was looking at whether it was possible with the real Splitter, to make it ~DpiAware and not have to manage all
But indeed, it is probably easier with a canvas, customized as wanted with the size, the drawing, the color
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Splitter separator size

Post by RASHAD »

You are welcome :D
Previous post updated a little bit
Egypt my love
BarryG
Addict
Addict
Posts: 3322
Joined: Thu Apr 18, 2019 8:17 am

Re: Splitter separator size

Post by BarryG »

Sorry to make you work, Rashad, but if you drag the second splitter to the left:

Image

Code: Select all

SmartWindowRefresh(0,1) ; Doesn't help.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Splitter separator size

Post by RASHAD »

Previous post updated
Egypt my love
BarryG
Addict
Addict
Posts: 3322
Joined: Thu Apr 18, 2019 8:17 am

Re: Splitter separator size

Post by BarryG »

Good job. Hehe.
dige
Addict
Addict
Posts: 1253
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Splitter separator size

Post by dige »

@RASHAD: Cool thing! As always! :D
"Daddy, I'll run faster, then it is not so far..."
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Splitter separator size

Post by Joris »

I didn't know about this gadget(-function) and used the splittergadget to get this things done.
But now, how do they differ in use or whatever (the splittergadget or this ResizeGadget) ?

Why isn't the ResizeGadget summed up in the gadgets list (PB help) ?

(And thanks Rashad for the nice code ... like always).
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Splitter separator size

Post by RASHAD »

@BarryG,dige and Joris
Thanks guys so much

@dige
In one of your posts you complained about FreeImage and the TIF format
I wish I can know more about it because I am using FreeImage myself :D
Egypt my love
dige
Addict
Addict
Posts: 1253
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Splitter separator size

Post by dige »

Just tested it again. Seems to be a problem with 32bit images.
But this gives me the idea, that maybe I have implemented something wrong? :oops: Since I'm actually only expecting 24 bit....
Can you load the following image with FreeImage?

https://u.pcloud.link/publink/show?code ... hhzSbV71a7
"Daddy, I'll run faster, then it is not so far..."
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Splitter separator size

Post by RASHAD »

Hi dige
1- Loaded as Default(0) - 24 bit depth
2- IrfanView says it's 32 bit depth but loaded as 24 bit depth like FreeImage
3- MS Windows Photo Viewer loaded as 32 bit depth

FreeImage is using DIB #DIB_RGB_COLORS which tends to 24 bit (MS GDI+)

Using MS WIC 32 bit
Egypt my love
Post Reply