GradientBrush and drawText


#1

Hello,
I’ve just pulled the latest tip from the git repository and all my text drawing code stopped working. I’m using a GradientBrush to fill the text.

[code] Font f (T(“Arial”), (float)getHeight(), Font::bold);
g.setFont (f);

GradientBrush mainGradient (Colour (0xff848484),
	0.0f,
	0.0f,
	Colours::black,
	0.0f,
	(float)getHeight(),
	false);

g.setBrush (&mainGradient);

g.drawText (getName(),
	0, 
	0, 
	getWidth(),
	getHeight(),
	Justification::left,
	true);[/code]

On the other hand, mouse rollovers and the Text Editor are working in Logic 8 now!

Thanks


#2

The above code just fills the text with a black colour.


#3

Yes, sorry - am in the middle of refactoring all the graphics code, and that’s something that I was in the middle of messing with. Will have it working again in the my check-in.


#4

AHHH! What happened?
The gradient works now, but now all the images that I was drawing are mangled to shit, and I got some weird line drawing stuff going on…

I’m not a git expert… What is the command to go back a few commits/versions? Or is downloading a snapshot from sourceforge the best bet.


#5

Presumably you’re using a Mac - can you let me know what’s failing, and I’ll get it sorted out?


#6

Yes I’m using a mac… Here are some snapshots:

Before:

After:


#7

Thanks. If you want a quick fix, just turn off USE_COREGRAPHICS_RENDERING in juce_mac_NSViewComponentPeer

Looks like I’ve just got my bits reversed in the image rendering, which is easy to fix. I don’t know what’s happening with that line above “most downloaded”, though - how are you drawing that?


#8

drawHorizontalLine stuff is drawing the lines in the wrong place (looks like the y position is wrong).

That is done in TabBarButton::paintButton:

[code]buttonHeight = getHeight() * 0.80f;

g.setColour (Colours::white);
g.drawHorizontalLine (0, 0, getWidth());

g.setColour (Colour (0xffbebebe));
g.drawHorizontalLine (buttonHeight - 1, 0, getWidth());[/code]

Looks like it’s reversed… The white line should be on the very top. the grey-ish one should be on the bottom edge there. The proportions (visually) are correct as far as the distances between the two lines go, but I’m a little puzzled on how it flipped.

[EDIT]
Don’t pay attention to the grey line that’s missing where “top rated” is, that’s another rect on top of it for other reasons…


#9

So here is another drawHorizontalLine example that’s wrong.

The white rectangle below the title bar is a component:

g.setColour(Colours::red); g.drawHorizontalLine (getHeight() - 10, 0, getWidth());

and when set y to 0:

g.setColour(Colours::red); g.drawHorizontalLine (0, 0, getWidth());

Sorry about the verboseness, just trying to crear it up for myself here. You probably know whats happening.


#10

Thanks very much for that, I’d not tested the drawHorizontalLine stuff. It’s a trivial fix, in juce_CoreGraphicsContext.mm:

void drawHorizontalLine (const int y, double left, double right) { CGContextFillRect (context, CGRectMake (left, flipHeight - (y + 1.0f), right - left, 1.0f)); }

And I don’t know if you noticed, but I checked in a fix for the image loading stuff last night. Hopefully that should sort you out!

The drawing’s all done with CoreGraphics on the mac now - your app’s pretty graphically heavy, so has it made it noticably faster or slower?


#11

Yes I saw that… I had a handful of these, so for the moment I changed all my drawHorizontalLine business to fillRect.

Yes, I saw that yesterday… Thank you very much for that.

I’ve been using the latest tip during my dev, so haven’t noticed any significant speed differences, although I’m noticing that images (pngs jpgs) look cleaner/sharper on the mac. My friend says it responds better, but he’s testing the AU.

Also my 2D coverflow control takes more cpu on the mac then it does on the pc. Still working on it… It animates when you scroll and the reflections get updated with another component that listens to movement/resizing etc. (So it makes heavy use of image, animation, etc)

On PC it takes about 10-15% on the Mac 35-40% (Same machine using boot camp Snow Leopard/Vista).

Thanks


#12