Search in sources :

Example 1 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class SEFrameChooserUI method showContextMenu.

@Override
public void showContextMenu(int x, int y) {
    DesignEditorFrame f = structureView.getFrameAtXY(x, y);
    if (f != null) {
        performAction(CogToolLID.SetStartFrame, f.getFrame());
        //            this.selection.setSelectedFrame(f.getFrame());
        setViewEnabledState(ListenerIdentifierMap.ALL);
        view.showPositionalMenu();
    } else {
        view.showStandardMenu();
    }
}
Also used : DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)

Example 2 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class DesignEditorMouseState method dealWithMouseDragged.

@Override
protected boolean dealWithMouseDragged(IFigure figure, int button, int eventX, int eventY, int state) {
    boolean goForward = super.dealWithMouseDragged(figure, button, eventX, eventY, state);
    if (goForward && mouseDown) {
        StandardDrawingEditor editor = ui.getViewEditor();
        // Update VIEW to ensure ME point is visible.
        // If outside of the visible canvas, up-click should cancel!
        stopMouseDragTimer = true;
        stopDynamic = editor.movePointNearEdge(eventX, eventY, updateDelta);
        switch(getMouseState()) {
            case PotentialMovingFrame:
            case PotentialMovingSelection:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(MovingFrames);
                // fall through!
                }
            case MovingFrames:
                {
                    updateDynamicMove(eventX, eventY, false);
                    break;
                }
            case PotentialTogglingSelection:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(TogglingSelection);
                // fall through!
                }
            case TogglingSelection:
                {
                    updateDynamicSelectionArea(eventX, eventY);
                    break;
                }
            case PotentialSelectingFrames:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(SelectingFrames);
                // fall through!
                }
            case SelectingFrames:
                {
                    updateDynamicSelectionArea(eventX, eventY);
                    break;
                }
            case PotentialCreatingTransition:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    // Do not allow transitions from menu headers or submenus
                    IFigure target = ui.structureView.getFigureAtXY(mouseDownX, mouseDownY, StructureViewUIModel.SOURCE_ONLY);
                    if ((target instanceof GraphicalParentWidget<?, ?>) && (((GraphicalParentWidget<?, ?>) target).canHaveChildren())) {
                        break;
                    }
                    setMouseState(CreatingTransition);
                    // Ensures proper default action
                    selection.deselectAll();
                // fall through!
                }
            case CreatingTransition:
                {
                    dynamicTransition(eventX, eventY);
                    DesignEditorFrame targetFigure = ui.structureView.getFrameAtXY(eventX, eventY);
                    if (targetFigure != potentialTarget) {
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(false);
                        }
                        potentialTarget = targetFigure;
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(true);
                        }
                    }
                    break;
                }
            case PotentialSelectTransition:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    handleMousePressed(StructureViewUIModel.NO_TRANSITION);
                    switch(getMouseState()) {
                        case PotentialMovingFrame:
                            {
                                setMouseState(MovingFrames);
                                updateDynamicMove(eventX, eventY, false);
                                break;
                            }
                        case PotentialSelectingFrames:
                            {
                                setMouseState(SelectingFrames);
                                updateDynamicSelectionArea(eventX, eventY);
                                break;
                            }
                        case PotentialCreatingTransition:
                            {
                                setMouseState(CreatingTransition);
                                dynamicTransition(eventX, eventY);
                                break;
                            }
                    }
                    break;
                }
            case PotentialToggleTransition:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    handleMousePressed(StructureViewUIModel.NO_TRANSITION);
                    setMouseState(TogglingSelection);
                    updateDynamicSelectionArea(eventX, eventY);
                    break;
                }
            case PotentialChangeTarget:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(ChangingTarget);
                    Point start = hitTransition.getStart();
                    hitTransition.setVisible(false);
                    double zoom = ui.getZoom();
                    double startX = start.x * zoom;
                    double startY = start.y * zoom;
                    ensureDynamicTransition(PrecisionUtilities.round(startX), PrecisionUtilities.round(startY));
                // fall through!
                }
            case ChangingTarget:
                {
                    dynamicTransitionTarget(eventX, eventY);
                    DesignEditorFrame targetFigure = ui.structureView.getFrameAtXY(eventX, eventY);
                    if (targetFigure != potentialTarget) {
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(false);
                        }
                        potentialTarget = targetFigure;
                        if (potentialTarget != null) {
                            potentialTarget.dynamicHighlight(true);
                        }
                    }
                    break;
                }
            case PotentialChangeSource:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    setMouseState(ChangingSource);
                    hitTransition.setVisible(false);
                    ensureDynamicTransition(mouseDownX, mouseDownY);
                    Point endPt = hitTransition.getEnd();
                    double zoom = ui.getZoom();
                    double endX = endPt.x * zoom;
                    double endY = endPt.y * zoom;
                    dynamicTransitionTarget(PrecisionUtilities.round(endX), PrecisionUtilities.round(endY));
                    break;
                }
            case ChangingSource:
                {
                    dynamicTransitionSource(eventX, eventY);
                    GraphicalSource<?> sourceFigure = ui.structureView.getSourceAtXY(eventX, eventY);
                    InteractionFigure drawLayer = ui.getViewEditor().getInteractionFigure();
                    if (sourceFigure != null) {
                        drawLayer.setCursor(WindowUtil.getCursor(WindowUtil.DRAW_CURSOR));
                    } else {
                        drawLayer.setCursor(WindowUtil.getCursor(WindowUtil.SELECT_CURSOR));
                    }
                    break;
                }
            case PotentialDuplicatingFrame:
                {
                    if (withinHysteresis(eventX, eventY)) {
                        break;
                    }
                    duplicatingDynamic = new ArrayList<RectangleFigure>();
                    //populate this from selection state
                    double zoom = ui.getZoom();
                    Iterator<DesignEditorFrame> selectedFrames = selection.getSelectedFrameFigures();
                    while (selectedFrames.hasNext()) {
                        RectangleFigure rect = new RectangleFigure();
                        DesignEditorFrame currFrame = selectedFrames.next();
                        //set size of new rectangle object
                        Rectangle frameSize = currFrame.getBounds();
                        frameSize.height = PrecisionUtilities.round(frameSize.height / zoom);
                        frameSize.width = PrecisionUtilities.round(frameSize.width / zoom);
                        frameSize.x = PrecisionUtilities.round(frameSize.x * zoom);
                        frameSize.y = PrecisionUtilities.round(frameSize.y * zoom);
                        rect.setBounds(frameSize);
                        //add new rectangle object to the array list
                        duplicatingDynamic.add(rect);
                        //display the new rectangle object
                        showSelectionArea(rect);
                    }
                    setMouseState(DuplicatingFrames);
                // fall through!
                }
            case DuplicatingFrames:
                {
                    updateDynamicDuplicate(eventX, eventY);
                    break;
                }
        }
        // Repeating timer for causing events to repeat.
        if ((updateDelta.x != 0) || (updateDelta.y != 0)) {
            if (rootFigure == null) {
                rootFigure = ui.getViewEditor().getInteractionFigure();
            }
            stopMouseDragTimer = false;
            // Determine the new point the mouse "moved" too.
            mouseDragTask.setNextMousePosition(eventX + updateDelta.x, eventY + updateDelta.y, button, state);
            // Queue the event for 0.1 sec.
            WindowUtil.GLOBAL_DISPLAY.timerExec(100, mouseDragTask);
        }
    }
    lastX = eventX;
    lastY = eventY;
    cleanup();
    return goForward;
}
Also used : RectangleFigure(org.eclipse.draw2d.RectangleFigure) StandardDrawingEditor(edu.cmu.cs.hcii.cogtool.view.StandardDrawingEditor) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) GraphicalSource(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalSource) InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class DesignEditorMouseState method updateDynamicMove.

protected void updateDynamicMove(int x, int y, boolean updateModel) {
    double zoom = ui.getZoom();
    double dx = (x / zoom) - scaledMouseDownX;
    double dy = (y / zoom) - scaledMouseDownY;
    Iterator<DesignEditorFrame> frameFigs = selection.getSelectedFrameFigures();
    while (frameFigs.hasNext()) {
        DesignEditorFrame frameFig = frameFigs.next();
        DoublePoint frameOrigin = frameFig.getFrame().getFrameOrigin();
        double newX = frameOrigin.x + dx;
        double newY = frameOrigin.y + dy;
        // Prevent the frame from moving past 0,0
        if (newX < 0) {
            newX = 0;
        }
        if (newY < 0) {
            newY = 0;
        }
        ui.setFigureOrigin(frameFig, newX, newY);
    }
    ui.performRepaintUpdates();
    if (updateModel) {
        ui.performAction(DesignEditorLID.MoveFrames, new DesignEditorUI.MoveParameters(dx, dy, selection));
    }
}
Also used : DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 4 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class DesignEditorMouseState method dealWithMouseDoubleClicked.

@Override
protected boolean dealWithMouseDoubleClicked(IFigure figure, int button, int x, int y, int state) {
    boolean goForward = super.dealWithMouseDoubleClicked(figure, button, x, y, state);
    ui.confirmRenameFrame();
    if (goForward) {
        IFigure target = ui.structureView.getFigureAtXY(x, y, StructureViewUIModel.FRAME_LABEL);
        if (target instanceof DesignEditorFrame.FrameLabel) {
            DesignEditorFrame.FrameLabel frameLabel = (DesignEditorFrame.FrameLabel) target;
            ui.initiateFrameRename(frameLabel.getFrameFigure());
        } else if (target instanceof DesignEditorFrame) {
            Frame frame = ((DesignEditorFrame) target).getFrame();
            ui.performAction(DesignEditorLID.EditFrame, new SingleFrameSelection(frame));
        }
    }
    setMouseState(MouseUp);
    cleanup();
    return goForward;
}
Also used : DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) IFigure(org.eclipse.draw2d.IFigure)

Example 5 with DesignEditorFrame

use of edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame in project cogtool by cogtool.

the class DesignEditorUI method createFrameSelectionHandler.

protected AlertHandler createFrameSelectionHandler() {
    return new AlertHandler() {

        public void handleAlert(EventObject alert) {
            FrameSelectionChange evt = (FrameSelectionChange) alert;
            ActionPropertySet actionProps = view.getActionPropertySet();
            if (evt != null) {
                if (evt.changedFrameFigure != null) {
                    evt.changedFrameFigure.setSelected(evt.selected);
                    // Handle property sheet selection
                    Frame[] selectedFrames = selection.getSelectedFrames();
                    int selectedFrameCount = selectedFrames.length;
                    if (selectedFrameCount > 0) {
                        actionProps.setComposite(ActionPropertySet.FRAME);
                        if (selectedFrameCount == 1) {
                            actionProps.setFrameName(selectedFrames[0]);
                        }
                    } else {
                        actionProps.setComposite(ActionSet.USE_NONE);
                    }
                    actionProps.enableFrameName(selectedFrameCount == 1);
                } else {
                    actionProps.setComposite(ActionSet.USE_NONE);
                    Iterator<DesignEditorFrame> frameFigures = selection.getSelectedFrameFigures();
                    while (frameFigures.hasNext()) {
                        DesignEditorFrame frameFigure = frameFigures.next();
                        frameFigure.setSelected(evt.selected);
                    }
                }
                // Repaint the frame contents
                delayedRepainting.requestRepaint(REPAINT_ALL);
            }
        }
    };
}
Also used : ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) FrameSelectionChange(edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState.FrameSelectionChange) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) DesignEditorFrame(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) EventObject(java.util.EventObject) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

DesignEditorFrame (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorFrame)18 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)8 IFigure (org.eclipse.draw2d.IFigure)5 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 DesignEditorTransition (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)4 EventObject (java.util.EventObject)4 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)3 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)3 GraphicalSource (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalSource)3 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)3 Iterator (java.util.Iterator)3 Point (org.eclipse.draw2d.geometry.Point)3 ActionPropertySet (edu.cmu.cs.hcii.cogtool.view.ActionPropertySet)2 InteractionFigure (edu.cmu.cs.hcii.cogtool.view.InteractionFigure)2 Design (edu.cmu.cs.hcii.cogtool.model.Design)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)1 FrameSelectionChange (edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState.FrameSelectionChange)1 GraphicalChildWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalChildWidget)1 GraphicalParentWidget (edu.cmu.cs.hcii.cogtool.uimodel.GraphicalParentWidget)1