Bug in Tbrush

Bug in Tbrush

Postby Enrico Maria Giordano » Tue May 31, 2011 2:53 pm

In brush.prg there is the following line:

Code: Select all  Expand view
if ( nAt := AScan( ::aBrushes, {|oBrush| Self == oBrush } ) ) > 0


But we can't compare brushes at this point because some of the properties of the current brush have not been assigned yet (ie. ::aGrad).

One of the results is that the new GRADIENT clause doesn't work if there are brushes already defined.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Tbrush

Postby nageswaragunupudi » Tue May 31, 2011 3:43 pm

Thanks for pointing out the bug.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bug in Tbrush

Postby nageswaragunupudi » Wed Jun 01, 2011 4:45 am

One of the results is that the new GRADIENT clause doesn't work if there are brushes already defined.


There seems to be no problem in creating any number of gradient brushes.

Code: Select all  Expand view

#include "fivewin.ch"

static aGrad1  := { { .4, CLR_BLUE, CLR_WHITE }, { .6, CLR_WHITE, CLR_BLUE } }
static aGrad2  := { { 0.50, 14853684, 16314573 }, { 0.50, 16314573, 14853684 } }
static aGrad3  := { { 0.25, RGB( 219, 230, 244 ), RGB( 207, 221, 239 ) },;
                    { 0.75, RGB( 201, 217, 237 ), RGB( 231, 242, 255 ) } }
static aGrad4  := { { 0.25, RGB( 255, 253, 222 ), RGB( 255, 231, 151 ) }, ;
                    { 0.75, RGB( 255, 215,  84 ), RGB( 255, 233, 162 ) } }

static aGrdBrush[ 4 ]

function Main()

   local oWnd, oBar

   DEFINE BRUSH aGrdBrush[ 1 ] GRADIENT aGrad1
   DEFINE BRUSH aGrdBrush[ 2 ] GRADIENT aGrad2
   DEFINE BRUSH aGrdBrush[ 3 ] GRADIENT aGrad3
   DEFINE BRUSH aGrdBrush[ 4 ] GRADIENT aGrad4

   ? Len( TBrush():aBrushes )

   DEFINE WINDOW oWnd BRUSH aGrdBrush[ 1 ] MDI ;
      TITLE "Gradient Brushes"

   DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32 2007
   DEFINE BUTTON OF oBar PROMPT "Child" ACTION NewChild()
   SET MESSAGE OF oWnd TO '' 2007

   ACTIVATE WINDOW oWnd

   ? Len( TBrush():aBrushes )

   AEval( aGrdBrush, { |o| o:End() } )

   ? Len( TBrush():aBrushes )

return nil

static function NewChild()

   static nBrush  := 1

   local oWnd

   nBrush   := If( nBrush == 4, 1, ++nBrush )

   DEFINE WINDOW oWnd MDICHILD OF WndMain() ;
      BRUSH aGrdBrush[ nBrush ]
   ACTIVATE WINDOW oWnd

return nil
 


Four gradient brushes are created and can be used and reused in any manner.

But the problem arises when new brushes are created with the same image with different resize modes, after creating a non-resizble brush with that image. This will be fixed.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bug in Tbrush

Postby Enrico Maria Giordano » Wed Jun 01, 2011 10:04 am

Please try:

Code: Select all  Expand view
  DEFINE BRUSH aGrdBrush[ 1 ] //GRADIENT aGrad1
   DEFINE BRUSH aGrdBrush[ 2 ] GRADIENT aGrad2
   DEFINE BRUSH aGrdBrush[ 3 ] GRADIENT aGrad3
   DEFINE BRUSH aGrdBrush[ 4 ] GRADIENT aGrad4


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Tbrush

Postby nageswaragunupudi » Wed Jun 01, 2011 10:00 pm

Thanks, Yes.
I noticed this too.
Fixed now.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bug in Tbrush

Postby Enrico Maria Giordano » Wed Jun 01, 2011 10:59 pm

Thank you. One more problem: ::nResizeMode is 0 by default. It should be 1.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in Tbrush

Postby nageswaragunupudi » Wed Jun 01, 2011 11:59 pm

This is the logic adopted:

nResizeMode is not relevant for solid and style brushes, but only to those which depend on bitmaps, including gradients.

Default mode for all bitmap brushes, except gradients, is TILED mode. nResizeMode = 0 is the default tiled mode. This is the traditional way. nResizeMode = 1 means STRETCH and nResizeMode = 2 means RESIZE. Optionally, one of these two modes can be selected in case of Images, at the time of creation of the brush. RESIZE mode retains the aspect ratio, while STRETCH does not. In case of RESIZE, one of the dimensions fits the window client size while the other may exceed.

Gradient brushes are always to be stretched, i.e., the entire window client area is to be filled. Size of the bitmap created is exactly the same as the client area of the window.

By default the gradient type is Vertical, which is represented by nResizeMode = 1 and optional HORIZONTAL mode is represented by 2. When a brush is created for gradient, we are setting the default to 1 ( vertical ) in the New() method, unless HORIZ clause is specified.

Hope this explains. Welcome your suggestions.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bug in Tbrush

Postby Enrico Maria Giordano » Thu Jun 02, 2011 8:00 am

No, what I'm trying to say is that the default for gradient brushes is currently 0 that means != 1 and therefore horizontal. Please test.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 118 guests