It is currently Sat Dec 16, 2017 7:32 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: EventType Resize ?
PostPosted: Sat Nov 18, 2017 3:28 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 322
I should have mentioned i am on Windows (tested with Win 7/10) the same issue on both, with or without that cleaning white box which simply makes it easier to visualize the bug, still the issue persists on windows at least :!:


Top
 Profile  
Reply with quote  
 Post subject: Re: EventType Resize ?
PostPosted: Sat Nov 18, 2017 3:31 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10312
Location: Beyond the pale...
Post a bug report.

On Windows the resize event for a canvas gadget is firing after the gadget has been resized, but before the embedded bitmap has. Fred/Timo simply need to resize the bitmap before the resize event is sent.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject: Re: EventType Resize ?
PostPosted: Sat Nov 18, 2017 3:38 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 322
Bug reported, thanks for confirming srod :)


Top
 Profile  
Reply with quote  
 Post subject: Re: EventType Resize ?
PostPosted: Sun Nov 19, 2017 8:37 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 607
Even so it works
Code:
ResizeGadget(g, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore) ; << this fixes the issue without cycling!
   

Code:
EnableExplicit
Global gdt

Procedure initial_fill(g)
    If StartDrawing(CanvasOutput(g))
        Debug "initial_fill >>> Width = " + Str(GadgetWidth(g)) + "    Height = " + Str(GadgetHeight(g))
        Debug "initial_fill >>> Drawing-Width = " + Str(OutputWidth()) + "    Drawing-Height = " + Str(OutputHeight())
        DrawingMode(#PB_2DDrawing_Default)
        RoundBox(0, 0, OutputWidth(), OutputHeight(), 10, 10, #Green)
        StopDrawing()
    EndIf
EndProcedure

Procedure fill_callback()
    Protected g = EventGadget()
    ResizeGadget(g, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore) ; << this fixes the issue without cycling!
    If StartDrawing(CanvasOutput(g))
        Debug "fill_callback >>> Width = " + Str(GadgetWidth(g)) + "    Height = " + Str(GadgetHeight(g))
        Debug "fill_callback >>> Drawing-Width = " + Str(OutputWidth()) + "    Drawing-Height = " + Str(OutputHeight())
        DrawingMode(#PB_2DDrawing_Default)
        Box(0, 0, OutputWidth(), OutputHeight(), #White)
        RoundBox(0, 0, OutputWidth(), OutputHeight(), 10, 10, #Red)
        StopDrawing()
    EndIf
EndProcedure

OpenWindow(0,0,0, 200, 100, "test", #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
SetWindowColor(0, #Black)

gdt = CanvasGadget(#PB_Any, 5,5, 190, 90);, #PB_Canvas_Border)
BindGadgetEvent(gdt, @fill_callback(), #PB_EventType_Resize)

initial_fill(gdt)

Repeat
    Select WaitWindowEvent()
        Case #PB_Event_SizeWindow
            ResizeGadget(gdt, #PB_Ignore,#PB_Ignore, WindowWidth(0) - 10,  WindowHeight(0) - 10)
        Case #PB_Event_CloseWindow
            End
    EndSelect
ForEver


Top
 Profile  
Reply with quote  
 Post subject: Re: EventType Resize ?
PostPosted: Sun Nov 19, 2017 10:09 pm 
Offline
User
User

Joined: Fri Aug 04, 2017 11:03 pm
Posts: 17
this seems to work
Code:
EnableExplicit
Global gdt

Procedure initial_fill(g)
  ResizeGadget(g, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore)
    If StartDrawing(CanvasOutput(g))
        Debug "initial_fill >>> Width = " + Str(GadgetWidth(g)) + "    Height = " + Str(GadgetHeight(g))
        Debug "initial_fill >>> Drawing-Width = " + Str(OutputWidth()) + "    Drawing-Height = " + Str(OutputHeight())
         
        DrawingMode(#PB_2DDrawing_Default)
       
        RoundBox(0, 0, OutputWidth(), OutputHeight(), 10, 10, #Green)
       
        StopDrawing()
    EndIf
EndProcedure

Procedure fill_callback()
  ResizeGadget(gdt, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore) <----here
  If StartDrawing(CanvasOutput(EventGadget()))
    DrawingMode(#PB_2DDrawing_Default)
    Box(0, 0, OutputWidth(), OutputHeight(), #White) ;THIS ERASES THE PREVIOUS ROUND BOX!
    RoundBox(0, 0, OutputWidth(), OutputHeight(), 10, 10, #Red)
    StopDrawing()
  EndIf
EndProcedure

Procedure myResize(); <------ Add this procedure
 
  ResizeGadget(gdt, #PB_Ignore,#PB_Ignore, WindowWidth(0) - 10,  WindowHeight(0) - 10)
EndProcedure



Code:
OpenWindow(0,0,0, 200, 100, "test", #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
gdt = CanvasGadget(#PB_Any, 5,5, 190, 90);, #PB_Canvas_Border)
BindEvent(#PB_Event_SizeWindow, @myResize(), 0)
BindGadgetEvent(gdt, @fill_callback(), #PB_EventType_Resize)
initial_fill(gdt)

Repeat
  Select WaitWindowEvent()
      Case #PB_Event_SizeWindow
            ResizeGadget(gdt, #PB_Ignore, #PB_Ignore, WindowWidth(0) - 10,  WindowHeight(0) - 10)
    Case #PB_Event_CloseWindow
      End
  EndSelect
ForEver


__________________________________________________
Code tags added
20.11.2017
RSBasic


Top
 Profile  
Reply with quote  
 Post subject: Re: EventType Resize ?
PostPosted: Sun Nov 19, 2017 11:02 pm 
Offline
User
User

Joined: Fri Aug 04, 2017 11:03 pm
Posts: 17
this seems to work part2?

Code:
EnableExplicit
Global gdt

Procedure initial_fill(g)
;ResizeGadget(g, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore) ;Ignore this line not needed cdr3
If StartDrawing(CanvasOutput(g))
Debug "initial_fill >>> Width = " + Str(GadgetWidth(g)) + " Height = " + Str(GadgetHeight(g))
Debug "initial_fill >>> Drawing-Width = " + Str(OutputWidth()) + " Drawing-Height = " + Str(OutputHeight())

DrawingMode(#PB_2DDrawing_Default)

RoundBox(0, 0, OutputWidth(), OutputHeight(), 10, 10, #Green)

StopDrawing()
EndIf
EndProcedure

Procedure fill_callback()
ResizeGadget(gdt, #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore) ;<---- just add this line here cdr3
If StartDrawing(CanvasOutput(EventGadget()))
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, OutputWidth(), OutputHeight(), #White) ;THIS ERASES THE PREVIOUS ROUND BOX!
RoundBox(0, 0, OutputWidth(), OutputHeight(), 10, 10, #Red)
StopDrawing()
EndIf
EndProcedure

Procedure myResize(); <------ Add this procedure

ResizeGadget(gdt, #PB_Ignore,#PB_Ignore, WindowWidth(0) - 10, WindowHeight(0) - 10)
EndProcedure


Code:
OpenWindow(0,0,0, 200, 100, "test", #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
gdt = CanvasGadget(#PB_Any, 5,5, 190, 90);, #PB_Canvas_Border)
BindEvent(#PB_Event_SizeWindow, @myResize(), 0)
BindGadgetEvent(gdt, @fill_callback(), #PB_EventType_Resize)
initial_fill(gdt)

Repeat
  Select WaitWindowEvent()
      ;Case #PB_Event_SizeWindow
           ; ResizeGadget(gdt, #PB_Ignore, #PB_Ignore, WindowWidth(0) - 10,  WindowHeight(0) - 10) ;not needed
    Case #PB_Event_CloseWindow
      End
  EndSelect
ForEver


Top
 Profile  
Reply with quote  
 Post subject: Re: EventType Resize ?
PostPosted: Mon Nov 20, 2017 9:40 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10312
Location: Beyond the pale...
That's equivalent to what others had posted which of course is just a workaround which would, if the gadget had not already been resized, create an infinite loop! :) The fact that it doesn't is again due to the fact that the gadget has been resized, but not the embedded bitmap when the initial event fires.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


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