Recent

Author Topic: [Solved] Drawing outside of the Paint cycle  (Read 3960 times)

JimKueneman

  • Full Member
  • ***
  • Posts: 189
[Solved] Drawing outside of the Paint cycle
« on: May 02, 2017, 05:47:55 am »
Is there something special I need to call to draw on the control outside of the normal WM_PAINT call in OS X?  I am trying to draw a selection rectangle from within the MouseMove event but it won't draw anything.  Window and Linux both draw the rectangle I paint with the windows TCanvas.

Jim
« Last Edit: May 03, 2017, 05:44:12 am by JimKueneman »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9283
  • FPC developer.
Re: Drawing outside of the Paint cycle
« Reply #1 on: May 02, 2017, 10:14:08 am »
Most non windows widgetsets don't allow drawing outside of the draw event.

So set some flag, and then invalidate the relevant area. Then, in the paint event draw.

Graeme

  • Hero Member
  • *****
  • Posts: 1431
    • Graeme on the web
Re: Drawing outside of the Paint cycle
« Reply #2 on: May 02, 2017, 12:03:51 pm »
Drawing outside the OnPaint event is not supported by LCL on all target widgetsets. It some cases it might seem to work, but in those cases you are just lucky.

Having worked on my own GUI toolkit for years, there really is no need to do painting outside the OnPaint event - no matter what type of application or widget you are trying to implement. Yes, even selection rectangles can be painted from inside the OnPaint event.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

JimKueneman

  • Full Member
  • ***
  • Posts: 189
Re: Drawing outside of the Paint cycle
« Reply #3 on: May 02, 2017, 03:24:52 pm »
I tried that as well.  Is there a way to force a partial rendering so the order of drawing can be controlled?  I draw the selection rectangle last in the paint block but it is only drawn above one of my items I have drawn on the window.  I recall reading somewhere that the driver/hardware may draw the rendering in the order it see fit for optimization.

Graeme

  • Hero Member
  • *****
  • Posts: 1431
    • Graeme on the web
Re: Drawing outside of the Paint cycle
« Reply #4 on: May 02, 2017, 04:11:39 pm »
I recall reading somewhere that the driver/hardware may draw the rendering in the order it see fit for optimization.
That would be very odd behaviour of LCL-Cocoa/Carbon then - and inconsistent with the other LCL-xxx widgetsets. Unfortunately I can't help with that. My suggestion is to also ask your question in the Lazarus mailing list. Not all LCL developers hang out in this web forum.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9283
  • FPC developer.
Re: Drawing outside of the Paint cycle
« Reply #5 on: May 02, 2017, 04:39:10 pm »
I tried that as well.  Is there a way to force a partial rendering so the order of drawing can be controlled?  I draw the selection rectangle last in the paint block but it is only drawn above one of my items I have drawn on the window.  I recall reading somewhere that the driver/hardware may draw the rendering in the order it see fit for optimization.

No, that sounds as something OpenGL, but the LCL has no concept of Z order, and doesn't keep drawing operations apart. The best you can do is either accelerate so much that it doesn't matter (with or without 3D API), or cache things by drawing to BMPs and use those in redraws with and without selection

JimKueneman

  • Full Member
  • ***
  • Posts: 189
Re: [Solved] Drawing outside of the Paint cycle
« Reply #6 on: May 03, 2017, 05:44:58 am »
Dooh,  I had a clipping problem.... Saved the Canvas State then restored it before drawing the selection rectangle at the end.

 

TinyPortal © 2005-2018