PureRESIZE library : gadget automatic resizing and more

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

Moderator: gnozal

AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

SmartWindowRefresh(#WindowID, Flag) is an other method. It helps to prevent the window from flickering when it's resized.

And this resizing can be done manually or by your lib.

I can imagine, that many coders are using your fantastic ResizeLib, but some of them (like me) might wonder, why their window is flickering. They try to solve this problem, but don't know how. It would be nice, if you could write down this clue into your manual.


> and the lib went out long before
All (or most) of your libs were created with PB 3.94 or earlier, I know. But you must go ahead. Stay updated with your PB 4.x libs! If there are new possibilities (like the idea with #PB_Ignore for your ResizeLib), then use those possibilities!!!!

You think your lib is great? Ha, if you would implement more tricky functions like my idea with #PB_Ignore, then your lib wouldn't be great... IT WOULD BE BRILLIANT!!!! :wink:
PB 4.30

Code: Select all

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

Post by gnozal »

AND51 wrote:SmartWindowRefresh(#WindowID, Flag) is an other method. I can imagine, that many coders are using your fantastic ResizeLib, but some of them (like me) might wonder, why their window is flickering. They try to solve this problem, but don't know how. It would be nice, if you could write down this clue into your manual.
Sure, but I can't recommend what I haven't tested, and SmartWindowRefresh() is an official PB function, so it's in the manual ...
But I will test this and if it works well, I will add a line in the help file.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Image
PB 4.30

Code: Select all

onErrorGoto(?Fred)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Your update is bad!

Bug found!
Click and hold the upper^l eft< corner of the window to resize it. Now move it the the lower V right > corner: It resizes the window into the wrong direction!


I'll send you a video-link again (via PM)... Please, correct this error ASAP. I need to finish my program until monday.
If you can't correct this mistake, then give me the previous version of this lib it's better than the current one.

For the video: Please tell me, if you can extract 7z-Archives... Then I can compress the video to <300 KB. Otherweise, I must use ZIP insetad!


h.a.n.d., AND51
PB 4.30

Code: Select all

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

Post by gnozal »

AND51 wrote:Your update is bad!

Bug found!
Click and hold the upper^l eft< corner of the window to resize it. Now move it the the lower V right > corner: It resizes the window into the wrong direction!
Please test http://freenet-homepage.de/gnozal/PureRESIZE_BETA.zip
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 (both lib versions)

Changes :

- fixed 'manual upperleft corner resize + set minimal size' resize bug
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

yeah, now it's fixed!

thx!! :D
PB 4.30

Code: Select all

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

Post by gnozal »

Update (both versions)

Changes :

- enhanced PureRESIZE_SetGadgetResize(GadgetNumber.l, ...)
Parameter GadgetNumber now also may be a valid Windows control handle, this allows to use the library with 'API gadgets' created with CreateWindowEx_().
I needed it for a project.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Post by electrochrisso »

Thanks for your libs, they are great. :D
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update

Changes :
- fixed a 'minimal size' resize bug
Also recompiled PureFORM : this should fix the 'minimum window size' bug reported by tinman in preview mode.
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 »

Hi gnozal :)

A couple of requests.

1) Is it possible to have the unicode version of the library within the normal UserLibrary rather than having to set the subsystem? It's something I missed the first time and means I have to remember to set two things for unicode on each source. User libraries should be able to have unicode specific commands if they are called <Command>_UNICODE() and the library is passed through "libmaker" with the /UNICODE switch.

Would it be possible to have a resizing system where you can have 2 (or more) gadgets that resize or move side by side (e.g. OK and Cancel at the bottom of a dialog)? If PureResize can do this I have not figured it out. I use a library at work that allows you to set how much the left, top, right and bottom egdes of a gadget change by when a window is resized (float between 0 and 1). You can get normal "anchor" behaviour using 0's and 1's but you can also have multiple adjacent resizing elements using values in between.
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 »

tinman wrote:Is it possible to have the unicode version of the library within the normal UserLibrary rather than having to set the subsystem?
It is possible, but it's so much easier when using tailbite to compile separate libraries. I have so much librairies / versions that I am not sure to change this.
And it's fully transparent to the user with jaPBe V3.
tinman wrote:Would it be possible to have a resizing system where you can have 2 (or more) gadgets that resize or move side by side (e.g. OK and Cancel at the bottom of a dialog)?
Although I don't understand exactly what you mean, sounds like a complicated request :wink:
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:
tinman wrote:Is it possible to have the unicode version of the library within the normal UserLibrary rather than having to set the subsystem?
It is possible, but it's so much easier when using tailbite to compile separate libraries. I have so much librairies / versions that I am not sure to change this.
And it's fully transparent to the user with jaPBe V3.
OK.
gnozal wrote:
tinman wrote:Would it be possible to have a resizing system where you can have 2 (or more) gadgets that resize or move side by side (e.g. OK and Cancel at the bottom of a dialog)?
Although I don't understand exactly what you mean, sounds like a complicated request :wink:
OK, what about instead of completely anchoring to an edge, how about partially anchoring to an edge. So instead of a gadget moving by 1 pixel when the edge is moved, it moves by e.g. 0.5 of a pixel?

The bad thing is you'd need to store the current position/size of each gadget and that sounds like code you'd need to add :)
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 »

Sorry Tinman, I still don't get what you want.
About your Ok/Cancel example, have a look at the codes below :
Example 1

Code: Select all

Enumeration
  #Window_0
EndEnumeration
Enumeration
  #Button_Cancel
  #Button_Ok
EndEnumeration
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 450, 200, 195, 165, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    If CreateGadgetList(WindowID(#Window_0))
      ButtonGadget(#Button_Cancel, 0, 135, 65, 30, "Cancel")
      ButtonGadget(#Button_Ok, 130, 135, 65, 30, "Ok")
      PureRESIZE_SetGadgetResize(#Button_Cancel, 1, 0, 0, 1)
      PureRESIZE_SetGadgetResize(#Button_Ok, 0, 0, 1, 0)
    EndIf
  EndIf
EndProcedure

OpenWindow_Window_0()

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Select EventWindow()
        Case #Window_0
          CloseWindow(#Window_0)
          Break
      EndSelect
  EndSelect
Forever
Example 2

Code: Select all

Enumeration 
  #Window_0 
EndEnumeration 
Enumeration 
  #Button_Cancel 
  #Button_Ok 
EndEnumeration 
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 450, 200, 195, 165, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    If CreateGadgetList(WindowID(#Window_0))
      ButtonGadget(#Button_Cancel, 60, 135, 65, 30, "Cancel")
      ButtonGadget(#Button_Ok, 130, 135, 65, 30, "Ok")
      PureRESIZE_SetGadgetResize(#Button_Cancel, 0, 0, 1, 0)
      PureRESIZE_SetGadgetResize(#Button_Ok, 0, 0, 1, 0)
    EndIf
  EndIf
EndProcedure

OpenWindow_Window_0() 

Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_CloseWindow 
      Select EventWindow() 
        Case #Window_0 
          CloseWindow(#Window_0) 
          Break 
      EndSelect 
  EndSelect 
ForEver
Both look good to me. How should the buttons move when the window is resized ?
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: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:

Code: Select all

EnableExplicit

Define.l event
Define.l quit : quit = 0

Define.l original_width, new_width, diff_width

Structure lrf
    left.f
    right.f
EndStructure

Dim gadget_adjust.lrf(2)
Dim gadget_pos.lrf(2)

Define.lrf new

If OpenWindow(0, 0, 0, 400, 300, "foo", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered)

    original_width = WindowWidth(0)

    If CreateGadgetList(WindowID(0))
        ButtonGadget(1, 10, 265, 100, 25, "OK")
        ButtonGadget(2, 290, 265, 100, 25, "Cancel")
        
        ; Copy existing positions
        gadget_pos(1)\left = 10 : gadget_pos(1)\right = 110
        gadget_pos(2)\left = 290 : gadget_pos(2)\right = 390
        
        ; Set resize options
        gadget_adjust(1)\left = 0.1
        gadget_adjust(1)\right = 0.5
        
        gadget_adjust(2)\left = 0.5
        gadget_adjust(2)\right = 0.9
        
    EndIf

    While Not(quit)
        event = WaitWindowEvent()
        Select event
            Case #PB_Event_CloseWindow
                quit = 1
                
            Case #PB_Event_SizeWindow
                new_width = WindowWidth(0)
                diff_width = new_width - original_width

                ; Move gadget edges
                new\left = gadget_pos(1)\left + diff_width * gadget_adjust(1)\left
                new\right = gadget_pos(1)\right + diff_width * gadget_adjust(1)\right
                ResizeGadget(1, new\left, 265, new\right - new\left, 25)

                new\left = gadget_pos(2)\left + diff_width * gadget_adjust(2)\left
                new\right = gadget_pos(2)\right + diff_width * gadget_adjust(2)\right
                ResizeGadget(2, new\left, 265, new\right - new\left, 25)
        EndSelect
    Wend
    
    CloseWindow(0)
EndIf
End
And it's not just for OK and Cancel, I have some settings (3) arranged horizontally across a window and I want them to use roughly a third of the window each. But there are other things which must remain at a fixed size in between them, although move. See ->this image<- then ->this image<-.

Edit: URL incorrect.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Post Reply