Ticket #1968: pwa-centering-imre.patch

File pwa-centering-imre.patch, 46.7 KB (added by pap, 15 years ago)

Patch with changes made in the implementation review

  • modules/org.sophie2.main.app.halos/src/main/java/org/sophie2/main/app/halos/frame/rotate/FrameRotateHaloButton.java

    ### Eclipse Workspace Patch 1.0
    #P sophie
     
    2020import org.sophie2.base.scene.interfaces.Scene; 
    2121import org.sophie2.base.skins.SkinElementId; 
    2222import org.sophie2.base.visual.skins.VisualElementDef; 
     23import org.sophie2.main.app.commons.PageAreaMouseCapture; 
    2324import org.sophie2.main.app.commons.frame.FrameView; 
    2425import org.sophie2.main.app.commons.page.PageWorkArea; 
    2526import org.sophie2.main.app.halos.common.AppHaloUtil; 
     
    4849                final FrameH frame = frameView.model().get(); 
    4950                final double oldAngle = frame.getRotationAngle(); 
    5051 
    51                 PageWorkArea pwa = AppHaloUtil.getWorkArea(this); 
     52                final PageWorkArea pwa = AppHaloUtil.getWorkArea(this); 
    5253                final Scene scene = pwa.scene().get(); 
    5354                final ImmMatrix sceneToParent = SceneHelper.getElementToSceneTransform(scene, 
    5455                                frameView.parent().get().sceneElement().get()).inverse(); 
     
    6869                final ImmPoint oldControl = sceneToParent.transform(controlInScene); 
    6970 
    7071                final SceneVisual sceneVisual = pwa.sceneVisual().get(); 
    71                 sceneVisual.wantedViewRect().set(sceneVisual.actualViewRect().get()); 
     72                sceneVisual.wantedViewRect().set(sceneVisual.lastViewRect().get()); 
    7273                 
    73                 return new MouseCapture(0, 0, e) { 
     74                return new PageAreaMouseCapture(0, 0, e) { 
    7475 
    7576                        @Override 
    7677                        public void shouldMove(int newX, int newY) { 
     
    8586                        } 
    8687 
    8788                        @Override 
    88                         public void released() { 
     89                        public void onReleased() { 
    8990                                final Double angle = frame.getRotationAngle(); 
    9091                                setAngle(angle, true); 
    9192                                sceneVisual.wantedViewRect().set(null); 
     
    144145 
    145146                        } 
    146147 
     148                        @Override 
     149                        public PageWorkArea getWorkArea() { 
     150                                return pwa; 
     151                        } 
     152 
    147153                }; 
    148154        } 
    149155 
  • modules/org.sophie2.base.commons/src/main/java/org/sophie2/base/commons/util/position/ImmRect.java

     
    336336        public boolean contains(ImmRect other) { 
    337337                return this.toRectangle().contains(other.toRectangle()); 
    338338        } 
     339 
     340        /** 
     341         * Creates rectangle by given point and size. The given point is the center 
     342         * point for the rectangle. The size is the size of the rectangle. 
     343         *  
     344         * @param centerPoint 
     345         *            The center of the rectangle. 
     346         * @param size 
     347         *            The size of the rectangle. 
     348         * @return New rectangle. 
     349         */ 
     350        public static ImmRect create(ImmPoint centerPoint, ImmSize size) { 
     351                ImmPoint topLeft = new ImmPoint(centerPoint.getX() - size.getWidth()/2,  
     352                                centerPoint.getY() - size.getHeight()/2); 
     353                ImmRect res = new ImmRect(topLeft, size); 
     354                 
     355                return res; 
     356        } 
    339357} 
  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/PageAreaMouseCapture.java

     
     1package org.sophie2.main.app.commons; 
     2 
     3import java.awt.event.MouseEvent; 
     4 
     5import org.sophie2.base.commons.gui.MouseCapture; 
     6import org.sophie2.main.app.commons.page.PageWorkArea; 
     7 
     8/** 
     9 * Modified {@link MouseCapture} for {@link PageWorkArea}. 
     10 *  
     11 * @author tanya 
     12 */ 
     13public abstract class PageAreaMouseCapture extends MouseCapture { 
     14 
     15        /** 
     16         * Initiates capture.   
     17         * @param initCompX The current X coordinate of the component. 
     18         * @param initCompY The current Y coordinate of the component. 
     19         * @param e The mouse event initiating the capture. 
     20         */ 
     21        public PageAreaMouseCapture(int initCompX, int initCompY, MouseEvent e) { 
     22                super(initCompX, initCompY, e); 
     23                getWorkArea().scrollsLocked().set(Boolean.TRUE); 
     24        } 
     25         
     26        @Override 
     27        final public void released() { 
     28                onReleased(); 
     29                getWorkArea().scrollsLocked().set(Boolean.FALSE); 
     30        } 
     31         
     32        /** 
     33         * Called when the user has released the mouse button. Should be overrided and called in the {@link #released()}. 
     34         */ 
     35        public abstract void onReleased(); 
     36         
     37        /** 
     38         * Returns the {@link PageWorkArea} over which the {@link MouseCapture} is performed. 
     39         *  
     40         * @return {@link PageWorkArea} 
     41         */ 
     42        public abstract PageWorkArea getWorkArea(); 
     43} 
     44 No newline at end of file 
  • modules/org.sophie2.base.layout/src/test/java/org/sophie2/base/layout/model/LayoutDemo.java

     
     1package org.sophie2.base.layout.model; 
     2 
     3import java.awt.BorderLayout; 
     4 
     5import javax.swing.JDesktopPane; 
     6import javax.swing.JFrame; 
     7import javax.swing.JInternalFrame; 
     8import javax.swing.JLayeredPane; 
     9 
     10/** 
     11 * Demo for demonstrating the usage of {@link CustomLayout}. 
     12 * @author tanya 
     13 */ 
     14public class LayoutDemo { 
     15 
     16        /** 
     17         * Constructor that creates {@link JFrame}, adds a {@link JDesktopPane} with 
     18         * {@link CustomLayout} and set different layers to be with different 
     19         * layouts. 
     20         */ 
     21        public LayoutDemo() { 
     22                 
     23                JFrame frame = new JFrame(); 
     24                frame.setSize(300, 300); 
     25                frame.setVisible(true); 
     26                 
     27                JDesktopPane pane = new JDesktopPane(); 
     28                 
     29                frame.setContentPane(pane); 
     30                pane.setLayout(new CustomLayout(new BorderLayout())); 
     31                 
     32                JInternalFrame frame1 = new JInternalFrame(); 
     33                frame1.setLocation(10, 10); 
     34                frame1.setSize(90, 90); 
     35                frame1.setVisible(true); 
     36                 
     37                pane.setLayer(frame1, JLayeredPane.DEFAULT_LAYER); 
     38                 
     39                pane.add(frame1, BorderLayout.CENTER); 
     40                 
     41                JInternalFrame frame2 = new JInternalFrame(); 
     42                frame2.setLocation(110, 110); 
     43                frame2.setSize(90, 90); 
     44                frame2.setVisible(true); 
     45                 
     46                pane.setLayer(frame2, JLayeredPane.PALETTE_LAYER); 
     47                 
     48                pane.add(frame2, CustomLayout.CUSTOM); 
     49        } 
     50         
     51        /** 
     52         * The main method. 
     53         * @param args 
     54         */ 
     55        public static void main(String args[]) { 
     56                new LayoutDemo(); 
     57        } 
     58} 
     59 
  • modules/org.sophie2.extra.func.annotations/src/main/java/org/sophie2/extra/func/annotations/view/halos/StickyMoveHaloButton.java

     
    1616import org.sophie2.base.skins.SkinElementId; 
    1717import org.sophie2.base.visual.skins.VisualElementDef; 
    1818import org.sophie2.extra.func.annotations.view.StickyView; 
     19import org.sophie2.main.app.commons.PageAreaMouseCapture; 
    1920import org.sophie2.main.app.commons.page.PageWorkArea; 
    2021import org.sophie2.main.app.halos.page.element.PageElementMoveHaloButton; 
    2122 
     
    3435                // lock the view rect, so that we don't have auto-scrolls while moving. 
    3536                final PageWorkArea workArea = workArea().get(); 
    3637                final SceneVisual sv = workArea.sceneVisual().get(); 
    37                 sv.wantedViewRect().set(sv.actualViewRect().get()); 
     38                sv.wantedViewRect().set(sv.lastViewRect().get()); 
    3839 
    3940                StickyView stickyView = findParentElement(StickyHaloMenu.class).stickyView().get();  
    4041                final TimePos time = stickyView.getTime();   
     
    4748                                workArea.getSel().getEditScope().sceneElement().get()).inverse();  
    4849                final ImmPoint zero = sceneToParent.transform(ImmPoint.ZERO);  
    4950 
    50                 MouseCapture result = new MouseCapture(0, 0, e) { 
     51                MouseCapture result = new PageAreaMouseCapture(0, 0, e) { 
    5152 
    5253                        private void releaseAction(final LocationChannel locationChannel) { 
    5354                                final ImmPoint newlocation =  
     
    8081                        } 
    8182 
    8283                        @Override 
    83                         public void released() { 
     84                        public void onReleased() { 
    8485                                sv.wantedViewRect().set(null); 
    8586                                releaseAction(channel); 
    86  
    8787                        } 
    8888 
    8989                        @Override 
    9090                        public void shouldMove(final int newX, final int newY) { 
    9191                                moveAction(channel, newX, newY); 
    9292                        } 
     93 
     94                        @Override 
     95                        public PageWorkArea getWorkArea() { 
     96                                return workArea; 
     97                        } 
    9398                }; 
    9499 
    95100                return result; 
  • modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/interfaces/Scene.java

     
    11package org.sophie2.base.scene.interfaces; 
    22 
    33import org.sophie2.base.commons.util.ImmColor; 
     4import org.sophie2.base.commons.util.position.ImmRect; 
    45import org.sophie2.base.scene.helpers.SceneHelper; 
    56import org.sophie2.core.prolib.impl.BaseProObject; 
    67import org.sophie2.core.prolib.interfaces.Prop; 
     
    3536         * @return property 
    3637         */ 
    3738        public abstract Prop<? extends SceneElement> rootElement(); 
    38  
     39         
     40        /** 
     41         * The rectangle over which the actual view rectangle will be centered. 
     42         *  
     43         * @return property 
     44         */ 
     45        public abstract RwProp<ImmRect> centeringRect(); 
     46         
    3947        /** 
    4048         * The background color of the scene. This is the infinite area that is 
    4149         * outside of any object. Note that, you should usually use elements that 
  • modules/org.sophie2.base.scene/src/test/java/org/sophie2/base/scene/SceneDemo.java

     
    443443                        return component; 
    444444                } 
    445445 
    446                 public Prop<ImmRect> actualViewRect() { 
     446                public RwProp<ImmRect> lastViewRect() { 
    447447                        return getBean().makeValueProp("actualViewRect", ImmRect.class, 
    448448                                        ImmRect.ZERO_RECT); 
    449449                } 
     
    471471 
    472472                public RwProp<ImmRect> minimalViewRect() {  
    473473                        return getBean().makeValueProp("minimalViewRect", ImmRect.class, null);  
    474                 }  
     474                } 
    475475 
    476                 public RwProp<ImmRect> actualViewRectCache() {  
    477                         return getBean().makeValueProp("actualViewRectCache", ImmRect.class, null);  
    478                 }  
     476                public RwProp<ImmRect> actualViewRect() { 
     477//                      return getBean().makeValueProp("halosBoundSize", ImmRect.class, ImmRect.ZERO_RECT); 
     478                        return null; 
     479                } 
     480 
     481//              public RwProp<ImmRect> lastViewRect() { 
     482//                      // TODO Auto-generated method stub 
     483//                      return null; 
     484//              }  
    479485        } 
    480486 
    481487        /** 
  • modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/BaseSceneVisual.java

     
    11package org.sophie2.base.scene; 
    22 
     3import java.awt.Container; 
    34import java.awt.Dimension; 
    45import java.util.List; 
    56 
    67import javax.swing.JComponent; 
     8import javax.swing.JScrollPane; 
    79 
    810import org.sophie2.base.commons.util.OSUtil; 
     11import org.sophie2.base.commons.util.position.ImmPoint; 
    912import org.sophie2.base.commons.util.position.ImmRect; 
     13import org.sophie2.base.commons.util.position.ImmSize; 
    1014import org.sophie2.base.dnd.SophieDragDropHandler; 
    1115import org.sophie2.base.scene.helpers.ElementHelper; 
    1216import org.sophie2.base.scene.helpers.SceneHelper; 
     
    7175 
    7276        private static final int DEFAULT_PADDING_L = 18; 
    7377        private static final int DEFAULT_PADDING_R = 18; 
    74         private static final int DEFAULT_PADDING_T = 48; 
     78        private static final int DEFAULT_PADDING_T = 42; 
    7579        private static final int DEFAULT_PADDING_B = 18; 
    76  
     80         
    7781        public RwProp<ImmRect> wantedViewRect() { 
    7882                return getBean().makeValueProp("wantedViewRect", ImmRect.class, null); 
    7983        } 
    8084 
    81         public RwProp<ImmRect> minimalViewRect() {  
    82                 return getBean().makeValueProp("minimalViewRect", ImmRect.class, null);  
    83         }  
    84  
    85         public RwProp<ImmRect> actualViewRectCache() {  
    86                 return getBean().makeValueProp("actualViewRectCache", ImmRect.class, null);  
    87         }  
    88  
    8985        @Own 
    9086        public RwProp<Scene> scene() { 
    9187                return getBean().makeValueProp("scene", Scene.class); 
    9288        } 
     89         
     90        /** 
     91         * The size of the component where the scene is painted. This is the size which will be used for centering into it. 
     92         *  
     93         * @return The property. 
     94         */ 
     95        public RwProp<ImmSize> viewportSize() { 
     96                return getBean().makeValueProp("viewportSize", ImmSize.class, ImmSize.ZERO); 
     97        } 
    9398 
    9499        public Prop<JComponent> swingComponent() { 
    95100                class swingComponent extends ResourceProperty<JComponent> { 
    96101                        @Override 
    97102                        protected JComponent create() { 
    98103                                JComponent res = createSwingComponent(); 
     104                                res.setLayout(null); 
     105 
    99106                                SwingEventAdapter.registerComponent(res, 
    100107                                                BaseSceneVisual.this, null, res); 
    101108 
     
    112119 
    113120                        @Override 
    114121                        protected void setup(JComponent res) { 
     122 
    115123                                Dimension size = actualViewRect().get().getSize().toDimension(); 
     124                                 
     125                                 
     126                                int vScrollWidth = 0; 
     127                                int hScrollHeight = 0; 
     128 
     129                                JScrollPane pane = findParentScrollPane(res, 6); 
     130                                 
     131                                if (pane != null) { 
     132                                        vScrollWidth = pane.getVerticalScrollBar().getWidth(); 
     133                                        hScrollHeight = pane.getHorizontalScrollBar().getHeight(); 
     134                                }  
     135                                 
     136                                int newWidth = size.width; 
     137                                int newHeight = size.height; 
     138                                 
     139                                if (size.getWidth() <= viewportSize().get().getWidth()  
     140                                                && size.getHeight() > viewportSize().get().getHeight()) { 
     141                                        newWidth -= hScrollHeight; 
     142                                } 
     143                                 
     144                                if (size.getWidth() > viewportSize().get().getWidth()  
     145                                                && size.getHeight() <= viewportSize().get().getHeight()) { 
     146                                        newHeight -= vScrollWidth; 
     147                                } 
     148 
     149                                size = new Dimension(newWidth, newHeight); 
     150                                                                 
    116151                                res.setSize(size); 
    117152                                res.setPreferredSize(size); 
    118                                 res.setLayout(null); 
    119153                                res.revalidate(); 
     154                                res.repaint(); 
     155                        } 
     156                         
     157                        private JScrollPane findParentScrollPane(JComponent res, int depth) { 
     158                                Container component = res; 
     159                                int i = 0; 
     160                                 
     161                                while (i < depth && component != null) { 
     162                                         
     163                                        if (component instanceof JScrollPane) { 
     164                                                return (JScrollPane) component; 
     165                                        }  
     166                                         
     167                                        component = component.getParent(); 
     168                                        ++i; 
     169                                } 
     170                                 
     171                                return null; 
    120172                        } 
    121173 
    122174                        @SuppressWarnings("unused") 
     
    157209                return getBean().makeProp(swingComponent.class); 
    158210        } 
    159211 
     212         
     213         
    160214        /** 
    161215         * A view rectangle, if it can not be determined automatically (such as, 
    162216         * when no scene is set). 
    163217         */ 
    164218        protected static final ImmRect DEFAULT_VIEW_RECT = 
    165219                new ImmRect(0, 0, 256, 256); 
    166  
    167         public Prop<ImmRect> actualViewRect() { 
    168                 class actualViewRect extends AutoProperty<ImmRect> { 
     220         
     221        public RwProp<ImmRect> actualViewRect(){ 
     222                return getBean().makeValueProp("actualViewRect", ImmRect.class, ImmRect.ZERO_RECT); 
     223        } 
     224         
     225        public RwProp<ImmRect> lastViewRect(){ 
     226                return getBean().makeValueProp("lastViewRect", ImmRect.class, ImmRect.ZERO_RECT); 
     227        } 
     228         
     229        public Prop<ImmRect> minimalViewRect() { 
     230                class minimalViewRect extends AutoProperty<ImmRect> { 
    169231 
    170232                        @Override 
    171233                        protected ImmRect compute() { 
     
    177239                                                && scene().get().rootElement().get() != null) { 
    178240                                        ImmRect bound = SceneHelper.getBoundingRect(scene().get(), 
    179241                                                        scene().get().rootElement().get()); 
     242                                        res = bound; 
     243                         
     244                                                 
    180245                                        res = new ImmRect( 
    181                                                         bound.getX() - DEFAULT_PADDING_L,  
    182                                                         bound.getY() - DEFAULT_PADDING_T,  
    183                                                         bound.getWidth() + DEFAULT_PADDING_R + DEFAULT_PADDING_L,  
    184                                                         bound.getHeight() + DEFAULT_PADDING_B + DEFAULT_PADDING_T); 
     246                                        res.getX() - DEFAULT_PADDING_L,  
     247                                        res.getY() - DEFAULT_PADDING_T,  
     248                                        res.getWidth() + DEFAULT_PADDING_R + DEFAULT_PADDING_L,  
     249                                        res.getHeight() + DEFAULT_PADDING_B + DEFAULT_PADDING_T); 
     250 
     251                                        ImmRect centeringRect = scene().get().centeringRect().get(); 
     252                                         
     253                                        if (!centeringRect.equals(ImmRect.ZERO_RECT)) { 
     254                                                ImmPoint centerPoint = new ImmPoint(centeringRect.getWidth()/2, 
     255                                                                centeringRect.getHeight()/2); 
     256                                                ImmRect toUnite = ImmRect.create(centerPoint, viewportSize().get()); 
     257                                                res = res.union(toUnite); 
     258                                        } else { 
     259                                                ImmRect toUnite = new ImmRect(ImmPoint.ZERO, viewportSize().get()); 
     260                                                res = res.union(toUnite); 
     261                                        } 
    185262                                } else { 
    186263                                        // can not determine... 
    187264                                        // just make something... 
    188265                                        res = DEFAULT_VIEW_RECT; 
    189266                                } 
    190  
    191                                 // Center the actualRect on the minimalViewRect  
    192                                 // wantedViewRect is set by halo mouse tracking to limit the rect,   
    193                                 // so do nothing if wantedViewRect is not null  
    194                                 if (wantedViewRect().get() == null) {  
    195                                         ImmRect myMinimalViewRect = minimalViewRect().get();  
    196                                         if (myMinimalViewRect != null) {  
    197                                                 float xOffset = 
    198                                                         Math.max((myMinimalViewRect.getWidth() - res.getWidth()) / 2, 0);  
    199                                                 float yOffset = 
    200                                                         Math.max((myMinimalViewRect.getHeight() - res.getHeight()) / 2, 0);  
    201                                                 res = new ImmRect(res.getX() - xOffset,  
    202                                                                 res.getY() - yOffset,  
    203                                                                 Math.max(res.getWidth(), myMinimalViewRect.getWidth()),  
    204                                                                 Math.max(res.getHeight(), myMinimalViewRect.getHeight()));  
    205                                         }  
    206  
    207                                         if (!res.equals(actualViewRectCache().get())) {  
    208                                                 actualViewRectCache().set(res);  
    209                                         }  
    210                                 } 
    211  
    212267                                assert res != null; 
    213268                                return res; 
    214269                        } 
    215270                } 
    216  
    217                 return getBean().makeProp(actualViewRect.class); 
     271                return getBean().makeProp(minimalViewRect.class); 
    218272        } 
    219  
     273         
    220274        /** 
    221275         * Override this to provide logic for the creation of the Swing Component 
    222276         * of this {@link SceneVisual}. 
  • modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/helpers/SceneHelper.java

     
    248248                SophieLog.trace("sceneToSwing: sceneRect=" + sceneRect); 
    249249                assert sceneRect != null; 
    250250                // only translation... 
    251                 ImmRect viewRect = visual.actualViewRect().get(); 
     251                ImmRect viewRect = visual.lastViewRect().get(); 
    252252                assert viewRect != null; 
    253253                SophieLog.trace("sceneToSwing: viewRect=" + viewRect); 
    254254                ImmRect res = Position.translate(sceneRect, -viewRect.getX(), -viewRect 
     
    271271                SophieLog.trace("sceneToSwing: sceneRect=" + scenePoint); 
    272272                assert scenePoint != null; 
    273273                // only translation... 
    274                 ImmRect viewRect = visual.actualViewRect().get(); 
     274                ImmRect viewRect = visual.lastViewRect().get(); 
    275275                assert viewRect != null; 
    276276                SophieLog.trace("sceneToSwing: viewRect=" + viewRect); 
    277277                ImmPoint res = scenePoint.translate(-viewRect.getX(), -viewRect.getY()); 
     
    291291         */ 
    292292        public static ImmRect swingToScene(SceneVisual visual, ImmRect swingRect) { 
    293293                // only translation... 
    294                 ImmRect viewRect = visual.actualViewRect().get(); 
     294                ImmRect viewRect = visual.lastViewRect().get(); 
    295295                return Position.translate(swingRect, viewRect.getX(), viewRect.getY()); 
    296296        } 
    297297 
     
    306306         */ 
    307307        public static ImmPoint swingToScene(SceneVisual visual, ImmPoint swingPoint) { 
    308308                // only translation... 
    309                 ImmRect viewRect = visual.actualViewRect().get(); 
     309                ImmRect viewRect = visual.lastViewRect().get(); 
    310310                assert viewRect != null; 
    311311                return swingPoint.translate(viewRect.getX(), viewRect.getY()); 
    312312        } 
  • modules/org.sophie2.base.layout/src/main/java/org/sophie2/base/layout/model/CustomLayout.java

     
     1package org.sophie2.base.layout.model; 
     2 
     3import java.awt.BorderLayout; 
     4import java.awt.Component; 
     5import java.awt.Container; 
     6import java.awt.Dimension; 
     7import java.awt.LayoutManager2; 
     8import java.io.Serializable; 
     9 
     10import javax.swing.JDesktopPane; 
     11import javax.swing.JLayeredPane; 
     12 
     13/** 
     14 * LayoutManager that supports adding of components with different layouts - null 
     15 * and some specific layout. An object is created with a specific 
     16 * {@link LayoutManager2}. When different components are added, they can be with 
     17 * constraint - CustomLayout.CUSTOM. This means that for laying out of these 
     18 * components will be used null layout. For all other components added, it will 
     19 * be used the given layout manager. This layout manager can be used for example 
     20 * for {@link JDesktopPane}. For example, components at 
     21 * {@link JLayeredPane#DEFAULT_LAYER} can be with {@link BorderLayout} and the 
     22 * components at {@link JLayeredPane#PALETTE_LAYER} to be with null layout. 
     23 *  
     24 * @author tanya 
     25 */ 
     26public class CustomLayout implements LayoutManager2, Serializable { 
     27 
     28        /** 
     29         * Used for serialization. 
     30         */ 
     31        private static final long serialVersionUID = 810513263396699528L; 
     32 
     33        private LayoutManager2 layoutManager; 
     34         
     35        /** 
     36         * The constraint for the objects which we want to be with null layout. 
     37         */ 
     38        public static final String CUSTOM   = "Custom"; 
     39         
     40        /** 
     41         * Constructs an object with another layout manager. The components added 
     42         * will be with null layout or will be added according 
     43         *  
     44         * @param manager 
     45         *            The manager which will be responsible for how the components 
     46         *            will be added and how will be laid out. 
     47         */ 
     48        public CustomLayout(LayoutManager2 manager) { 
     49                this.layoutManager = manager; 
     50        } 
     51         
     52        public void addLayoutComponent(Component comp, Object constraints) { 
     53                if (constraints != CUSTOM && this.layoutManager != null) { 
     54                        this.layoutManager.addLayoutComponent(comp, constraints); 
     55                } 
     56        } 
     57 
     58        public float getLayoutAlignmentX(Container target) { 
     59                if (this.layoutManager != null) { 
     60                        return this.layoutManager.getLayoutAlignmentX(target); 
     61                } 
     62 
     63                return 0f; 
     64        } 
     65 
     66        public float getLayoutAlignmentY(Container target) { 
     67                if (this.layoutManager != null) { 
     68                        return this.layoutManager.getLayoutAlignmentY(target); 
     69                } 
     70                 
     71                return 0f; 
     72        } 
     73 
     74        public void invalidateLayout(Container target) { 
     75                if (this.layoutManager != null) { 
     76                        this.layoutManager.invalidateLayout(target); 
     77                } 
     78        } 
     79 
     80        public Dimension maximumLayoutSize(Container target) { 
     81                if (this.layoutManager != null) { 
     82                        return this.layoutManager.maximumLayoutSize(target); 
     83                } 
     84                 
     85                return null; 
     86        } 
     87 
     88        public void addLayoutComponent(String name, Component comp) { 
     89                if (this.layoutManager != null) { 
     90                        this.layoutManager.addLayoutComponent(name, comp); 
     91                } 
     92        } 
     93 
     94        public void layoutContainer(Container parent) { 
     95                if (this.layoutManager != null) { 
     96                        this.layoutManager.layoutContainer(parent); 
     97                } 
     98        } 
     99 
     100        public Dimension minimumLayoutSize(Container parent) { 
     101                if (this.layoutManager != null) { 
     102                        return this.layoutManager.minimumLayoutSize(parent); 
     103                } 
     104                 
     105                return null; 
     106        } 
     107 
     108        public Dimension preferredLayoutSize(Container parent) { 
     109                if (this.layoutManager != null) { 
     110                        return this.layoutManager.preferredLayoutSize(parent); 
     111                } 
     112                 
     113                return null; 
     114        } 
     115 
     116        public void removeLayoutComponent(Component comp) { 
     117                if (this.layoutManager != null) { 
     118                        this.layoutManager.removeLayoutComponent(comp); 
     119                } 
     120        } 
     121} 
     122 No newline at end of file 
  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/page/PageWorkArea.java

     
    11package org.sophie2.main.app.commons.page; 
    22 
     3import java.awt.BorderLayout; 
    34import java.util.ArrayList; 
    45import java.util.List; 
    56 
     
    1011import org.sophie2.base.commons.util.ImmColor; 
    1112import org.sophie2.base.commons.util.position.ImmArea; 
    1213import org.sophie2.base.commons.util.position.ImmMatrix; 
     14import org.sophie2.base.commons.util.position.ImmPoint; 
    1315import org.sophie2.base.commons.util.position.ImmRect; 
     16import org.sophie2.base.commons.util.position.ImmSize; 
     17import org.sophie2.base.layout.model.CustomLayout; 
    1418import org.sophie2.base.model.book.PageH; 
    1519import org.sophie2.base.scene.SceneVisual; 
    1620import org.sophie2.base.scene.effects.ColorEffect; 
     
    152156                        @Override 
    153157                        protected Scene compute() { 
    154158                                assert getLastValue() == null; 
     159                                 
    155160                                return new BaseScene() { 
    156161 
    157162                                        @Override 
    158163                                        protected void setupScene() { 
    159164                                                rootElement().set(rootSceneElement().get()); 
     165                                                 
     166                                                boolean isDesktopBook = !(bookView().get().getViewOptions().isShowControls()); 
     167 
     168                                                if (!isDesktopBook) { 
     169                                                        ImmPoint pageLocation = ImmPoint.ZERO; 
     170                                                        float zoom = bookView().get().getViewOptions().getZoom(); 
     171                                                        ImmSize pageSize = bookView().get().model().get().getPageSize(); 
     172                                                        pageSize = new ImmSize(pageSize.getWidth()*zoom, pageSize.getHeight()*zoom); 
     173                                                        ImmRect centeringRect = new ImmRect(pageLocation, pageSize); 
     174                                                         
     175                                                        centeringRect().set(centeringRect); 
     176                                                } 
     177 
    160178                                                topEventSource().set(PageWorkArea.this); 
    161179                                        } 
    162180                                }; 
     
    208226                        @Override 
    209227                        protected void setup(JDesktopPane res) { 
    210228                         
     229                                res.setLayout(new CustomLayout(new BorderLayout())); 
     230                                 
    211231                                JComponent sceneComp = sceneVisual().get().swingComponent().get(); 
    212232 
    213233                                sceneComp.setLocation(0, 0); 
    214234                                SophieLog.debug("PageWorkArea.layeredPage: sceneComp:" + sceneComp); 
    215235 
    216236                                res.removeAll(); 
    217                                 res.add(sceneComp, JLayeredPane.DEFAULT_LAYER); 
     237                                res.setLayer(sceneComp, JLayeredPane.DEFAULT_LAYER); 
     238                                 
     239                                res.add(sceneComp, BorderLayout.CENTER); 
    218240 
    219241                                res.revalidate(); 
    220242                                res.repaint(); 
    221243                        } 
    222244 
    223                         // TODO (r4) reimplement the page-work-area centering 
    224245                        @SuppressWarnings("unused") 
    225246                        @Setup 
    226247                        protected void setupActualSize(JLayeredPane res) { 
    227  
    228                                 // grab the value to set up the property sync 
    229                                 ImmRect actualCache = sceneVisual().get().actualViewRect().get(); 
    230  
    231248                                JDesktopPane desktopPane = swingComponent().get(); 
    232249                                desktopPane.revalidate(); 
    233250                                desktopPane.repaint(); 
     
    427444                } 
    428445                return getBean().makeProp(selectionRisenElement.class); 
    429446        } 
     447         
     448        /** 
     449         * Property which have True or False value depending on whether mouse capture event is started or not. 
     450         * <b>true</b> if mouse capture is on, <b>false</b> otherwise. 
     451         *  
     452         * @return property 
     453         */ 
     454        public RwProp<Boolean> scrollsLocked() { 
     455                return getBean().makeValueProp("scrollsLocked", Boolean.class, Boolean.FALSE);   
     456        } 
    430457} 
     458 No newline at end of file 
  • modules/org.sophie2.main.app.halos/src/main/java/org/sophie2/main/app/halos/page/resize/PageResizeHaloButton.java

     
    2222import org.sophie2.base.visual.skins.SkinPartDef; 
    2323import org.sophie2.base.visual.skins.VisualElementDef; 
    2424import org.sophie2.core.prolib.interfaces.Prop; 
     25import org.sophie2.main.app.commons.PageAreaMouseCapture; 
    2526import org.sophie2.main.app.commons.page.PageWorkArea; 
    2627import org.sophie2.main.app.halos.common.AppHaloUtil; 
    2728 
     
    4950 
    5051        @Override 
    5152        protected MouseCapture captureClick(MouseEvent e) { 
    52                 PageWorkArea pwa = AppHaloUtil.getWorkArea(PageResizeHaloButton.this); 
     53                final PageWorkArea pwa = AppHaloUtil.getWorkArea(PageResizeHaloButton.this); 
    5354 
    5455                if(pwa !=null ){ 
    5556 
    5657                        final SceneVisual sv = pwa.sceneVisual().get(); 
    57                         sv.wantedViewRect().set(sv.actualViewRect().get()); 
     58                        sv.wantedViewRect().set(sv.lastViewRect().get()); 
    5859 
    5960                        final BookH book = pwa.bookView().get().model().get(); 
    6061 
     
    6364                        final ImmMatrix transf = SceneHelper.getElementToSceneTransform(pwa.scene().get(), pwa.rootSceneElement().get()); 
    6465 
    6566                        ImmVector resizedSize = transf.transform(v); 
    66                         return new MouseCapture((int) resizedSize.getPointX(), (int) resizedSize.getPointY(), 
     67                        return new PageAreaMouseCapture((int) resizedSize.getPointX(), (int) resizedSize.getPointY(), 
    6768                                        e) { 
    6869 
    6970                                @Override 
    70                                 public void released() { 
     71                                public void onReleased() { 
    7172                                        sv.wantedViewRect().set(null); 
    7273 
    73  
    7474                                        new AutoAction("Set page size", true) { 
    7575 
    7676                                                @Override 
     
    112112                                        }.register(book.getAccess()); 
    113113                                } 
    114114 
     115                                @Override 
     116                                public PageWorkArea getWorkArea() { 
     117                                        return pwa; 
     118                                } 
     119 
    115120                        }; 
    116121                } 
    117122                return null; 
  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/page/ScenePageLogic.java

     
    44import java.util.ArrayList; 
    55import java.util.List; 
    66 
    7 import org.sophie2.base.commons.gui.MouseCapture; 
    87import org.sophie2.base.commons.util.position.ImmArea; 
    98import org.sophie2.base.commons.util.position.ImmMatrix; 
    109import org.sophie2.base.commons.util.position.ImmPoint; 
     
    3130import org.sophie2.core.mvc.OperationDef; 
    3231import org.sophie2.core.mvc.SortKey; 
    3332import org.sophie2.core.mvc.events.EventR3; 
     33import org.sophie2.main.app.commons.PageAreaMouseCapture; 
    3434import org.sophie2.main.app.commons.app.AppMainWindow; 
    3535import org.sophie2.main.app.commons.book.BookDocView; 
    3636import org.sophie2.main.app.commons.book.BookViewOptions; 
     
    131131 
    132132                        MouseEvent cause = event.getCausingEvent(EventR3.class).getCausingEvent( 
    133133                                        MouseEvent.class); 
    134                         new MouseCapture(0, 0, cause) { 
     134                        new PageAreaMouseCapture(0, 0, cause) { 
    135135 
    136136                                @Override 
    137                                 public void released() { 
     137                                public void onReleased() { 
    138138                                        pwa.selectionArea().set(ImmArea.EMPTY); 
    139139                                } 
    140140 
     
    170170                                                                pwa.getSel().select(toSelect, false); 
    171171                                                        } 
    172172                                } 
     173 
     174                                @Override 
     175                                public PageWorkArea getWorkArea() { 
     176                                        return pwa; 
     177                                } 
    173178                        }; 
    174179                        return true; 
    175180                } 
  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/app/AppMainWindow.java

     
    1414import org.sophie2.base.commons.util.position.ImmRect; 
    1515import org.sophie2.base.halos.HaloMenu; 
    1616import org.sophie2.base.layout.impl.DefaultMainWindow; 
     17import org.sophie2.base.layout.model.CustomLayout; 
    1718import org.sophie2.base.layout.model.DocView; 
    1819import org.sophie2.base.media.MediaComposite; 
    1920import org.sophie2.base.media.MediaUtil; 
     
    211212                                        if (hm.visible().get()) { 
    212213                                                for (JComponent c : hm.swingComponents().get()) { 
    213214 
    214                                                         res.add(c, JLayeredPane.PALETTE_LAYER); 
     215                                                        res.setLayer(c, JLayeredPane.PALETTE_LAYER); 
     216                                                        res.add(c, CustomLayout.CUSTOM); 
     217                                                         
    215218                                                } 
    216219                                        } 
    217220                                } 
     
    235238                                } 
    236239                                PageWorkArea workArea = bookDocView.workArea().get(); 
    237240 
    238                                 JDesktopPane res = workArea.swingComponent().get();  
    239  
    240                                 // The scene bounds 
    241                                 ImmRect bounds = workArea.sceneVisual().get().actualViewRect().get(); 
    242                                 // The bounds of visible huds 
    243                                 for (HaloMenu hm : haloMenus().get()) { 
     241                                if (!workArea.scrollsLocked().get()) { 
    244242 
    245                                         bounds = bounds.union(SceneHelper.swingToScene( 
    246                                                         workArea.sceneVisual().get(), hm.activeBounds().get())); 
    247                                 } 
     243                                        JDesktopPane res = workArea.swingComponent().get();  
    248244 
    249                                 bounds = SceneHelper.sceneToSwing(workArea.sceneVisual().get(), bounds); 
    250                                 Dimension d = bounds.getSize().toDimension(); 
     245                                        // The scene bounds 
     246                                        ImmRect bounds = workArea.sceneVisual().get().minimalViewRect().get(); 
     247                                        // The bounds of visible huds 
     248                                        for (HaloMenu hm : haloMenus().get()) { 
     249                                                bounds = bounds.union(SceneHelper.swingToScene( 
     250                                                                workArea.sceneVisual().get(), hm.activeBounds().get())); 
     251                                        } 
     252                                        bounds = SceneHelper.sceneToSwing(workArea.sceneVisual() 
     253                                                        .get(), bounds); 
    251254 
    252                                 res.setPreferredSize(d); 
    253                                 res.setSize(d); 
    254                                 res.revalidate(); 
     255                                        Dimension dim = bounds.getSize().toDimension(); 
     256                                        workArea.sceneVisual().get().actualViewRect().set( 
     257                                                        new ImmRect(workArea.sceneVisual().get().minimalViewRect().get().getX(),  
     258                                                                        workArea.sceneVisual().get().minimalViewRect().get().getY(), dim.width, dim.height)); 
     259                                } 
    255260                        } 
    256  
    257261                } 
    258262                return getBean().makeProp(haloSync.class); 
    259263        } 
  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/frame/FrameLogic.java

     
    22 
    33import java.awt.event.MouseEvent; 
    44 
    5 import org.sophie2.base.commons.gui.MouseCapture; 
    65import org.sophie2.base.commons.util.position.ImmMatrix; 
    76import org.sophie2.base.commons.util.position.ImmPoint; 
    87import org.sophie2.base.commons.util.position.ImmSize; 
     
    2423import org.sophie2.core.mvc.EventFilterBuilder; 
    2524import org.sophie2.core.mvc.OperationDef; 
    2625import org.sophie2.core.mvc.events.EventR3; 
     26import org.sophie2.main.app.commons.PageAreaMouseCapture; 
    2727import org.sophie2.main.app.commons.element.ElementView; 
    2828import org.sophie2.main.app.commons.element.ResizeAreaSceneElement.ResizeSubAreaElement; 
    2929import org.sophie2.main.app.commons.page.PageWorkArea; 
     
    5555                        final ElementView elementView = event.getSource(ElementView.class); 
    5656                        final ResourceAccess access = elementView.getAccess(); 
    5757                 
    58                         PageWorkArea pwa = elementView.getPwa(); 
     58                        final PageWorkArea pwa = elementView.getPwa(); 
    5959                        Mode sizeTemplateMode = ResizableElement.KEY_SIZE.getMode(access); 
    6060                        Mode locTemplateMode = MemberElement.KEY_LOCATION.getMode(access); 
    6161 
     
    7575 
    7676                        // lock the view rect, so that we don't have auto-scrolls while moving. 
    7777                        final SceneVisual sv = pwa.sceneVisual().get(); 
    78                         sv.wantedViewRect().set(sv.actualViewRect().get()); 
     78                        sv.wantedViewRect().set(sv.lastViewRect().get()); 
    7979 
    8080                        MouseEvent cause = event.getCausingEvent(EventR3.class).getCausingEvent( 
    8181                                        MouseEvent.class); 
    8282 
    83                         new MouseCapture(0, 0, cause) { 
     83                        new PageAreaMouseCapture(0, 0, cause) { 
    8484 
    8585                                private void doResize(final LocationChannel oldChannel) { 
    8686                                        final ImmSize newSize = ResizableElement.KEY_SIZE.get(access); 
     
    100100                                } 
    101101                                 
    102102                                @Override 
    103                                 public void released() { 
     103                                public void onReleased() { 
    104104                                        doResize(channel); 
    105105                                        sv.wantedViewRect().set(null); 
    106106                                } 
     
    173173 
    174174                                        } 
    175175                                } 
     176 
     177                                @Override 
     178                                public PageWorkArea getWorkArea() { 
     179                                        return pwa; 
     180                                } 
    176181                        }; 
    177182 
    178183                        return true; 
  • modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/impl/BaseScene.java

     
    11package org.sophie2.base.scene.impl; 
    22 
    33import org.sophie2.base.commons.util.ImmColor; 
     4import org.sophie2.base.commons.util.position.ImmRect; 
    45import org.sophie2.base.scene.interfaces.Scene; 
    56import org.sophie2.base.scene.interfaces.SceneElement; 
    67import org.sophie2.core.prolib.impl.ResourceProperty; 
     
    2021        } 
    2122 
    2223        @Override 
     24        public RwProp<ImmRect> centeringRect() { 
     25                return getBean().makeValueProp("centeringRect", ImmRect.class, ImmRect.ZERO_RECT); 
     26        } 
     27         
     28        @Override 
    2329        public RwProp<ImmColor> backgroundColor() { 
    2430                return getBean().makeValueProp("backgroundColor", ImmColor.class, 
    2531                                ImmColor.GRAY); 
  • modules/org.sophie2.main.scene.simple/src/main/java/org/sophie2/main/scene/simple/SimpleSceneVisual.java

     
    11package org.sophie2.main.scene.simple; 
    22 
     3import java.awt.Container; 
    34import java.awt.Graphics; 
    45import java.awt.Graphics2D; 
    56 
    67import javax.swing.JComponent; 
    78import javax.swing.JPanel; 
     9import javax.swing.JScrollPane; 
    810 
    911import org.sophie2.base.commons.util.position.ImmRect; 
     12import org.sophie2.base.commons.util.position.ImmSize; 
    1013import org.sophie2.base.scene.BaseSceneVisual; 
    1114import org.sophie2.base.scene.SceneVisual; 
    1215import org.sophie2.base.scene.helpers.SceneHelper; 
     
    1619/** 
    1720 * Simple scene implementation. 
    1821 *  
    19  * @author milo, peko, nenko, mira, gogov 
     22 * @author milo, peko, nenko, mira, gogov, tanya 
    2023 */ 
    2124@SkinElementId("main.scene.simple.simple-scene-visual") 
    2225public class SimpleSceneVisual extends BaseSceneVisual { 
     
    3740                private static final long serialVersionUID = 4801814966438437503L; 
    3841 
    3942                private long lastPaintTime = System.currentTimeMillis(); 
    40  
     43                 
     44                private static final int OFFSET = 2; 
     45                 
    4146                @Override 
    4247                protected void paintComponent(Graphics graphics) { 
    4348 
     
    5358                        SophieLog.trace("paintComponent: parent=" + getParent()); 
    5459 
    5560                        Graphics2D g2d = (Graphics2D) graphics.create(); 
     61                        //Centering the actual view rectangle. 
     62                         
     63                        int w = this.getParent().getParent().getParent().getWidth(); 
     64                        int h = this.getParent().getParent().getParent().getHeight(); 
     65 
     66                         
     67                        viewportSize().set(new ImmSize(w, h)); 
    5668                        ImmRect visRect = actualViewRect().get(); 
    5769 
    5870                        SceneHelper.paint(g2d, visRect, scene().get()); 
    59  
     71                         
     72                        Container container = this.getParent().getParent().getParent(); 
     73                        if (container instanceof JScrollPane) { 
     74                                JScrollPane pane = (JScrollPane) container; 
     75                                 
     76                                if (!lastViewRect().get().equals(visRect)) { 
     77                                        if (lastViewRect().get().getY() > visRect.getY()) { 
     78                                                pane.getVerticalScrollBar().setValue(0);                                                 
     79                                        } else if (lastViewRect().get().getHeight() + OFFSET + lastViewRect().get().getY() < visRect.getHeight() + visRect.getY() 
     80                                                        && lastViewRect().get().getY() <= visRect.getY()) { 
     81                                                pane.getVerticalScrollBar().setValue(pane.getVerticalScrollBar().getMaximum()); 
     82                                        } 
     83                                         
     84                                        if (lastViewRect().get().getX() > visRect.getX()) { 
     85                                                pane.getHorizontalScrollBar().setValue(0);                                               
     86                                        } else if (lastViewRect().get().getWidth() + OFFSET + lastViewRect().get().getX() < visRect.getWidth() + visRect.getX() 
     87                                                        && lastViewRect().get().getX() <= visRect.getX()) { 
     88                                                pane.getHorizontalScrollBar().setValue(pane.getHorizontalScrollBar().getMaximum()); 
     89                                        } 
     90                                } 
     91                        } 
     92                         
     93                        lastViewRect().set(visRect); 
     94                         
    6095                        SophieLog.debug("paintComponent: total paint time=" 
    6196                                        + (System.currentTimeMillis() - startTime)); 
     97                         
    6298                } 
    6399        } 
    64100} 
  • modules/org.sophie2.main.scene.sprites/src/main/java/org/sophie2/main/scene/sprites/SpritesSceneVisual.java

     
    5252                        SophieLog.trace("paintComponent: parent=" + getParent()); 
    5353 
    5454                        Graphics2D g2d = (Graphics2D) graphics.create(); 
    55                         ImmRect visRect = actualViewRect().get(); 
     55                        ImmRect visRect = lastViewRect().get(); 
    5656                         
    5757                        SceneHelper.paintSprite(g2d, visRect, scene().get()); 
    5858 
  • modules/org.sophie2.dev/src/main/java/org/sophie2/dev/author/FakeAuthorMain.java

     
    9696                //Profiler.start(); 
    9797                SophieLog.info("Starting fake..."); 
    9898                SophieLog.setMinLevel("", LogLevel.INFO); 
    99                 SophieLog.setMinLevel("org.sophie2.core.mvc", LogLevel.DEBUG); 
     99//              SophieLog.setMinLevel("org.sophie2.core.mvc", LogLevel.DEBUG); 
    100100                //SophieLog.setMinLevel("org.sophie2.core.modularity.FileEntryManager.fillFakeModulePaths", LogLevel.ERROR); 
    101101                //SophieLog.setMinLevel("org.sophie2.base.layout", LogLevel.DEBUG); 
    102102                //SophieLog.setMinLevel("org.sophie2.base.model.resources.r4", LogLevel.DEBUG); 
  • modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/SceneVisual.java

     
    3232         * @return property 
    3333         */ 
    3434        RwProp<ImmRect> wantedViewRect(); 
    35  
    36         /**  
    37          * The smallest rectangle this scene should have.  
    38          *   
    39          * Use this to tell the scene it should be larger than its components, for example,  
    40          * to fill out a window.  
    41          *   
    42          * @return property  
    43          */  
    44         RwProp<ImmRect> minimalViewRect();  
    45  
    46         /**  
    47          * Last known value of the actual view rect, so PageWorkArea can listen for changes  
    48          *   
    49          * Only set this value when it has actually changed  
    50          *   
    51          * @return property  
    52          */  
    53         RwProp<ImmRect> actualViewRectCache();  
     35         
    5436        /** 
    5537         * The swing component displaying the scene. 
    5638         *  
     
    7254         *  
    7355         * @return property 
    7456         */ 
    75         Prop<ImmRect> actualViewRect(); 
     57        RwProp<ImmRect> lastViewRect(); 
     58         
     59        /** 
     60         * Minimal part of the scene that will be displayed. 
     61         *  
     62         * @return property 
     63         */ 
     64        Prop<ImmRect> minimalViewRect(); 
     65 
     66        /** 
     67         * Contains what the dimension of the visible part of the scene should be if 
     68         * we want the visible part of the scene to surround the halos. 
     69         *  
     70         * @return property 
     71         */ 
     72        RwProp<ImmRect> actualViewRect(); 
    7673} 
  • modules/org.sophie2.main.scene.jogl/src/main/java/org/sophie2/main/scene/jogl/JoglSceneVisual.java

     
    6464                public void display(GLAutoDrawable drawable) { 
    6565                        final GL2 gl = drawable.getGL().getGL2(); 
    6666                         
    67                         SceneHelper.paint(gl, actualViewRect().get(),   scene().get()); 
     67                        SceneHelper.paint(gl, lastViewRect().get(),     scene().get()); 
    6868                } 
    6969                 
    7070                public void reshape(GLAutoDrawable drawable, 
  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/app/DocumentsLogic.java

     
    44import org.sophie2.base.layout.impl.DefaultDocView; 
    55import org.sophie2.base.model.resources.r4.ResourceRefR4; 
    66import org.sophie2.base.model.resources.r4.access.ResourceAccess; 
    7 import org.sophie2.core.logging.SophieLog; 
    87import org.sophie2.core.mvc.EventFilterBuilder; 
    98import org.sophie2.core.mvc.EventParams; 
    109import org.sophie2.core.mvc.LogicR3; 
     
    128127                         
    129128                        return true; 
    130129                } 
    131                  
    132         }, 
    133  
    134          
    135         /** 
    136          * Handles resizing of the window by the user. Should center the page in the 
    137          * window. 
    138          */ 
    139         @SortKey("fff-document-resize") 
    140         ON_RESIZE { 
    141  
    142                 public void defineFilter(EventFilterBuilder filter) { 
    143                         filter.setEventId(DefaultDocView.EventIds.RESIZE); 
    144                         filter.setSourceClass(DefaultDocView.class); 
    145                 } 
    146  
    147                 public boolean handle(EventR3 event) { 
    148                         // FIXME (R4) Reimplement page centering. This might need to go down to the layout. 
    149                         SophieLog.warn("(R4) Reimplement page centering!"); 
    150                         return false; 
    151                 } 
    152  
    153130        }; 
    154131         
    155132        /** 
  • modules/org.sophie2.main.app.halos/src/main/java/org/sophie2/main/app/halos/frame/MainTitleBarHalo.java

     
    4545import org.sophie2.core.prolib.interfaces.RwProp; 
    4646import org.sophie2.core.prolib.list.ComposingProList; 
    4747import org.sophie2.core.prolib.list.ProList; 
     48import org.sophie2.main.app.commons.PageAreaMouseCapture; 
    4849import org.sophie2.main.app.commons.element.ElementView; 
    4950import org.sophie2.main.app.commons.element.GroupView; 
    5051import org.sophie2.main.app.commons.frame.FrameView; 
     
    253254         */ 
    254255        protected MouseCapture captureClick(MouseEvent e) { 
    255256 
     257                final PageWorkArea pwa = workArea().get();  
     258 
    256259                // lock the view rect, so that we don't have auto-scrolls while moving. 
    257                 final SceneVisual sv = workArea().get().sceneVisual().get(); 
    258                 sv.wantedViewRect().set(sv.actualViewRect().get()); 
     260                final SceneVisual sv = pwa.sceneVisual().get(); 
     261                sv.wantedViewRect().set(sv.lastViewRect().get()); 
    259262 
    260263                // get the selected frame locations before start moving 
    261264                ResourceRefList frameRefs = ResourceRefList.EMPTY; 
     
    289292                 
    290293                 
    291294                //TODO: rewrite --milo 
    292                 MouseCapture result = new MouseCapture(0, 0, e) { 
     295                MouseCapture result = new PageAreaMouseCapture(0, 0, e) { 
    293296                         
    294297                        private void releasedAction( 
    295298                                        final ImmList<ImmPoint> oldPositions, 
     
    341344                        } 
    342345                         
    343346                        @Override 
    344                         public void released() { 
     347                        public void onReleased() { 
    345348                                sv.wantedViewRect().set(null); 
    346349                                releasedAction(finalOldLocations, finalFrameRefs, finalTimes); 
    347350                        } 
     
    349352                        @Override 
    350353                        public void shouldMove(final int newX, final int newY) { 
    351354                                moveAction(finalOldLocations, finalFrameRefs, finalTimes, newX, newY); 
     355                        } 
    352356 
     357                        @Override 
     358                        public PageWorkArea getWorkArea() { 
     359                                return pwa; 
    353360                        } 
    354361                }; 
    355362                return result;