9
$\begingroup$

While preparing a dynamic module, I discovered a weird behaviour of Mathematica's controls when you rotate them:

Rotate[Button["Toto", Null], 0]
Rotate[Button["Toto", Null], 0.01]
Rotate[Button["Toto", Null], 0.02]

enter image description here

The first non-rotated button has standard Mac OS styling. The last one, for large enough rotation, uses a non-native styling, which is somewhat ugly. But the real surprise is that controls with small enough rotation are displayed with native styling (and it is actually rotated, not just rounded down to the case of the non-rotated button).

My point of view is that, while I can live with the ugliness of non-native buttons, I'd rather have uniformity between all my controls. So, my question is two-fold:

  • How can I force rotated controls to be displayed with native styling?
  • If that's not possible, how can I force non-rotated controls to be displayed with non-native styling?
$\endgroup$
7
$\begingroup$

You can use the Style setting ControlRendering to display controls in their generic form:

Rotate[Style[Button["Toto", Null], ControlsRendering -> "Generic"], 0]

If you don't see the bottom line you need to set the Buttons ImageMargins:

Rotate[Style[Button["Toto", Null, ImageMargins -> 1], 
  ControlsRendering -> "Generic"], 0.0]
$\endgroup$
2
  • $\begingroup$ This sounds like what I was looking for, but it doesn't work for me (Mac OS 10.8, MMA 8.0.4.0) because the bottom border of the button isn't drawn :( $\endgroup$
    – F'x
    Sep 4 '12 at 8:45
  • $\begingroup$ Adding ImageMargins option will make the line visible. $\endgroup$
    – Matariki
    Sep 4 '12 at 9:14
4
$\begingroup$

Maybe something like this:

 Rotate[Framed[
  Button["Toto", Null, Appearance -> "Frameless", 
   BaseStyle -> {"GenericButton", 16, Bold}], RoundingRadius -> 5, 
  Background -> GrayLevel[.95]], 0]
 Rotate[Framed[
  Button["Toto", Null, Appearance -> "Frameless", 
   BaseStyle -> {"GenericButton", 16, Bold}], RoundingRadius -> 5, 
  Background -> GrayLevel[.95]], 0.01]
 Rotate[Framed[
  Button["Toto", Null, Appearance -> "Frameless", 
   BaseStyle -> {"GenericButton", 16, Bold}], RoundingRadius -> 5, 
  Background -> GrayLevel[.95]], 0.02]

enter image description here

$\endgroup$
2
  • $\begingroup$ Hum, drawing my own controls… why not? The only downside I see in my first tries is that it makes the clickable area slightly smaller. $\endgroup$
    – F'x
    Sep 4 '12 at 8:46
  • $\begingroup$ @F'x You can probably increase the clickable area with the Button option FrameMargins. $\endgroup$
    – VLC
    Sep 4 '12 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.