Search in sources :

Example 1 with TapPressType

use of edu.cmu.cs.hcii.cogtool.model.TapPressType in project cogtool by cogtool.

the class ActionSet method createTouchComposite.

protected Composite createTouchComposite() {
    Composite touchComp = new Composite(actionSettings, SWT.NONE);
    touchComp.setLayout(new FormLayout());
    touchActionLabel = new DisplayLabel(touchComp, SWT.NONE);
    touchActionLabel.setText(L10N.get("DE.ButtonActionCaption", "Action") + ":");
    // TODO Why is this here rather than in its natural home in the
    //      overridden method in ActionPropertySet?
    transitionSourceLabelTouch = createTransitionSourceLabel(touchComp);
    transitionSourceNameTouch = createTransitionSourceName(touchComp);
    transitionDestinationLabelTouch = createTransitionDestinationLabel(touchComp);
    transitionDestinationNameTouch = createTransitionDestinationName(touchComp);
    touchActionCombo = new ComboWithEnableFix(touchComp, SWT.DROP_DOWN | SWT.READ_ONLY);
    for (TapPressType element : TapPressType.DISPLAY) {
        touchActionCombo.add(element.toString());
    }
    touchActionCombo.select(0);
    touchActionCombo.addSelectionListener(widgetActionChange);
    return touchComp;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) TapPressType(edu.cmu.cs.hcii.cogtool.model.TapPressType) Composite(org.eclipse.swt.widgets.Composite) ComboWithEnableFix(edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix) DisplayLabel(edu.cmu.cs.hcii.cogtool.util.DisplayLabel)

Example 2 with TapPressType

use of edu.cmu.cs.hcii.cogtool.model.TapPressType in project cogtool by cogtool.

the class SEDemoMouseState method doTransitionAction.

protected boolean doTransitionAction(TransitionSource source, int button, int state, int clickState) {
    AAction action = null;
    Set<DeviceType> deviceTypes = ui.design.getDeviceTypes();
    if (deviceTypes.contains(DeviceType.Mouse)) {
        MousePressType pt = null;
        switch(clickState) {
            case UP:
                pt = MousePressType.Up;
                break;
            case DOWN:
                pt = MousePressType.Down;
                break;
            case CLICK:
                pt = MousePressType.Click;
                break;
            case DOUBLE:
                pt = MousePressType.Double;
                break;
            case TRIPLE:
                pt = MousePressType.Triple;
                break;
            default:
                throw new IllegalArgumentException("Invalid click state received");
        }
        action = new ButtonAction(getActionButtonButton(button), pt, getActionButtonModifier(state));
    } else if (deviceTypes.contains(DeviceType.Touchscreen)) {
        TapPressType tt = null;
        switch(clickState) {
            case UP:
                tt = TapPressType.Up;
                break;
            case DOWN:
                tt = TapPressType.Down;
                break;
            case CLICK:
                tt = TapPressType.Tap;
                break;
            case DOUBLE:
                tt = TapPressType.DoubleTap;
                break;
            case TRIPLE:
                tt = TapPressType.TripleTap;
                break;
            default:
                throw new IllegalArgumentException("Invalid ClickState received");
        }
        action = new TapAction(tt);
    }
    if (clickState == CLICK) {
        if (source.getTransition(action) == null) {
            // Check to see if a doubleclick/doubletap is in the set of
            // transitions
            Iterator<AAction> iter = source.getTransitions().keySet().iterator();
            while (iter.hasNext()) {
                AAction act = iter.next();
                if ((act.getType() == ActionType.ButtonPress) && deviceTypes.contains(DeviceType.Mouse)) {
                } else if ((act.getType() == ActionType.Tap) && deviceTypes.contains(DeviceType.Touchscreen)) {
                }
            }
            if ((source instanceof IWidget) && ((IWidget) source).isStandard() && deviceTypes.contains(DeviceType.Mouse)) {
                WidgetType type = ((IWidget) source).getWidgetType();
                Object toggle = source.getAttribute(WidgetAttributes.IS_TOGGLEABLE_ATTR);
                Object isSep = source.getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
                if ((type == WidgetType.Check) || (type == WidgetType.Radio) || ((type == WidgetType.PullDownItem) && NullSafe.equals(WidgetAttributes.NON_SEPARATOR, isSep)) || ((type == WidgetType.Button) && NullSafe.equals(WidgetAttributes.IS_TOGGLEABLE, toggle))) {
                    if (type == WidgetType.PullDownItem) {
                        ui.hideAllChildren();
                    }
                    AAction a = new ButtonAction(MouseButtonState.Left, MousePressType.Click, 0);
                    SEDemoUI.SelfTransition prms = new SEDemoUI.SelfTransition(ui.selection, source, a);
                    ui.performAction(SEDemoLID.InsertSelfTransition, prms);
                    return true;
                }
            }
            ui.showContextMenu(source);
        }
    }
    Transition transition = source.getTransition(action);
    if (transition != null) {
        SEDemoUI.FollowTransition prms = new SEDemoUI.FollowTransition(ui.selection, transition);
        ui.performAction(SEDemoLID.PerformTransition, prms);
        return true;
    }
    return false;
}
Also used : ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) TapAction(edu.cmu.cs.hcii.cogtool.model.TapAction) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) TapPressType(edu.cmu.cs.hcii.cogtool.model.TapPressType) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) MousePressType(edu.cmu.cs.hcii.cogtool.model.MousePressType) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 3 with TapPressType

use of edu.cmu.cs.hcii.cogtool.model.TapPressType in project cogtool by cogtool.

the class DesignExportToHTML method getMenuMap.

/**
	 * Return an array of three strings, corresponding to the three possible
	 * mouse buttons, representing either the name of the frame transitioned to
	 * by that button, or 'null'.
	 * NOTE: Hover and multiple-click transitions don't work with menu items.
	 */
protected String getMenuMap(MenuItem child) {
    String result = "[";
    // TODO: onmouseup doesn't work for middle clicks...except
    // sometimes it does, may be related to focus?
    // Always use onmouseup instead of onclick because we need to check
    // for double click here too
    String[] mouseUpDests = new String[4];
    mouseUpDests[0] = "null";
    int mouseUpButton = 0;
    Iterator<Transition> transitions = child.getTransitions().values().iterator();
    while (transitions.hasNext()) {
        Transition transition = transitions.next();
        AAction action = transition.getAction();
        if (action instanceof ButtonAction) {
            ButtonAction bAction = (ButtonAction) action;
            MouseButtonState buttonState = bAction.getButton();
            MousePressType pressType = bAction.getPressType();
            int button = -1;
            String destName = getFrameURL(transition.getDestination(), ".html");
            if (!MousePressType.Hover.equals(pressType)) {
                if (MouseButtonState.Left.equals(buttonState)) {
                    button = LEFT_MOUSE;
                } else if (MouseButtonState.Middle.equals(buttonState)) {
                    button = MIDDLE_MOUSE;
                } else if (MouseButtonState.Right.equals(buttonState)) {
                    button = RIGHT_MOUSE;
                }
                /*if (MousePressType.Click.equals(pressType) &&
                        (button == LEFT_MOUSE))
                    {
                        //onAction = "onclick";
//                        clickDest = "'" + destName + "'";
                        mouseUpButton = button;
                        mouseUpDests[mouseUpButton] = "'" + destName + "'";
                    }
                    else */
                if (MousePressType.Up.equals(pressType) || MousePressType.Click.equals(pressType)) {
                    //onAction = "onmouseup";
                    mouseUpButton = button;
                    mouseUpDests[mouseUpButton] = "'" + destName + "'";
                }
            //                    else if (MousePressType.Double.equals(pressType)) {
            //                        //onAction = "ondblclick";
            //                        dblClickButton = button;
            //                        dblClickDests[dblClickButton] = "'" + destName + "'";
            //                    }
            //                  else if (MousePressType.Down.equals(pressType)) {
            //                      onAction = "onmousedown";
            //                  }
            }
        } else if (action instanceof TapAction) {
            TapAction bAction = (TapAction) action;
            TapPressType pressType = bAction.getTapPressType();
            String destName = getFrameURL(transition.getDestination(), ".html");
            if (!TapPressType.Hover.equals(pressType)) {
                if (TapPressType.Tap.equals(pressType)) {
                    // TODO: Behavior is undefined if both a left-click and
                    // tap transition are created from the same widget!
                    //onAction = "onclick";
                    //                        clickDest = "'" + destName + "'";
                    mouseUpButton = LEFT_MOUSE;
                    mouseUpDests[mouseUpButton] = "'" + destName + "'";
                }
            //                  else if (TapPressType.Up.equals(pressType)) {
            //                      onAction = "onmouseup";
            //                  }
            //                    else if (TapPressType.DoubleTap.equals(pressType)) {
            //                        //onAction = "ondblclick";
            //                        // TODO see tap
            //                        dblClickButton = LEFT_MOUSE;
            //                        dblClickDests[dblClickButton] = "'" + destName + "'";
            //                    }
            //                  else if (TapPressType.Down.equals(pressType)) {
            //                      //onAction = "onmousedown";
            //                  }
            }
        }
    }
    for (int i = 1; i < mouseUpDests.length; i++) {
        if (mouseUpDests[i] == null) {
            mouseUpDests[i] = "null";
        }
        //            if (dblClickDests[i] == null) {
        //                dblClickDests[i] = "null";
        //            }
        result += mouseUpDests[i];
        if (i < 3) {
            result += ", ";
        }
    }
    result += "]";
    return result;
}
Also used : TapPressType(edu.cmu.cs.hcii.cogtool.model.TapPressType) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) MousePressType(edu.cmu.cs.hcii.cogtool.model.MousePressType) TapAction(edu.cmu.cs.hcii.cogtool.model.TapAction) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) MouseButtonState(edu.cmu.cs.hcii.cogtool.model.MouseButtonState)

Example 4 with TapPressType

use of edu.cmu.cs.hcii.cogtool.model.TapPressType in project cogtool by cogtool.

the class DesignExportToHTML method parseTransitions.

/**
	 * Given the transitions from a widget, parse them and return 3 strings:
	 * first, the name of the destination frame of its hover transition;
	 * second, the map that defines its single click transitions;
	 * third, the map that defines its double click transitions.
	 * (See comments on the javascript functions for how these maps are used.)
	 */
protected String[] parseTransitions(IWidget w, boolean checkFocus, int ignoreButton) {
    String[] result = new String[2];
    result[0] = "null";
    result[1] = "[";
    // TODO: onmouseup doesn't work for middle clicks...except
    // sometimes it does, may be related to focus?
    // Always use onmouseup instead of onclick because we need to check
    // for double click here too
    Iterator<Transition> transitions = w.getTransitions().values().iterator();
    // If we are told to ignore transitions from a certain button, check
    // if the widget has any transitions defined from that button.  If not,
    // tell the javascript explicitly not to pop up the "does not help..."
    // message if that button is clicked with the IGNORE_LEFT_CLICK string
    // flag.
    boolean hasIgnoredButtonTransition = false;
    while (transitions.hasNext()) {
        Transition transition = transitions.next();
        AAction action = transition.getAction();
        if (action instanceof ButtonAction) {
            ButtonAction bAction = (ButtonAction) action;
            MouseButtonState buttonState = bAction.getButton();
            MousePressType pressType = bAction.getPressType();
            int button = -1;
            String destName = getFrameURL(transition.getDestination(), ".html");
            int modifiers = bAction.getModifiers();
            int numClicks = 0;
            if (MousePressType.Hover.equals(pressType)) {
                result[0] = "'" + destName + "'";
            } else {
                if (MouseButtonState.Left.equals(buttonState)) {
                    button = LEFT_MOUSE;
                    if (checkFocus) {
                        destName += buildFocusSearch(w, transition.getDestination());
                    }
                } else if (MouseButtonState.Middle.equals(buttonState)) {
                    button = MIDDLE_MOUSE;
                } else if (MouseButtonState.Right.equals(buttonState)) {
                    button = RIGHT_MOUSE;
                }
                if (MousePressType.Up.equals(pressType) || MousePressType.Click.equals(pressType)) {
                    numClicks = 1;
                    if ((button == ignoreButton) && (modifiers == AAction.NONE)) {
                        hasIgnoredButtonTransition = true;
                    }
                } else if (MousePressType.Double.equals(pressType)) {
                    numClicks = 2;
                } else if (MousePressType.Triple.equals(pressType)) {
                    numClicks = 3;
                }
                if (result[1].length() > 1) {
                    result[1] += ", ";
                }
                result[1] += "[" + button + ", " + numClicks + ", " + modifiers + ", '" + destName + "']";
            }
        } else if (action instanceof TapAction) {
            TapAction bAction = (TapAction) action;
            TapPressType pressType = bAction.getTapPressType();
            String destName = getFrameURL(transition.getDestination(), ".html");
            int numClicks = 0;
            if (TapPressType.Hover.equals(pressType)) {
                result[0] = "'" + destName + "'";
            } else {
                if (TapPressType.Up.equals(pressType) || TapPressType.Tap.equals(pressType)) {
                    // TODO: Behavior is undefined if both a left-click and
                    // tap transition are created from the same widget!
                    numClicks = 1;
                    if (ignoreButton == 1) {
                        hasIgnoredButtonTransition = true;
                    }
                } else //                  }
                if (TapPressType.DoubleTap.equals(pressType)) {
                    //onAction = "ondblclick";
                    // TODO see tap
                    numClicks = 2;
                } else if (TapPressType.TripleTap.equals(pressType)) {
                    // TODO see tap
                    numClicks = 3;
                }
                if (result[1].length() > 1) {
                    result[1] += ", ";
                }
                result[1] += "[" + LEFT_MOUSE + ", " + numClicks + ", " + AAction.NONE + ", '" + destName + "']";
            }
        }
    }
    if (!hasIgnoredButtonTransition) {
        // transition already defined
        if (result[1].length() > 1) {
            result[1] += ", ";
        }
        result[1] += "[" + ignoreButton + ", 1, 0, " + IGNORE_LEFT_CLICK + "]";
    }
    result[1] += "]";
    return result;
}
Also used : TapPressType(edu.cmu.cs.hcii.cogtool.model.TapPressType) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) MousePressType(edu.cmu.cs.hcii.cogtool.model.MousePressType) TapAction(edu.cmu.cs.hcii.cogtool.model.TapAction) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) MouseButtonState(edu.cmu.cs.hcii.cogtool.model.MouseButtonState) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Aggregations

TapPressType (edu.cmu.cs.hcii.cogtool.model.TapPressType)4 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)3 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)3 MousePressType (edu.cmu.cs.hcii.cogtool.model.MousePressType)3 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)3 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)3 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)2 MouseButtonState (edu.cmu.cs.hcii.cogtool.model.MouseButtonState)2 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)1 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)1 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)1 ComboWithEnableFix (edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix)1 DisplayLabel (edu.cmu.cs.hcii.cogtool.util.DisplayLabel)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Composite (org.eclipse.swt.widgets.Composite)1