4
$\begingroup$

Bug introduced in 10 or earlier and persisting through 11.0.0


When content is larger than ImageSize of TabView then the top edge is cut off even with Alignment->{Left,Top}.

SetterBar[Dynamic@horizontalAlignment, {Left, Right}]
SetterBar[Dynamic@verticalAlignment, {Bottom, Top}]


TabView[{
  1 -> Framed[RandomImage[1, {100, 100}, ImageSize -> 200], FrameStyle -> Red]
  },
 ImageSize -> {90, 90} ,
 Alignment -> Dynamic@{horizontalAlignment, verticalAlignment}]

enter image description here

I expect that the red frame edge should be visible. The only one setting which is respected is Left.

Is this OS specific?

related: 44690

Tested on Win7 V10.0.2

$\endgroup$
  • 1
    $\begingroup$ Same with my v10.0.2 & v9.0.1 on OSX 10.9.5. $\endgroup$ – SquareOne Mar 4 '15 at 9:44
  • $\begingroup$ Actually, it seems to concern only the contents which have been defined with the option ImageSize. When this option is missing, the image in TabView is not clipped but rescaled to be fully visible. For example, try instead : {1 -> Framed[RandomImage[1, {200, 200}], FrameStyle -> Red]}. Or am I missing something ? $\endgroup$ – SquareOne Mar 4 '15 at 14:37
  • $\begingroup$ Yes it was clear to me that we are not talking about contents like Grid but like images or graphics. Once again, in my example : {1 -> Framed[RandomImage[1, {200, 200}], FrameStyle -> Red]}, the random image is 200x200, it is larger than the display area 90x90, but it is not clipped but scaled down to fit the display. I am just saying that TabView behaves differently whether graphics content were defined with ImageSize or not. It is complementary to your observations. $\endgroup$ – SquareOne Mar 4 '15 at 15:13
  • $\begingroup$ Observe also the difference between : 1 -> RandomImage[1, {200, 200}] and 1 -> Show@RandomImage[1, {200, 200}]. The first is an Image, the second is a Graphics, both have 200x200 but display differently in TabView. $\endgroup$ – SquareOne Mar 4 '15 at 15:15
  • $\begingroup$ @SquareOne Sorry, I missed your point. Yes you are right, the behaviour is different. But I can live with this, unless I set options explicitly I can't expect it will always fit my expectation. My question is about unexpected results when options are not leaving any interpretation to MMA. It is just a bug, imo. $\endgroup$ – Kuba Mar 4 '15 at 22:18
3
$\begingroup$

Quick fix is to use

Pane[#, ImageMargins -> {{0, 10}, {5, 5}}] &

on tabs contents.

enter image description here

Not convenient but working. Probably also OS dependent solution...

To not copy this I'm using a function which can be used directly on TabView:

tabViewFix1 = Function[tabView,
     MapAt[
        Pane[#, ImageMargins -> {{0, 10}, {5, 5}}] &,
        tabView,
        {1, All, 2}
     ]
]

Edit: WRI confirmed it is misbehaving:

[...] It does appear that the Alignment option in TabView is not behaving properly in this case and I have forwarded an incident report to our developers with the information you provided. In the meantime, depending on your program, it may be possible for you to use the option ImageMargins to make the margins bigger, this seems to allow the frame to become visible in all alignment scenarios. The ImageMargins option can be used as in the following example:

SetterBar[Dynamic@horizontalAlignment,{Left,Right}]
SetterBar[Dynamic@verticalAlignment,{Bottom,Top}]
TabView[{1->Framed[RandomImage[1,{100,100},ImageSize->200],FrameStyle->Red, ImageMargins->7]},ImageSize->{90,90},Alignment->Dynamic@{horizontalAlignment,verticalAlignment}]
$\endgroup$
  • 1
    $\begingroup$ The ImageMargins workaround works for me also if I use it directly in Framed, and according to my tests these margins needs to be >= 6. For example : Framed[RandomImage[1, {100, 100}, ImageSize -> 200], ImageMargins -> 6, FrameStyle -> Red] $\endgroup$ – SquareOne Mar 4 '15 at 9:49
  • $\begingroup$ @SquareOne sure, the problem is that the content can be arbitrary and will be cut off. I used Framed to show the issue. I mean, not everything has ImageMargins option. $\endgroup$ – Kuba Mar 4 '15 at 9:50
  • $\begingroup$ Allright, it did not understand the problem was the cut off of the content. Instead of a RandomImage, maybe you should take some image with one (red) pixel border frame to show the cut off ? $\endgroup$ – SquareOne Mar 4 '15 at 9:56
  • $\begingroup$ @SquareOne I added a short explanation at the top of the question. Is this ok or do you insist on different example? $\endgroup$ – Kuba Mar 4 '15 at 10:04

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.