[haiku-development] Re: RoundRect ButtonFrame

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Mon, 19 Mar 2012 22:11:38 +0100

Am 19.03.2012 21:46, schrieb John Scipione:
On Mon, Mar 19, 2012 at 4:42 PM, Clemens Zeidler
<clemens.zeidler@xxxxxxxxxxxxxx>  wrote:
just a quick guess but why not implement it in:
http://haiku.it.su.se:8180/source/xref/src/kits/interface/ControlLook.cpp#DrawButtonFrame

Just derive from BControlLook and change it there. Then set be_control_look
to point to your derived class, right?

Clemens,

That is what I am proposing, to implement the feature it in
ControlLook. I am asking for help on how to implement the feature as
it is not obvious to me after a cursory attempt.

There is already an implementation of rounded corners in BControlLook. It's used for the BTab rendering. The code has to handle a lot of corner cases including support for transparent button frames, that is why it may not be as straight forward as you may have hoped. But when you follow it closely, you should see how it works exactly. IIRC, you need to replicate the code for drawing the left/bottom and right/bottom corners, since tabs currently only need the left/top and right/top corner. It shouldn't be too hard to reuse the tab rendering for button frames. However, BControlLook separates button frame rendering from button background rendering. It may indeed be best to use a flag in both DrawButtonBackground() and DrawButtonFrame() and pass the flag from BButton, so you don't break other interface elements that use only one of DrawButtonFrame() and DrawButtonBackground() and combine it with a different background/frame that does not expect round corners.

Best regards,
-Stephan

Other related posts: