PureRESIZE library : gadget automatic resizing and more

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

tinman wrote:
gnozal wrote:How should the buttons move when the window is resized ?
Like the first example, but the size of both gadgets increase as well as being anchored to the left and right edge. Here is some code that shows the effect I would like to achieve: ...
Ok, I see.
Some kind of proportional resizing.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

gnozal wrote:Ok, I see. Some kind of proportional resizing.
Yes, but if you won't add it then it's no problem. Just a request :)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (all versions)

Changes :
- new function PureRESIZE_SetGadgetProportionalResize().
This feature is hard to explain ; run the code example in the manual.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Woohoo, gnozal you rock! :)
Thank you so much.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

gnozal,

That was a great addition to your library! One thing I noticed is that (for example) if I have a listicon and I enable resize on top/left/bottom/right and turn on vertical proportional resize, the top does not stay locked.

It seems to me that if all (top/right/bottom/left) are locked and vertical prop. is turned on that only the height of the listicon should change (in proportion to the height change of the window) and not the Y position.

Is this a small bug or am I misinterpreting how it works?

Thanks again for this!
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Xombie wrote:It seems to me that if all (top/right/bottom/left) are locked and vertical prop. is turned on that only the height of the listicon should change (in proportion to the height change of the window) and not the Y position.
When enabling proportional resize the 'lock' behaviour changes. The proportional feature is designed to resize multiple gadgets on the same line / column.

It's very hard to explain. I use PureFORM to simulate the resizing behaviour : build your form, set the resizing options [Extra tab], hit F5 [Preview mode on], try resizing, hit F5 [Preview mode off], change resize settings, hit F5 [Preview mode on], try resizing, etc...

For your listicon, lock TOP/LEFT only.
Try this code : the 2 listicons resize vertically proportionally to the window height.

Code: Select all

Enumeration
  #Window_0
EndEnumeration
Enumeration
  #ListIcon_0
  #ListIcon_1
EndEnumeration
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 293, 99, 392, 430, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    If CreateGadgetList(WindowID(#Window_0))
      ListIconGadget(#ListIcon_0, 5, 5, 190, 235, "Gadget_0", 100, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
      ListIconGadget(#ListIcon_1, 5, 245, 190, 180, "Gadget_1", 100, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
      PureRESIZE_SetGadgetResize(#ListIcon_0, 1, 1, 0, 0)
      PureRESIZE_SetGadgetProportionalResize(#ListIcon_0, 0, 1)
      PureRESIZE_SetGadgetResize(#ListIcon_1, 1, 1, 0, 0)
      PureRESIZE_SetGadgetProportionalResize(#ListIcon_1, 0, 1)
    EndIf
  EndIf
EndProcedure

OpenWindow_Window_0()

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
        CloseWindow(#Window_0)
        Break
  EndSelect
Forever
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

gnozal,

I put together an example in PureForm for your reference. There are 3 dividing lines and a listicon in a container on the form. If you resize the height of the window you'll (hopefully) see that the listicon's Y position changes in regard to the second dividing bar.

I also tried without the container and got the same behavior.

Code: Select all

;{- Enumerations / DataSections
;{ Windows
Enumeration
   #WindowMain
EndEnumeration
;}
;{ Status bars
Enumeration
   #StatusBar_WindowMain
EndEnumeration
;}
;{ Gadgets
Enumeration
   #ContainTest
   #DivideTest01
   #DivideTest02
   #DivideTest03
   #ListTestMain
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_WindowMain()
   If OpenWindow(#WindowMain, #PB_Ignore, #PB_Ignore, 900, 700, "Test", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_MaximizeGadget)
      If CreateStatusBar(#StatusBar_WindowMain, WindowID(#WindowMain))
      EndIf
      If CreateGadgetList(WindowID(#WindowMain))
         ContainerGadget(#ContainTest, 102, 0, 798, 680, #PB_Container_Raised) ;>
            TextGadget(#DivideTest01, 1, 25, 790, 5, " ", #PB_Text_Border)
            TextGadget(#DivideTest02, 1, 165, 790, 5, " ", #PB_Text_Border)
            TextGadget(#DivideTest03, 1, 625, 790, 5, " ", #PB_Text_Border)
            ListIconGadget(#ListTestMain, 1, 175, 790, 445, "", 0, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
         CloseGadgetList() ;<
         ; Gadget Resizing
         PureRESIZE_SetGadgetResize(#ContainTest, 1, 1, 1, 1)
         PureRESIZE_SetGadgetResize(#DivideTest01, 1, 1, 1, 0, #ContainTest)
         PureRESIZE_SetGadgetResize(#DivideTest02, 1, 1, 1, 0, #ContainTest)
         PureRESIZE_SetGadgetResize(#DivideTest03, 1, 0, 1, 1, #ContainTest)
         PureRESIZE_SetGadgetProportionalResize(#DivideTest03, 0, 1)
         PureRESIZE_SetGadgetResize(#ListTestMain, 1, 1, 0, 0, #ContainTest)
         PureRESIZE_SetGadgetProportionalResize(#ListTestMain, 0, 1)
         ; Window Minimum Size
         PureRESIZE_SetWindowMinimumSize(#WindowMain, 900, 700)
      EndIf
   EndIf
EndProcedure

OpenWindow_WindowMain()

;{- Event loop
Repeat
   Event = WaitWindowEvent()
   Select Event
      ; ///////////////////
      Case #PB_Event_Gadget
         EventGadget = EventGadget()
         EventType = EventType()
      ; ////////////////////////
      Case #PB_Event_CloseWindow
         EventWindow = EventWindow()
         If EventWindow = #WindowMain
            CloseWindow(#WindowMain)
            Break
         EndIf
   EndSelect
ForEver
;
;}
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Xombie wrote:gnozal,

I put together an example in PureForm for your reference. There are 3 dividing lines and a listicon in a container on the form. If you resize the height of the window you'll (hopefully) see that the listicon's Y position changes in regard to the second dividing bar.
Ok, I see what you mean.

The proportional feature is designed to resize all gadgets on the same line / column like in this project [Edit -> Load project from clipboard] :

Code: Select all

;{[PureFORM Project]
;PureFORM_Project_Begin
;Project¶!!XombieProject
;Window¶1¶#WindowMain¶13565952¶#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_MaximizeGadget¶Test¶345¶63¶900¶708¶0¶0¶0¶0¶0¶0¶0¶-1¶0¶¶¶
;ContainerGadget¶1¶#ContainTest¶1¶-1¶-1¶0¶0¶5¶0¶2¶#PB_Container_Raised¶¶¶-1¶0¶¶¶0¶0¶1¶0¶0¶102¶0¶798¶680¶1¶1¶1¶1¶1¶0·0·0¶0¶-1¶-1¶-1¶-1¶¶0¶¶0¶0
;TextGadget¶2¶#DivideTest01¶1¶1¶5¶0¶0¶26¶0¶131072¶#PB_Text_Border¶ ¶¶-1¶0¶¶¶0¶0¶0¶0¶0¶1¶25¶790¶5¶1¶1¶1¶0¶0¶1·0·1¶0¶-1¶-16777216¶-1¶-1¶¶0¶¶0¶0
;TextGadget¶3¶#DivideTest02¶1¶1¶5¶0¶0¶26¶0¶131072¶#PB_Text_Border¶ ¶¶-1¶0¶¶¶0¶0¶0¶0¶0¶1¶165¶790¶5¶1¶1¶1¶0¶0¶1·0·1¶0¶-1¶-16777216¶-1¶-1¶¶0¶¶0¶0
;TextGadget¶4¶#DivideTest03¶1¶1¶5¶0¶0¶26¶0¶131072¶#PB_Text_Border¶ ¶¶-1¶0¶¶¶0¶0¶0¶0¶0¶1¶625¶790¶5¶1¶1¶1¶0¶0¶1·0·1¶0¶-1¶-16777216¶-1¶-1¶¶0¶¶0¶0
;ListIconGadget¶5¶#ListTestMain¶1¶1¶5¶0¶0¶15¶0¶1073807368¶#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect¶¶¶-1¶0¶0¶¶0¶0¶0¶0¶0¶1¶175¶790¶445¶1¶1¶1¶0¶0¶1·0·1¶0¶-1¶-1¶-1¶-1¶¶0¶¶0¶0
;PureFORM_Project_End
;}
I never thought about (fixed height) separators ...
I will try to add some extra parameters to allow proportional movement without changing width / height.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (all versions)

Changes :
- added extra parameters to PureRESIZE_SetGadgetProportionalResize() allowing to lock the width / height. Gadget still moves proportionaly to the parent, but the width / height is locked (usefull for separators).

Xombie, try this code with the new library : I hope it's what you expected. I don't think I can do better for now.

Code: Select all

;
; /////////////// EXAMPLE 2
;
Enumeration
  #WindowMain
EndEnumeration
Enumeration
  #ContainTest
  #DivideTest01
  #DivideTest02
  #DivideTest03
  #ListTestMain
EndEnumeration
Procedure OpenWindow_WindowMain()
  If OpenWindow(#WindowMain, 345, 63, 820, 708, "PureRESIZE proportional demo 2", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
    If CreateGadgetList(WindowID(#WindowMain))
      ContainerGadget(#ContainTest, 10, 0, 798, 680, #PB_Container_Raised)
        TextGadget(#DivideTest01, 1, 25, 790, 5, " ", #PB_Text_Border)
        TextGadget(#DivideTest02, 1, 165, 790, 5, " ", #PB_Text_Border)
        TextGadget(#DivideTest03, 1, 625, 790, 5, " ", #PB_Text_Border)
        ListIconGadget(#ListTestMain, 1, 175, 790, 445, "", 0, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
      CloseGadgetList()
    EndIf
  EndIf
EndProcedure

OpenWindow_WindowMain()

PureRESIZE_SetGadgetResize(#ContainTest, 1, 1, 1, 1)
PureRESIZE_SetGadgetResize(#DivideTest01, 1, 1, 0, 0, #ContainTest)
PureRESIZE_SetGadgetResize(#DivideTest02, 1, 1, 0, 0, #ContainTest)
PureRESIZE_SetGadgetResize(#DivideTest03, 1, 1, 0, 0, #ContainTest)
PureRESIZE_SetGadgetResize(#ListTestMain, 1, 1, 0, 0, #ContainTest)

; Proportional vertical resize with separators
PureRESIZE_SetGadgetProportionalResize(#DivideTest01, 0, 1, 0, 1)
PureRESIZE_SetGadgetProportionalResize(#DivideTest02, 0, 1, 0, 1)
PureRESIZE_SetGadgetProportionalResize(#DivideTest03, 0, 1, 0, 1)
PureRESIZE_SetGadgetProportionalResize(#ListTestMain, 0, 1)

PureRESIZE_SetWindowMinimumSize(#WindowMain, 820, 400)
PureRESIZE_SetWindowMaximumSize(#WindowMain, 820, 800)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Select EventWindow()
        Case #WindowMain
          CloseWindow(#WindowMain)
          Break
      EndSelect
  EndSelect
ForEver
End
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (all versions)

Changes :
- new function PureRESIZE_CenterGadget(GadgetNumber.l, Horizontal.l, Vertical.l) : enables automatic centering for a gadget.
Please see help file code example.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

Post by storck »

Thank you Gnozal!

I love the option to center a gadget.

Where do you find the time for all these updates? Do you have like 25 hour days where you live? 10 days each week? 400 days each year? It must be something... Or is it just hard work? :wink:

Best Regards,

Storck
User avatar
Zizaco
User
User
Posts: 26
Joined: Tue May 16, 2006 8:20 pm
Contact:

Post by Zizaco »

http://www.purebasic.fr/english/viewtopic.php?t=30902

Is it possible to use the PureRESIZE library with the "Windows" inside a MDIGadget?
The functions PureRESIZE_SetWindowMinimumSize and MaximumSize works for me, but the "PureRESIZE_SetGadgetResize() " don't.
Why? There is any way to get it to work?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Zizaco wrote:http://www.purebasic.fr/english/viewtopic.php?t=30902
Is it possible to use the PureRESIZE library with the "Windows" inside a MDIGadget?
The functions PureRESIZE_SetWindowMinimumSize and MaximumSize works for me, but the "PureRESIZE_SetGadgetResize() " don't.
Why? There is any way to get it to work?
Sorry ...
I didn't think about MDI when I designed the library because I never use MDI.
Please note that MDI gadget items are windows, not gadgets ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
quasiperfect
Enthusiast
Enthusiast
Posts: 157
Joined: Tue Feb 13, 2007 6:16 pm
Location: Romania
Contact:

Post by quasiperfect »

i think there is a bug in the panel gadget resizing it dosen't work properly
here is a pureform project with the bug in action http://www.quasiperfect.eu/diverse/qpphp.pbf
Last edited by quasiperfect on Sat Apr 12, 2008 10:55 am, edited 1 time in total.
Registered user of PureBasic
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

quasiperfect wrote:i think there is a bug in the panel gadget resizing it dosen't work properly
i can send u a pureform project with the bug in action
Yep, some code would help.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply