bugGNUstep - Bugs: bug #20057, rotated+translated text fields...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #20057: rotated+translated text fields display incorrectly

Submitted by:  Mark Tracy <tracy454>
Submitted on:  Sun 03 Jun 2007 03:28:09 AM UTC  
 
Category:  Gui/AppKit Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  Fred Kiefer <FredKiefer>
Open/Closed:  Closed

( Jump to the original submission)

Fri 30 Jan 2009 07:29:59 PM UTC, comment #12: 

no feedback ...presumably fixed

Richard Frith-Macdonald <CaS>
Project Member
Sun 23 Nov 2008 05:02:44 PM UTC, comment #11: 

Changed this bug report to in test as all known cases where we handled this wrongly should now be resolved.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Tue 11 Nov 2008 08:19:39 PM UTC, comment #10: 

I put in an improved version of the code below, this should now correct all combinations of bounds trnaslation and bounds rotation. Still setting bounds in rotated view is not correct and the relationship of bounds and frames in the rotated case will need more work.
For that reason I leave this open.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Sun 09 Nov 2008 12:29:45 AM UTC, comment #9: 

Last summer I made some more progress not documented here an I was even able to reproduce the behaviour cited below. Still more complex combination of rotation and translation where still wrong.
Now I am trying to get an application working that has views rotated by 90 degrees and this completely fails.

After experimenting on my Apple I came up with code that works somewhat better, but it still isn't completely correct. It looks like the code would be simpler when implementing setBoundsOrigin: based on translateOriginToPoint:.

I put the code here for future reference:

- (void) setBoundsOrigin: (NSPoint)newOrigin
{
  if (_is_rotated_from_base)
    {
      NSAffineTransform *matrix;
      NSRect frame = _frame;
      NSPoint offset;

      frame.origin = NSMakePoint(0, 0);
      if (_coordinates_valid)
        {
          (*invalidateImp)(self, invalidateSel);
        }
      if (_boundsMatrix == nil)
        {
          _boundsMatrix = [NSAffineTransform new];
          offset = NSMakePoint(NSMinX(_bounds), NSMinY(_bounds));
        }
      else
        {
          matrix = [_boundsMatrix copy];
          [matrix invert];
          offset = [matrix transformPoint: NSMakePoint(0, 0)];
          RELEASE(matrix);
      }
      NSLog(@"Translate by %g, %g", -newOrigin.x + offset.x, -newOrigin.y + offset.y);
      [_boundsMatrix translateXBy: -newOrigin.x + offset.x
                     yBy: -newOrigin.y + offset.y];     
//      [_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];

     // Adjust bounds
      matrix = [_boundsMatrix copy];
      [matrix invert];
      [matrix boundingRectFor: frame result: &_bounds];
      RELEASE(matrix);
      [self resetCursorRects];
      if (_post_bounds_changes)
        {
          [nc postNotificationName: NSViewBoundsDidChangeNotification
              object: self];
        }
    }
  else if (NSEqualPoints(_bounds.origin, newOrigin) == NO)
    {
      if (_coordinates_valid)
        {
          (*invalidateImp)(self, invalidateSel);
        }
      _bounds.origin = newOrigin;
      if (_boundsMatrix == nil)
        {
          _boundsMatrix = [NSAffineTransform new];
        }
      [_boundsMatrix setFrameOrigin: NSMakePoint(-newOrigin.x, -newOrigin.y)];
      [self resetCursorRects];
      if (_post_bounds_changes)
        {
          [nc postNotificationName: NSViewBoundsDidChangeNotification
              object: self];
        }
    }
}

- (void) translateOriginToPoint: (NSPoint)point
{
  NSPoint offset;

  

  if (_boundsMatrix == nil)
    {
      offset = NSMakePoint(NSMinX(_bounds), NSMinY(_bounds));
    }
  else
    {
      NSAffineTransform *matrix;
      NSRect frame = _frame;

      frame.origin = NSMakePoint(0, 0);
      matrix = [_boundsMatrix copy];
      [matrix invert];
      offset = [matrix transformPoint: NSMakePoint(0, 0)];
      RELEASE(matrix);
    }

  

  [self setBoundsOrigin: NSMakePoint(offset.x - point.x,
                                     offset.y - point.y)];
//  [self setBoundsOrigin: NSMakePoint(NSMinX(_bounds) - point.x,
//      NSMinY(_bounds) - point.y)];
}

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Wed 04 Jul 2007 12:05:11 PM UTC, comment #8: 

I made some progress here. With the text field now flipped as on MacOSX the bounds rotation works in the same direction, but the mixing of rotation and translation of bounds is still broken.

I must admit I am a bit glueless what goes on here. Rotating the bounds on Cocoa give {{0, -39.0817}, {163.196, 103.799}} (and almost the same on GNUstep). Adding a bounds translation {5, 5} to this gives a bounds of {{5, -73.1634}, {163.196, 103.799}}. This surely makes some sense, I just don't see it.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Fri 29 Jun 2007 11:53:35 AM UTC, comment #7: 

OK, even after a hack to get rotated text working for the cairo backend there is still a lot to do.

Rotation the bounds seems to work the wrong way round and combining bounds rotation and translation gives unexpected results.

Therfore I switch the state of the bug report back to open.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Thu 28 Jun 2007 05:35:52 PM UTC, comment #6: 

I think, I was able to fix most of this problem in SVN. What still remains is the broken rotated text drawin in the cairo backend (I broke this when moving away from using cairo transformations) and the missing bounds translation.

The later seems to be a rather deep problem of all our cells, they expect that the frame rectangle they get for drawing is the whole frame. I don't have any idea on how to fix that.

Could you please test the behaviour from SVN and report on the result?

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Wed 27 Jun 2007 12:24:42 PM UTC, comment #5: 

I made some tests myself and the whole mechanism of doing frame and bounds transformation in GNUstep seems to be wrong, not just the rotation case. For example even a simple translate on bounds produces a wrong result.

Looking at the code I think that implementing a correct solution is easy, as soon as we are able to define, what consitutes a correct solution :-(

One question is, if _frameMatrix and _boundsMatrix should include the translation element or not. Currently this is handled inconsistently in the code.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Mon 25 Jun 2007 10:45:27 AM UTC, comment #4: 

I misunderstood this ... and now I'm starting to suspect that the use of bounds and the transofrmation matrix betweek frame and bounds is quite buggy in gui/back.

Richard Frith-Macdonald <CaS>
Project Member
Sat 23 Jun 2007 07:24:30 AM UTC, comment #3: 

It still does not work for me. I have included an updated TestApp3.tgz source code to demonstrate the bug; it works as expected in Cocoa.

Also, try alternately translating and rotating the bounds. The text shrinks. Again, this is not the behavior in Cocoa.

(file #13142)

Mark Tracy <tracy454>
Fri 22 Jun 2007 10:04:08 AM UTC, comment #2: 

I think I have fixed this in svn trunk, but I don't have a testcase written for it ... could you please try it and let me know if the new code is OK?

Richard Frith-Macdonald <CaS>
Project Member
Thu 21 Jun 2007 08:13:10 AM UTC, comment #1: 

I have a work-around. After either [aTextField setFrameRotation: anAngle] or [aTextField setFrame: aRect] add a dummy bounds rotation [aTextField setBoundsRotation: [aTextField boundsRotation]]

Mark Tracy <tracy454>
Sun 03 Jun 2007 03:28:09 AM UTC, original submission:  

When the frame of an NSTextField is rotated and translated, the field displays incorrectly, or not at all. If it is rotated only or translated only the display is OK. The bug happens when trying to do both. This seems to be due the the bounds not following the frame. Also, rotating or translating the bounds seem to give unexpected results. This occurred in gui-1.12, and is still present in trunk 25214; gui-1.11 did not do this. This happens with both the art and cairo backends, but the symptoms are slightly different. Even setting a frame rotation of 0.00 triggers the bug. See TestApp3 for a demonstration of the bug.

System: Suse 10.2 running on Parallels VM over OSX; GNUstep trunk 25214

Mark Tracy <tracy454>

 

Attached Files
file #13142:  TestApp3.tgz added by tracy454 (6KiB - application/x-compressed-tar - slightly improved over original)
file #12941:  TestApp3.tgz added by tracy454 (6KiB - application/x-compressed-tar)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 13 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-01-30 CaS Open/ClosedIn Test => Closed
    2008-11-23 FredKiefer StatusIn Progress => Fixed
        Open/ClosedOpen => In Test
    2007-06-29 FredKiefer Open/ClosedIn Test => Open
    2007-06-28 FredKiefer StatusConfirmed => In Progress
        Assigned toNone => FredKiefer
        Open/ClosedOpen => In Test
    2007-06-25 CaS StatusFixed => Confirmed
        Open/ClosedIn Test => Open
    2007-06-23 tracy454 Attached File- => Added TestApp3.tgz, #13142
    2007-06-22 CaS StatusNone => Fixed
        Open/ClosedOpen => In Test
    2007-06-03 tracy454 Attached File- => Added TestApp3.tgz, #12941

    Back to the top


    Powered by Savane 3.5