CPSegmentedControl drawing bug #1213

Closed
nigelgoodship opened this Issue Apr 7, 2011 · 17 comments

Comments

Projects
None yet
7 participants

The right-most segment of a CPSegmentedControl is being drawn with less than its fair share of space between the label text and the right edge.

Owner

aljungberg commented Apr 7, 2011

Do you have a screenshot/reduction?

Hi,

Further to my reply on GitHub, I can however attach an image to an email! :-)

Note that the margin to the right of "Update" is smaller than the other margins on the segments. I have another segmented control in the app that shows the same problem.

Regards,

Nigel

On 7 Apr 2011, at 18:06 , aljungberg wrote:

Do you have a screenshot/reduction?

Reply to this email directly or view it on GitHub:
https://github.com/280north/cappuccino/issues/1213#comment_969848

Owner

aljungberg commented Apr 7, 2011

But unfortunately GitHub stripped out the attachment before forwarding the email to me. :)

There's a screenshot here:
http://dl.dropbox.com/u/25610745/CPSegmentedControlError.png

The margin to the right of "Update" is a little smaller than all the others. Not a huge deal, but my boss has commented on it. :-)

Owner

aljungberg commented Apr 7, 2011

Yes that looks wrong. How did you make that happen? Can you recreate it using the Tests/Manual/CPTabView test as a base?

OK, good suggestion. I've adapted the Tests/Manual/CPTabView2 test to create a simple CPSegmentedControl and it doesn't show the problem. I guess I should have mentioned that my segmented control came from an NSSegmentedControl via nib2cib. I've taken a look at NSSegmentedControl.j in the nib2cib source and it's setting the frame width to be the same as the original in InterfaceBuilder. This is clearly not quite right with the change to Aristo. I'll take a look at improving the nib2cib code, unless someone more expert than me could take that on? (Probably need to add a pixel or two per segment to the frame width.)

Update: on looking more closely at the result of creating a CPSegmentedControl in code, I think the right margin of the last segment might be a pixel short, which might be related to the observed problem by being amplified somehow by the wider margins coming from the nib? Hard to tell, though. Here's a screen grab: http://dl.dropbox.com/u/25610745/CPSegmentedControlTest.png

I've tried a few experiments in the nib2cib NSSegmentedControl.j code but without any practical conclusion. Much seems to depend on the styling (eg font) changes between Apple's UI in the nib and the Aristo theme. By its own admission, the code that tiles the segmentItems and sizes the frame is a hack.

I've fixed the problem in my app with the following additional hack, placed in awakeFromCib:

var theFrame = [theSegmentedControl frame];
[theSegmentedControl setFrame:
CGRectMake(theFrame.origin.x - [theSegmentedControl segmentCount] / 2.0,
theFrame.origin.y,
theFrame.size.width + [theSegmentedControl segmentCount],
theFrame.size.height)];

This seems to produce a perfect result. :-)

I fear I'll have to leave any conclusions or further actions in this issue to those far more expert and experienced than me.

@ghost

ghost commented Aug 19, 2011

http://oi56.tinypic.com/f0dwsh.jpg

I'm experiencing the same issue on 0.9.

cappbot commented May 9, 2012

Label: #new. What's next? A reviewer should examine this issue.

Contributor

ahankinson commented Feb 14, 2013

I think this is still an issue. I'm attaching a screenshot of a segmented control in IB and as rendered in Safari. The right-most segment seems to be out of alignment.

SegmentedAlignment

-#new
+#acknowledged
+bug
+Theme
milestone=1.0

cappbot commented Feb 14, 2013

Milestone: 1.0. Labels: #acknowledged, Theme, bug. What's next? A reviewer should examine this issue.

Contributor

BlairDuncan commented Feb 14, 2013

When this issue was originally created the rightmost segment had no space at all between its title and the right edge. It was corrected and is much better but still needs a bit more space to be visually correct.

Contributor

ahankinson commented Feb 14, 2013

In @nigelgoodship's comment (#1213 (comment)) there is still a bit of space on the right, but looking at his screenshot and the one I just posted it seems that the spacing is pretty similar.

Contributor

daboe01 commented Nov 26, 2014

the spacing seems to be quite ok in the current master.
+#fixed

cappbot commented Nov 26, 2014

Milestone: 1.0. Labels: #fixed, Theme, bug. What's next? This issue is considered successfully resolved.

@cappbot cappbot added #fixed and removed #acknowledged labels Nov 26, 2014

cappbot closed this Nov 26, 2014

Member

Dogild commented Nov 26, 2014

Probably fixed by #2226

cappbot commented Nov 26, 2014

Milestone: 1.0. Labels: #fixed, Theme, bug. What's next? This issue is considered successfully resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment