Need help with broken?! Scollpanels

Started by Grisu, July 14, 2019, 20:07:21

Previous topic - Next topic

Grisu

Hi all,

I'm trying to make gadgets (textfields, comboboxes, labels etc) to resize properly on a scollpanel... and failed so far.
I would like to increase the width of my app's window and at the same time to increase the width of the gadgets placed on the scrollpanel as well.
Without the scrollpanel every gadget adjustment works fine aka increases its width properly. But once placed on the scrollpanel, it seems to be "locked" in place?!

Below is a simplified example code of the framework that I'm using. I need to make it work within these edge cases.


SuperStrict

Framework MaxGui.Drivers
Import BRL.GLMax2D
Import BRL.StandardIO
Import BRL.Pixmap
Import BRL.EventQueue
Import BRL.Timer
Import BRL.Retro
Import BRL.Max2D
Import BRL.Pngloader
Import BRL.Jpgloader
Import Maxgui.ProxyGadgets

Const MAINWINDOW_W:Int = 278
Const MAINWINDOW_H:Int = 154
Const BUTTONSIZE:Byte = 30
Const LABEL_STARTY:Byte = 3

?win32
Const PNL_HEIGHT:Int = 22
Const SLIDER_WIDTH:Int = 22
Const WIN_MENU_FLAG:Int = 0
?

Global SpectrumTimer:TTimer=CreateTimer(24)

' //////  Main Window
Global icol:Int
Global flags:Int=WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS | WINDOW_CENTER | WIN_MENU_FLAG | WINDOW_ACCEPTFILES | WINDOW_RESIZABLE
Global MainWindow:TGadget=CreateWindow("Scrollbar Test",0,0,MAINWINDOW_W,MAINWINDOW_H,Null, flags)

Global Button2:TGadget=CreateButton("Exit APP",2,MAINWINDOW_H-BUTTONSIZE,MAINWINDOW_W-3,BUTTONSIZE,MainWindow,BUTTON_OK)
SetGadgetLayout Button2,EDGE_ALIGNED,EDGE_ALIGNED,Null,EDGE_ALIGNED

' //////  Creator Panel
Global CreatorPanel:TGadget = CreatePanel(0, 0, MAINWINDOW_W, MAINWINDOW_H, MainWindow)', PANEL_ACTIVE)
SetGadgetLayout CreatorPanel, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED

Global CreatorPanel_White: TGadget = CreatePanel(0, 0, MAINWINDOW_W, 22, CreatorPanel)',PANEL_SUNKEN)
SetGadgetLayout CreatorPanel_White, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, Null
SetGadgetColor CreatorPanel_White,255,255,255

Global Label_creator1:TGadget=CreateLabel:TGadget("Editor",2,LABEL_STARTY,MAINWINDOW_W-80-6,16,CreatorPanel_White,LABEL_LEFT)
?Not Linux
SetGadgetFont( Label_creator1, LookupGuiFont( GUIFONT_SYSTEM, 0, FONT_BOLD) )
?
SetGadgetLayout Label_creator1, EDGE_ALIGNED, Null, EDGE_ALIGNED, Null

Global CreatorScrlMain:TScrollPanel = CreateScrollPanel(0,22, MAINWINDOW_W, MAINWINDOW_H-3-BUTTONSIZE-3-19, CreatorPanel,SCROLLPANEL_HNEVER)'|SCROLLPANEL_SUNKEN)', SCROLLPANEL_VNEVER)', SCROLLPANEL_SUNKEN)
SetGadgetLayout CreatorScrlMain,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED
SetGadgetSensitivity(CreatorScrlMain , SENSITIZE_MOUSE)

Global CreatorClient:TGadget = ScrollPanelClient(CreatorScrlMain)
SetGadgetLayout Creatorclient,Null, Null, EDGE_ALIGNED,EDGE_ALIGNED
SetGadgetSensitivity(CreatorClient , SENSITIZE_MOUSE)

Global Creator_NameTextField:TGadget = CreateTextField(3,3,MAINWINDOW_W-3-SLIDER_WIDTH-30, PNL_HEIGHT, CreatorClient)
SetGadgetLayout Creator_NameTextField, EDGE_ALIGNED, Null, EDGE_ALIGNED, Null

Global Creator_UrlTextField:TGadget = CreateTextField(3,3+PNL_HEIGHT+2,MAINWINDOW_W-3-SLIDER_WIDTH-30, PNL_HEIGHT, CreatorClient)
SetGadgetLayout Creator_UrlTextField, EDGE_ALIGNED, Null, EDGE_ALIGNED, Null

Global Creator_GenreListbox1:TGadget     = CreateComboBox(3,1+PNL_HEIGHT*2+14, MAINWINDOW_W-3-SLIDER_WIDTH-30, PNL_HEIGHT, CreatorClient)
SetGadgetLayout Creator_GenreListbox1, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED ' Show when window height increases...
AddGadgetItem Creator_GenreListbox1,"Listbox Text 01", GADGETITEM_NORMAL, -1, "0"
SelectGadgetItem(Creator_GenreListBox1,0)

Global Creator_GenreListbox2:TGadget     = CreateComboBox(3,1+PNL_HEIGHT*5+14, MAINWINDOW_W-3-SLIDER_WIDTH-30, PNL_HEIGHT, CreatorClient)
SetGadgetLayout Creator_GenreListbox2, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED ' Show when window height increases...
AddGadgetItem Creator_GenreListbox2,"Listbox Text 02", GADGETITEM_NORMAL, -1, "0"
SelectGadgetItem(Creator_GenreListBox2,0)

FitScrollPanelClient( CreatorScrlMain , SCROLLPANEL_SIZETOKIDS )

' ///// Set Window Dimensions
SetMinWindowSize(MainWindow,MAINWINDOW_W,MAINWINDOW_H)
SetMaxWindowSize(MainWindow,600,DesktopHeight())

' ///// Main Loop

While WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE
End
Case EVENT_GADGETACTION
          Select EventSource()

                 Case BUTTON2
          End
                 End Select

       Case EVENT_TIMERTICK

    Select EventSource()

Case SpectrumTimer
        End Select

End Select

Wend
End


Thanks in advance for your support
Grisu
Pocket Radio Player     Cardwar

cpsmith0191

Just seen this post, a work around may be a resize demo I did a little while ago. It does not use scroll bars but a button to increase and a button to decrease the size, the code is intended to be added to an existing program to save rewriting for a different screen resolution.
You can download it from http://cpsmith0191.freeoda.com/mysite/index.html, select blitz max demos, resize demo.
If you are intent on using scroll bars an event hook might provide a solution, as I had problems with smooth canvas scrolling until I used one.
(Must add that event hook code was provided by someone on the old blitz max forum.)
If you want the event hook code I can upload it to my site. Have fun cps.

Grisu

I'm really interested in the event hook code you mentioned.  As your first code isn't solving my issue and I don't want a user to click a button in 2020 for stuff that should work "out of the box".

I added an image as an example of what I'm trying to get out of a "fix".



Pocket Radio Player     Cardwar

cpsmith0191

I've uploaded a zip file to my web site called scroll_demo.zip, it unzips to two files.
mapmove.bmx and current.jpg unzip both to same directory and you should be away.
NB Event hook code provided by somebody on the original blitz website and I've lost their info so can't give them credit.
My web site is :   http://cpsmith0191.freeoda.com/mysite/index.html, select blitz max demos from the left then scroll_demo to download the zip file.
Hope you find this useful, have fun cps.

Grisu

Thanks for your help. Too bad I have no Brucey (tm) coding powers. :(
Pocket Radio Player     Cardwar

Henri

Hi,

CreateScrollPanel-function has a SCROLLPANEL_HSCALING flag. Does that help if you add that ?

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Grisu

Thanks a lot Henri. Didn't know that flag exits...  :o

Anyway, after hours of moving more flags and panels around, I got it working...  ;D
Pocket Radio Player     Cardwar