It is currently Fri May 25, 2018 9:49 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: ScrollAreaGadget display problems if height > 32000 pixel
PostPosted: Sun Jun 18, 2017 8:59 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1555
Location: Germany (Saxony, Deutscheinsiedel)
Maybe it's a PB Bug, a MS Windows limitation (maybe different between the different Windows versions) or something else...

But I discovered display problems in my multimedia viewer, if I'm displaying many thumbnail pictures one below each other and reaching a specific inner height of the used ScrollAreaGadget.

As there isn't written anything in the PB docs about it, and I don't see this effect on my MacBook (MacOS 10.6.8 ), I created the following test code for Windows (here using Win10). There you can see, that the CanvasImages are overlaying each other as soon a position of around 32,000 pixels is reached.... just scroll down in the ScrollAreaGadget.

Code:
Procedure BindScrollDatas()
  SetWindowTitle(0, "ScrollAreaGadget " +
                    "(" +
                    GetGadgetAttribute(0, #PB_ScrollArea_X) +
                    "," +                     
                    GetGadgetAttribute(0, #PB_ScrollArea_Y) +
                    ")" )
EndProcedure

If OpenWindow(0, 0, 0, 405, 800, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScrollAreaGadget(0, 10, 10, 390, 780, 390, 555, 30)
 
  y = 10
  ButtonGadget  (1, 10, y, 230, 30,"Button 1")  : y + 40
  ButtonGadget  (2, 50, y, 230, 30,"Button 2")  : y + 40
  ButtonGadget  (3, 90, y, 230, 30,"Button 3")  : y + 40
  TextGadget    (4,130, y, 230, 20,"This is the content of a ScrollAreaGadget!",#PB_Text_Right)  : y + 40
 
  #ImageHeight = 200
  For a = 0 To 200
    CreateImage(a, Random(300, 100), #ImageHeight)
    drawX = ImageWidth(a)
   
    If StartDrawing(ImageOutput(a))
      drawY = 0
      For x = 0 To drawX Step 10
        RoundBox(x, drawY, drawX-2*x, #ImageHeight-2*drawY, 20, 20, RGB(Random(255), Random(255), Random(255)))
        drawY + 10
      Next x
      DrawText(10, 10, "Image " + Str(a))
      StopDrawing()
    EndIf
   
    CanvasGadget(5+a, 10 + (300-drawX)/2, y, drawX, #ImageHeight)  : y + #ImageHeight + 10
    SetGadgetAttribute(5+a, #PB_Canvas_Image, ImageID(a))
  Next
 
  SetGadgetAttribute(0, #PB_ScrollArea_InnerHeight, y)
 
  CloseGadgetList()
 
  BindGadgetEvent(0, @ BindScrollDatas())
 
  Repeat
    Select WaitWindowEvent()
      Case  #PB_Event_CloseWindow
        End
      Case  #PB_Event_Gadget
        Select EventGadget()
          Case 0
            ;               MessageRequester("Info","Ein Scrollbalken wurde verwendet! (" +
            ;                                       GetGadgetAttribute(0, #PB_ScrollArea_X) +
            ;                                       "," +                     
            ;                                       GetGadgetAttribute(0, #PB_ScrollArea_Y) +
            ;                                       ")" ,#PB_MessageRequester_Ok)
          Case 1
            MessageRequester("Info","Button 1 was pressed!",#PB_MessageRequester_Ok)
          Case 2
            MessageRequester("Info","Button 2 was pressed!",#PB_MessageRequester_Ok)
          Case 3
            MessageRequester("Info","Button 3 was pressed!",#PB_MessageRequester_Ok)
        EndSelect
    EndSelect
  ForEver
EndIf

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Sun Jun 18, 2017 9:32 pm 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 922
Yep, it fails here on Win 10
On Linux and Mac it works
I self think, here you must have a answer from Fred or Freak.

Regards Werner

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Mon Jun 19, 2017 11:24 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1555
Location: Germany (Saxony, Deutscheinsiedel)
walbus wrote:
Yep, it fails here on Win 10
On Linux and Mac it works
I self think, here you must have a answer from Fred or Freak.


You're right, Werner.

I just need to know, if it can be fixed or if it is a non-changeable limitation (which then needs a remark in the PB docs).

I'm just using the ScrollAreaGadget now, for displaying much content like thumbnail images + further informations (textgadget etc.).
Other things like displaying only a limited number of thumbnails/informations in a container gadget + switching to new content after clicking/moving a seperate scrollbar would also need more programming effort, would have a slow-down on reaction to user input (instead of having to wait for a little progressbar while the thumbnails are loaded and the ScrollArea is filled with them...).

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Wed Jun 21, 2017 7:47 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 7969
Location: Kelowna, BC, Canada
The nMax member of the SCROLLINFO structure for the vertical scrollbar is set with SetGadgetAttribute, as shown in the code. However, this member maxes out at 32766 on Windows regardless of the value in SetGadgetAttribute. This can be overcome in API using SetScrollInfo_(), which is initially encouraging. Celebrations are shortlived however, as having overcome this limitation for the scrollbar, the undesirable behavior remains. Which means it's probably something the team can correct in the gadget code as it's probably based on the standard limitation and doesn't consider the coder's API manipulation of nMax. Probably Fred didn't foresee that someone would want more than 32766 for a maximum dimension. However, once you enter the world of earth mapping or similar project, 32766 isn't very much at all.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Tue Jul 11, 2017 2:10 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13266
Location: France
I think it's a Windows limitation, because at some point the 'y' coordinate of the new gadget is capped and still result to the same value. Just put:

Code:
Debug GadgetY(5+a)


right after the canvasgadget() creation and you will see that.


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Sun Jul 16, 2017 8:49 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1555
Location: Germany (Saxony, Deutscheinsiedel)
Ok, so it should be checked for limitations on any OS supported by PB and then the PB docs need to get the related remarks. Thanks!

For myself I will think, what to do/rework in my project...

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Mon Jul 17, 2017 9:39 am 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 922
Code updated d20 m07 y2017

Hi Andre,
primary you can fix it with a workaround

Looking here, this little tricky sample, now you see all canvas, the Limit is completely removed :shock:

Code:
; Win OS - Workaround sample for removing the 32k size Limit on the ScrollAreaGadget - First testversion d19 m07 y2017
; Author Werner Albus - www.nachtoptik.de - www.quick-aes-256.de

#ImageHeight=200 ; Change you the height, you must change also the pre defined offset, it's simple

#AmountCanvas=4000

Global Dim y_pos_canvas(#AmountCanvas)

Procedure BindScrollDatas()
  yy=-(#ImageHeight+10)
  offset.f=0.0070042*#AmountCanvas ; Pre defined offset for max 9000 canvas, changeable
  min=#AmountCanvas*(#ImageHeight+10)
 
  If min<=GadgetHeight(0)
    DisableGadget(0, 1)
  Else
    short_loop_1:
    If y_pos_canvas(#AmountCanvas)-GetGadgetAttribute(0, #PB_ScrollArea_Y)*offset<GadgetHeight(0)-10 And min>GadgetHeight(0)
      offset-0.00001
       Goto short_loop_1
   EndIf
    For a=1 To #AmountCanvas
      yy+(#ImageHeight+10)
      scroll_offset.f=GetGadgetAttribute(0, #PB_ScrollArea_Y)*offset
      If y_pos_canvas(a)-(#ImageHeight+10)-scroll_offset<GadgetHeight(0) And  y_pos_canvas(a)-(#ImageHeight+10)-scroll_offset>-(#ImageHeight+10)
        HideGadget(5+a, 0)
        ResizeGadget(5+a, #PB_Ignore, yy-scroll_offset+10, #PB_Ignore, #PB_Ignore)
      Else
        HideGadget(5+a, 1)
      EndIf
    Next
    DisableGadget(0, 0)
  EndIf
 
EndProcedure

If OpenWindow(0, 0, 0, 363, 800, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ScrollAreaGadget(0, 331, 10, 21, 780, 0, 0, 1500/#AmountCanvas+1, #PB_Container_Single)
  CloseGadgetList()
  ContainerGadget(#PB_Any, 10, 10, 325, GadgetHeight(0), #PB_Container_Double)
 
  y=10
  For a=1 To #AmountCanvas
    CreateImage(1, Random(300, 100), #ImageHeight)
    drawX=ImageWidth(1)
    If StartDrawing(ImageOutput(1))
      drawY=0
      For x=0 To drawX Step 10
        RoundBox(x, drawY, drawX-2*x, #ImageHeight-2*drawY, 20, 20, RGB(Random(255), Random(255), Random(255)))
        drawY+10
      Next x
      DrawText(10, 10, "Image "+Str(a))
      StopDrawing()
    EndIf
    CanvasGadget(5+a, 10+(300-drawX)/2, y, drawX, #ImageHeight)  : y+#ImageHeight+10
    y_pos_canvas(a)=y
    SetGadgetAttribute(5+a, #PB_Canvas_Image, ImageID(1))
    While WindowEvent() : Wend
  Next

  SetGadgetAttribute(0, #PB_ScrollArea_InnerHeight, 30759-100000/#AmountCanvas)
 
  BindGadgetEvent(0, @BindScrollDatas())
 
  Repeat
    Select WaitWindowEvent()
      Case  #PB_Event_CloseWindow
        End
      Case  #PB_Event_Gadget
        Select EventGadget()
        EndSelect
    EndSelect
  ForEver
EndIf

_________________
http://www.nachtoptik.de


Last edited by walbus on Thu Jul 20, 2017 8:22 am, edited 26 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Mon Jul 17, 2017 9:20 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1555
Location: Germany (Saxony, Deutscheinsiedel)
Thank you, walbus, for trying to help with a workaround.

Unfortunately the limited height (~32,000 pixel) of a ScrollAreaGadget can't be really solved, also not by your workaround.
Of course I can decrease the height of my images to display, e.g. by limiting their height to 150 pixel (instead of 200). In this case there can be displayed 263 images.

But this number is always limited, and you can't decrease the height of pictures (preview pics of landscapes, cities, etc. in my project) endless. Somewhen it's not usable for the user anymore...

As the number of pictures, for which a preview pic has to be displayed, can easilly reach 1,000 and more I need to program such a "image preview" (e.g. with displaying the actual one in greater size, the one before and after in smaller size, and buttons/scrollbar for moving through the list of pictures matching different selected criterias) myself....

Using the ScrollAreaGadget will also hit its limits on MacOS somewhen, or the loading/displaying is taking to much time and/or memory, etc.

As I'm having my solution in mind, this thread is now mainly for adding needed remarks to the PB docs.

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Wed Jul 19, 2017 2:15 pm 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 922
Hi Andre,
I have updated the code above
You can simple change this code for using as sample up to 9000 canvas now
It was a little fiddly, but now, i think, it works fine.....

This new code emulate the ScrollAreaGadget and can so remove the limitation complete :wink:

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Fri Jul 21, 2017 8:13 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1555
Location: Germany (Saxony, Deutscheinsiedel)
Thank you again, Walbus!

When I think more and more about the best solution, the used ScrollAreaGadget was a quick solution, but trying to display hundreds or thousands of image previews at once is really not the ideal solution.
What goes fast here with self-painted images takes a lot more time, when loading all the pictures (up to HD resolution) and resizing them to smaller preview pics. This will take a lot of time at some point, and the memory is also limited (or the automatic using of a swap file lead to slow-down).

So programming a solution similar to the 'MacOS Finder' seems the way to go: displaying a result list and one or several preview pics, where the next/previous image previews will be loaded when moving through the result list. Probably there is already example code for this, haven't searched already...

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Sun Jul 23, 2017 8:55 am 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 922
Hi Andre,
yep, it's not simple to find the best solution
A Picture preview is ever a good thing, but with so many canvas not optimal, i think...

Regards Werner

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Sun Jul 30, 2017 6:45 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13266
Location: France
Moved to documentation


Top
 Profile  
Reply with quote  
 Post subject: Re: ScrollAreaGadget display problems if height > 32000 pixe
PostPosted: Sat Apr 21, 2018 10:17 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1555
Location: Germany (Saxony, Deutscheinsiedel)
Fred, any suggestion what should be added to the docs?

(As there will be needed different notes for each OS...)

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye