deanbrowne / j4me

Automatically exported from code.google.com/p/j4me
1 stars 1 forks source link

Wrong absolute component location #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

the x,y location store at component level before each paint are wrong in
case of children component, because the current translation is not apply.

In that case, calling the repaint() method will not refresh the entire
component.

Fix proposal in Component.paint 

this.x = g.getTranslateX() + x;
this.y = g.getTranslateY() + y;

instead of 

this.x = x;
this.y = y;

Cheers
Jean-Marie

Original issue reported on code.google.com by jmherme...@gmail.com on 14 Feb 2008 at 10:57

GoogleCodeExporter commented 9 years ago
That's was not solving my problem in all cases. 

Because the DeviceScreen.repaint method (called by Component.repaint), add an Y
offset in case of having a  Title Bar. 

Now that I store in Component.x and Component.y  the absolute location, then 
this
shifting is not wanted anymore 

All  is fine now using the following code in DeviceScreen

public void repaint (int x, int y, int width, int height)
    {
//      if ( hasTitleBar() )
//      {
//          // Offset the user's y by the height of the title bar.
//          Theme theme = UIManager.getTheme();
//          int titleHeight = theme.getTitleHeight();
//          y += titleHeight;
//      }

        slave.repaint( x, y, width, height );
    }

note that I must also Ignore the titleHeight translation on Pointer Events

in DeviceScreen.pointerPressed : 

    if ( processed == false )
        {
            // Adjust the press location to fit in the canvas area.
            int py = y;

//          if ( hasTitle )
//          {
//              py -= theme.getTitleHeight();
//          }

            // Forward the event.
            master.pointerPressed( x, py );
        }

        // Continue processing the pointer event.
        super.pointerPressed( x, y );   

Original comment by jmherme...@gmail.com on 14 Feb 2008 at 1:45

GoogleCodeExporter commented 9 years ago
Related to components contained within each other.  This will be a J4ME 1.1 
issue.

Original comment by deanbro...@gmail.com on 8 Mar 2008 at 1:28

GoogleCodeExporter commented 9 years ago

Original comment by deanbro...@gmail.com on 8 Mar 2008 at 1:29