wiln / flexlib

Automatically exported from code.google.com/p/flexlib
0 stars 0 forks source link

flexlib.mdi.manager.MDIManager's center() method don't centralize correctly #213

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create an MDICanvas
2. create an MDIWindow
3. Try to add the MDIWindow instance to the MDICanvas instance's 
windowManager property using its addCenter method, so it internally will 
invoke the MDIManager.center() method to try to center the given MDIWindow

What is the expected output?
To have the MDIWindow instance centered inside the MDICanvas instance

What do you see instead?
MDIWindow instance is not centralized inside the MDICanvas instance

Suggested code to replace MDIManager.center() method:

public function center(window:MDIWindow):void
{
   window.x = this.container.width * 0.5 - window.width * 0.5;
   window.y = this.container.height * 0.5 - window.height * 0.5;
}

Original issue reported on code.google.com by macie...@gmail.com on 16 Apr 2009 at 2:18

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
and add the Math.round()
so the edge's don't bluers, if it hits a half pixel!

/**
 * Positions a window in the center of the available screen. 
 * 
 *  @param window:MDIWindow to center
 * */
public function center(window:MDIWindow):void
{
    window.x = Math.round(this.container.width / 2 - window.width / 2);
    window.y = Math.round(this.container.height / 2 - window.height / 2);
}

Original comment by catop...@gmail.com on 17 Aug 2009 at 8:27