Lecture 5: Conventional Input Models for Window Managers and Toolkits

Slides:



Advertisements
Similar presentations
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
Advertisements

CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
6/13/20151 CS 160: Lecture 13 Professor John Canny Fall 2004.
1 Model View Controller. 2 Outline Review Definitions of MVC Why do we need it? Administiriva Changing the display Event flow Dragging at interactive.
Event Handling. In this class we will cover: Keyboard Events Mouse Events Focus Events Action Interface Multicasting.
1 Lecture 5: Window Manager Input Models Brad Myers Advanced User Interface Software.
Stanford hci group / cs376 research topics in human-computer interaction UI Software Tools Scott Klemmer 27 October 2005.
Welcome to CIS 083 ! Events CIS 068.
1 Lecture 5: Conventional Input Models for Window Managers and Toolkits Brad Myers Advanced User Interface Software © Brad Myers.
BIM211 – Visual Programming Objects, Collections, and Events 1.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Lecture Set 13 Drawing Mouse and Keyboard Events Part B – Mouse and Keyboard Events.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© 2013.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
Interactive Programs Java API. Terminology Event—an action or occurrence, not part of a program, detected by the program. Events can be Event—an action.
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
The structure of Interactive Software
Forms Concepts Triggers Fired when Internal/External events occur
Working in the Forms Developer Environment
Scratch for Interactivity
Event Loops and GUI Intro2CS – weeks
CompSci 230 S Software Construction
Microsoft Access 2007 – Level 2
Advanced User Interfaces
Introduction to Computer CC111
Validating User Input Lesson 5.
Event loops 16-Jun-18.
An Introduction to Computers and Visual Basic
Relational Algebra Chapter 4 1.
Event Driven Programming Dick Steflik
Program and Graphical User Interface Design
Chapter Eleven Handling Events.
CSC461 Lecture 8: Input Devices
Lecture 6: Window Manager Input Models
An Introduction to Computers and Visual Basic
Lesson 1: Buttons and Events – 12/18
Introduction to Events
Windows Desktop Applications
Chap 7. Building Java Graphical User Interfaces
User Interface Software Look under the hood
Visual Basic Properties, Methods and Events
Topic 8: (Last two papers)
Introduction to Computing Using Java
Graphics -- Introduction
Relational Algebra Chapter 4 1.
Event loops.
Tutorial 6 Creating Dynamic Pages
GRAPHICAL USER INTERFACE
More programming with "Processing"
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Getting Started with Adobe Illustrator CS6
An Introduction to Computers and Visual Basic
Professor John Canny Spring 2004 March 5
European Computer Driving Licence
6. WinForms 2003 C# GUI - Basics.
Event loops 8-Apr-19.
Input & Output CS 422: UI Design and Programming
Event loops.
Professor John Canny Spring 2003 March 12
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Lecture 5: Conventional Input Models for Window Managers and Toolkits Brad Myers 05-830 Advanced User Interface Software © 2017 - Brad Myers

Homework 2 lineThickness of outlineRects and lines Review of required algorithm © 2017 - Brad Myers

Objects defined by properties 50 50 100 100 200 200 200 200 Object title: Square Shape: square Corner location: (100, 50) Height: 200 Width: Color: red Object title: Square Shape: square Corner location: (100, 50) Height: 200 Width: Color: red © 2017 - Brad Myers blue

Displaying Multiple Objects Object title: Square 1 Shape: square Corner location: (100, 50) Height: 300 Width: Color: blue Object title: Rectangle 1 Shape: rectangle Corner location: (250, 300) Height: 100 Width: 250 Color: green Object title: Circle 1 Shape: circle Center: (400, 300) Radius: 100 Color: red Object title: Circle 2 Shape: circle Center: (600, 400) Radius: 100 Color: orange © 2017 - Brad Myers

Redrawing When Objects Are Moved Changing attributes of one object may require redraw of others. Area must be redrawn 1st Boundary Box Object title: Square 1 Shape: square Corner location: (100, 50) Height: 300 Width: Color: blue Object title: Rectangle 1 Shape: rectangle Corner location: (250, 300) Height: 100 Width: 250 Color: green Object title: Circle 1 Shape: circle Center: (400, 300) Radius: 100 Color: red Object title: Circle 2 Shape: circle Center: (600, 400) Radius: 100 Color: orange (400, 75) © 2017 - Brad Myers

Redrawing From Back To Front Redraw operations are required for all affected objects. 2nd Boundary Box Objects redrawn from back to front to repair “damage” This object not redrawn 1st Boundary Box Object title: Square 1 Shape: square Corner location: (100, 50) Height: 300 Width: Color: blue Object title: Rectangle 1 Shape: rectangle Corner location: (250, 300) Height: 100 Width: 250 Color: green Object title: Circle 1 Shape: circle Center: (400, 75) Radius: 100 Color: red Object title: Circle 2 Shape: circle Center: (600, 400) Radius: 100 Color: orange © 2017 - Brad Myers

Operations Requiring No Redrawing Some operations may require that no objects be redrawn. No redraw necessary Delete object Boundary Box DELETE Object title: Square 1 Shape: square Corner location: (100, 50) Height: 300 Width: Color: blue Object title: Rectangle 1 Shape: rectangle Corner location: (250, 300) Height: 100 Width: 250 Color: green Object title: Circle 1 Shape: circle Center: (400, 75) Radius: 100 Color: red Object title: Circle 2 Shape: circle Center: (600, 400) Radius: 100 Color: orange © 2017 - Brad Myers

Redraw algorithm Group Hierarchy Note coordinate systems Reference: David S. Kosbie, Brad Vander Zanden, Brad A. Myers, Dario Giuse. "Automatic Graphical Output Management", in Brad A. Myers, editor. The Garnet Compendium: Collected Papers, 1989-1990. Carnegie Mellon University School of Computer Science Technical Report, no. CMU-CS-90-154, August, 1990. pp. 30-43. pdf. Group Hierarchy Note coordinate systems © 2017 - Brad Myers

Multi-pass Refresh algorithm Keep track of objects whose slots have changed Can have “group” keep track by having each graphical object call “damage” on its container group passing in the object‘s bounding box Groups propagate damage rectangles up to the top Careful about coordinates Combine damage rectangles Call “redraw” on top-level group Intersect each component with composite damage rectangle If intersect, then redraw all children, back to front © 2017 - Brad Myers

Input © 2017 - Brad Myers

Quotes “One of the most complex aspects of Xlib programming is designing the event loop, which must take into account all of the possible events that can occur in a window.” -- Nye & O'Reilly X Toolkit Intrinsics Programming Manual, vol. 4, 1990, p. 241. “The dispatching and handling of events is rather complicated.” -- Galaxy Reference Manual, v1.2, p. 20-5. © 2017 - Brad Myers

How Keyboard and Mouse Events are Handled Most window manager and toolkits use the same model Quite old and has problems © 2017 - Brad Myers

First issue: Which Window? Called “focus” Old name: “active” window Click to Type Move to Type Affects what kinds of interactions are possible Mac single menubar not possible with move-to-type © 2017 - Brad Myers

Event Records Structures (records) composed of all information about events Created by window manager, sent to a queue for each window X defines 33 different types of events Except for selectionRequest, the X/11 “*request” events are only for window managers © 2017 - Brad Myers

X Event Types visibilityNotify (become covered) resizeRequest circulateNotify (stacking order) configureNotify (resize or move) destroyNotify (was destroyed) gravityNotify (moved due to gravity) mapNotify (became visible) createNotify reparentNotify (in diff. window) unmapNotify (invisible) circulateRequest configureRequest mapRequest mappingNotify (keyboard mapping) clientMessage selectionClear (for cut and paste) selectionNotify selectionRequest buttonPress keyPress keyRelease buttonRelease motionNotify enterNotify leaveNotify focusIn focusOut keymapNotify (change keymap) Expose graphicsExpose (source of copy not available) noExpose (source of copy is available) colormapNotify propertyNotify (some property changed) © 2017 - Brad Myers

Windows .Net Events AutoSizeChanged BackColorChanged BackgroundImageChanged BackgroundImageLayoutChanged BindingContextChanged CausesValidationChanged ChangeUICues Click ClientSizeChanged ContextMenuChanged ContextMenuStripChanged ControlAdded ControlRemoved CursorChanged Disposed DockChanged DoubleClick DragDrop DragEnter DragLeave DragOver EnabledChanged Enter FontChanged ForeColorChanged GiveFeedback GotFocus HandleCreated HandleDestroyed HelpRequested ImeModeChanged Invalidated KeyDown KeyPress KeyUp Layout Leave LocationChanged LostFocus MarginChanged MouseCaptureChanged MouseClick MouseDoubleClick MouseDown MouseEnter MouseHover MouseLeave MouseMove MouseUp MouseWheel Move PaddingChanged Paint ParentChanged PreviewKeyDown QueryAccessibilityHelp QueryContinueDrag RegionChanged Resize RightToLeftChanged SizeChanged StyleChanged SystemColorsChanged TabIndexChanged TabStopChanged TextChanged Validated Validating VisibleChanged © 2017 - Brad Myers Source: http://msdn.microsoft.com/en-us/library/1dk48x94.aspx

Other events Java has events for: Visual Basic has events for: MouseMove vs. MouseDrag Java event hierarchy starts from java.awt.AWTEvent Many special events: PaintEvent, WindowEvent, HierarchyEvent, etc. Java event tutorial Visual Basic has events for: Drag Drop Timer MouseWheel iOS (iPhone): accelerometer; remote controls HTML/CSS supports Hover In X, a window specifically declares which events they want to receive using event masks Reduces network traffic and unnecessary processing Event masks also used for other things in X “pointerGrab” Source: http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/Introduction/Introduction.html © 2017 - Brad Myers

Event Modifiers Which “modifier” keys Shift, Control, Alt, Function, Command (Mac), Num-Lock Various combinations Can get events when Shift, etc. goes down, but usually ignored Single click, double-click, triple-click, etc. Click vs. Down vs. Drag Amulet supports string parsing of names: “SHIFT_CONTROL_DOUBLE_LEFT_DOWN” © 2017 - Brad Myers

Gestural “Events” Gestures might come in as if they were regular events So lower-level code doesn’t need to distinguish Android has separate “gesture” classes iOS: Gesture Recognizers Amulet: added at higher level, as “commands” (see next lecture) © 2017 - Brad Myers

Event Handling Toolkits (e.g., Visual Basic) automatically handle expose and some other events for the widgets. Structured graphics systems (e.g., Amulet) automatically handle many of the events. Events (in X) are C-language union type of many event structures that are all the same size but with different field names. Key and mouse events contain (at least): x position of the mouse y position of the mouse window of the mouse event type event code event modifiers timestamp © 2017 - Brad Myers

Examples Amulet lowest levels: Issue: new types of events Big switch statement gemW_draw.cc (see MainWndProc) gemX_input.cc (see Am_Handle_Event_Received) Issue: new types of events E.g, tablet eraser on stylus, proximity Gesture, mouse wheel events, like scroll New types of devices: e.g., hardware widgets © 2017 - Brad Myers

Waiting for Events Java listeners for events Low-level routine that waits for event wants to be blocking rather than polling for efficiency Calls specified routines when events arrive Macintosh (used to?) use polling for mouse location Toolkits provide this internally, e.g.: XtAppMainLoop(...) Am_Main_Event_Loop() in Amulet Can specify timeouts so notified after certain time if no events Can ask X to flush multiple motion events If not handled fast enough, get weird lag Garnet tries to do extra flushing to avoid this Not an issue if polling for motion events Problem for polylines, gestures, etc. Java listeners for events © 2017 - Brad Myers

Architectures Old: giant switch statement per window Branch for each event But not dependent on mode, which object, etc. “MainEventLoop” in Amulet’s implementation Global event handlers for each type of event No matter where that event happens in the window E.g., per Activity in Android Specific event handlers per object Java Swing: button1.addActionListener(this); Android: View event listeners (since widgets are views) But only works if knows where the objects are Lots of issues with multiple threading © 2017 - Brad Myers

Propagation Events sent to the lowest level window containing the pointer. If event not selected with event-mask, then sent to the container window, etc. Can't specify individual keys (get all keys and may have to explicitly resend events) Handlers often will get to say whether they handled the event or not Android: onXXXX() handlers return booleans © 2017 - Brad Myers

Issue: Covering Which objects get an event when overlapping “Z” order vs. containment What about when top object doesn’t want event? Can’t necessarily use obj.contains(eventX, eventY) Input mechanism must know about graphical objects Bounding box vs. on object Complexities: http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/event_delivery_responder_chain/event_delivery_responder_chain.html#//apple_ref/doc/uid/TP40009541-CH4-SW2 © 2017 - Brad Myers

Issue: Event Priorities When already interacting, need to give priority to current interaction While dragging, who gets mouse move events? Issue: if mouse is moved too fast & gets outside of the object While text editing Current field gets all text events, no matter where mouse is What if leave the window? Interacts with Click vs. move to type Cross-window drag & drop © 2017 - Brad Myers

Translation Tables So particular mouse key or keyboard key not hard-wired into application. Allows user customization and easier changes Supported in Motif by the resources mechanism e.g. Shift<Btn1Down>: doit() can be put in .Xdefaults, and then application deals with doit, and user can change bindings. Keyboard translation is 2 step process in X: Hardware "keycodes" numbers mapped to "keysyms" "Keysyms" translated to events For double-clicking, Motif does translation, but not Xlib For non-widgets, have to do it yourself Always also get the single click events Java – no built-in double click support Does have click vs. drag © 2017 - Brad Myers

Issue: Scrolling Refresh Race condition when copy from an area that might be covered X/11 provides graphicsExpose and noExpose events © 2017 - Brad Myers