bugGNUstep - Bugs: bug #27930, Offsetting a subview breaks when...

Group
 
 

bug #27930: Offsetting a subview breaks when the parent view is resized

Submitter:  Derek Fawcus <dfawcus>
Submitted:  Wed 04 Nov 2009 01:02:40 AM UTC
   
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  Bug Status:  Invalid
Privacy:  Public Assigned to:  FredKiefer
Open/Closed:  Declined
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 05 Nov 2009 08:17:48 AM UTC, comment #3: 

I remember to have encountered a similar issue based on the fact the origin of the content view is zero on Mac OS X but not on GNUstep, as you said it isn't easy to track down.
When you think about it it's logical to have a zero origin because the window have no bottom border at all on Mac OS X by default. However iirc the weird thing I have observed is that if you set a custom bottom border with -setContentBorderThickness:forEdge:, the content view still reports (0, 0) as its origin which looks like a Cocoa bug to me.

Quentin Mathé <qmathe>
Group Member
Thu 05 Nov 2009 07:55:39 AM UTC, comment #2: 

It took me some time to pin down the problem in your code. In the end it turned out to be quite simple. In your _adjustFrameHeightForNewFrame: method you set the origin of the subview relative to the origin of the super view:

ourFrame.origin.y = newFrame.origin.y + _offset;

This is always wrong, as these two frames are in different coordinate systems. The correct code looks like this:

ourFrame.origin.y = _offset;

Why did it work on Apple but fail on GNUstep? Apple seems to have the origin of the content view always at (0, 0). This is not true for GNUstep.

But then there isn't any reason for all your special code. Just set the offset of your view once when you create it and make the height resizable as well, that way the system should keep track of all this computation.

Fred Kiefer <FredKiefer>
Group Member
Wed 04 Nov 2009 02:22:11 AM UTC, comment #1: 

and I've found a workaround...

My code replaces the window content view with the new main view,
if instead the main view is itself set as a subview of the pre-existing content view,  things work as expected.

i.e. in the sample code,  in do_window(),  replace
        [window setContentView: mainView];
with
        [[window contentView] addSubview:mainView];

Which may give a hint as to what is happening.

Derek Fawcus <dfawcus>
Wed 04 Nov 2009 01:02:40 AM UTC, original submission:  

I am trying to set up two NSViews,  one a subview of the other.
The subview is to track the width of the parent,  but is to be constantly shorter than the height,  and offset vertically,
such that there is a portion of the parent always visible under then child.

The attached program exhibits a failure with gui/back 0.16 (and base 1.18) as packaged on Mandriva 2009.1,  however it operates correctly on OSX 10.4.11;  the offset is initially seen to be correct,  but upon resize occuring it is doubled.

Derek Fawcus <dfawcus>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #18985:  offset.tar.gz added by dfawcus (5KiB - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by qmathe (Posted a comment)
  • -email is unavailable- added by FredKiefer (Posted a comment)
  • -email is unavailable- added by dfawcus (Submitted the item)
  • -email is unavailable- added by dfawcus
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-11-05 FredKiefer StatusNone Invalid
        Assigned toNone FredKiefer
        Open/ClosedOpen Declined
    2009-11-04 dfawcus Carbon-Copy- Added dfawcus
        Attached File- Added offset.tar.gz, #18985

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code