ui toolkits - github pagesuwdata.github.io/hcid520/17wi/lectures/01-uitoolkits.pdf · for...

52
UI Toolkits HCID 520 User Interface Software & Technology

Upload: others

Post on 14-Jul-2020

25 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

UI Toolkits

HCID 520 User Interface Software & Technology

Page 2: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

http://www.cryptonomicon.com/beginning.html

Page 3: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Xerox Alto 1973

Page 4: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Command Line (UNIX shell, DOS prompt) Interaction driven by system User prompted for input when needed Text-based input and output

Event-Driven Interfaces (GUIs) Interaction driven by user System waits for user action and responds Pointing & text input, graphical output More complex architecture & development

Evolution of User Interfaces

Page 5: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Component Model

Page 6: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target
Page 7: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target
Page 8: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target
Page 9: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target
Page 10: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Encapsulate interactive components (widgets) Component library (button, slider, container) Interface built as a hierarchy of components

Widgets drawn by underlying graphics library

Input event generation and dispatch Historically mouse & keyboard, now touch, …

Bounds management & damage/redraw Model geometry, redraw updated regions only

Component (Widget) Model

Page 11: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

User Interface Components

Each component (widget) is an object with: A bounding box A method for drawing itself Drawn in the component’s coordinate system

Methods (callbacks) to process input events

public void paint(Graphics g) { g.fillRect(…); // interior g.drawString(…); // label g.drawRect(…); // outline }

Page 12: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

User Interface ComponentsLabel TextArea

ButtonsEach component has its own 2D coordinate system.

Page 13: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Containment HierarchyWindow

Panel

TextArea Panel

Button Button

Label

Page 14: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Component LayoutWindow

Panel

TextArea Panel

Button Button

Label

Each container is responsible for positioning its contents.

Page 15: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Event-Driven Architecture

Page 16: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

User input is modeled as events. Events are dispatched to components for processing.

Events

Page 17: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

User input is modeled as events. Events are dispatched to components for processing.

Hardware Events Mouse: move, button-down, button-up Keyboard: key-down, key-up

Events

Page 18: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

User input is modeled as events. Events are dispatched to components for processing.

Hardware Events Mouse: move, button-down, button-up Keyboard: key-down, key-up

Inferred Events Mouse: click, double-click, enter, exit, drag Keyboard: key-press Window: move, resize

Events

Page 19: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Events encapsulate the information needed for components to react to input or changes.

Event Type (mouse moved, key down, etc) Event Target (the input component) Timestamp (when did event occur) Modifiers (Ctrl, Shift, Alt, etc) Event Content: Mouse: x,y coordinates, button pressed, # clicks Keyboard: which key was pressed

Anatomy of an Event

Page 20: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Go to http://mhcid.washington.edu Open the JavaScript console, enter: var h = document.querySelector("header"); h.addEventListener("click", function(event) { console.log(event); });

Click the header region at the top of the page. Inspect the events in the JavaScript console.

Demo: Browser DOM Events

Page 21: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target
Page 22: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Event Dispatch Loop

Event Queue List of input events

Component Invoked callback method Update application state Request repaint, if needed

Mouse moved (t0,x,y)

Event Loop (runs in dedicated thread)

Remove next event from queue Determine event type Dispatch to proper component(s) Invoke callbacks on components Continue, or wait until event arrives

Page 23: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Event Dispatch Loop

Page 24: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Event Dispatch Loop

Mouse moved (t0,x,y)

Page 25: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Event Dispatch Loop

Event Queue List of input events

Mouse moved (t0,x,y)

Page 26: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Event Dispatch Loop

Event Queue List of input events

Mouse moved (t0,x,y)

Event Loop (runs in dedicated thread)

Remove next event from queue Determine event type Dispatch to proper component(s) Invoke callbacks on components Continue, or wait until event arrives

Page 27: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Event Dispatch Loop

Event Queue List of input events

Event Loop (runs in dedicated thread)

Remove next event from queue Determine event type Dispatch to proper component(s) Invoke callbacks on components Continue, or wait until event arrives

Component Invoked callback method Update application state Request repaint, if needed

Mouse moved (t0,x,y)

Page 28: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Window

Panel

TextArea Panel

Button Button

Label

Event Queue Mouse moved (t0,x,y) Mouse pressed (t1,x,y,1) Mouse dragged (t2,x,y,1) Key typed (t3, ‘F1’) …

Event Dispatch

Page 29: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Window

Panel

TextArea Panel

Button Button

Label

Event Queue Mouse moved (t0,x,y) Mouse pressed (t1,x,y,1) Mouse dragged (t2,x,y,1) Key typed (t3, ‘F1’) …

Event Dispatch

Page 30: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Window

Panel

TextArea Panel

Button Button

Label

Event Queue Mouse moved (t0,x,y) Mouse pressed (t1,x,y,1) Mouse dragged (t2,x,y,1) Key typed (t3, ‘F1’) …

Event Dispatch

Page 31: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Window

Panel

TextArea Panel

Button Button

Label

Event Queue Mouse moved (t0,x,y) Mouse pressed (t1,x,y,1) Mouse dragged (t2,x,y,1) Key typed (t3, ‘F1’) …

Event Dispatch

Page 32: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Window

Panel

TextArea Panel

Button Button

Label

Event Queue Mouse moved (t0,x,y) Mouse pressed (t1,x,y,1) Mouse dragged (t2,x,y,1) Key typed (t3, ‘F1’) …

Event Dispatch

Page 33: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Window

Panel

TextArea Panel

Button Button

Label

Event Queue Mouse moved (t0,x,y) Mouse pressed (t1,x,y,1) Mouse dragged (t2,x,y,1) Key typed (t3, ‘F1’) …

/* callback for TextArea */ function mouseMoved(evt) { // process mouse moved event }

Event Dispatch

Page 34: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

UI Tools Discussion

Page 35: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Brief UI tool history, establish vocabulary in wide use today, and chart future trajectories.

At any point did they “miss the mark”?

Myers, Hudson & Pausch

Page 36: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Brief UI tool history, establish vocabulary in wide use today, and chart future trajectories.

At any point did they “miss the mark”? Web: subsuming many desktop applications Design vs. Dev: In practice often done by teams with varied skills (interaction design, graphic design, implementation) 3D: Mostly limited to games? BUT fabrication now likely to drive new 3D design tools. VR?

Myers, Hudson & Pausch

Page 37: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Not just for desktop GUI widgets & events Mobile applications (iOS, Android) Information visualization (d3.js, Protovis, Prefuse) Tangible user interfaces (Papier-Maché) Gestural user interfaces (Kinect API) Speech user interfaces (MS Speech API) Proxemic user interfaces (Proximity Toolkit)

Many exhibit similar tensions around expressiveness, efficiency and ease-of-use

Toolkits Abound…

Page 38: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Simplify & accelerate UI development Lower the threshold of specification difficulty Raise the ceiling of what can be expressed But hard to do both! Establish path of least resistance Makes common / successful designs easy Makes unusual / ineffective designs harder Can limit & shape what we conceive / design Enforce consistency of design Maintain familiar widgets and interactions

Toolkit Benefits & Shortcomings

Page 39: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

E X E R C I S E 1 Widget Design

Page 40: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Hello

Page 41: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Hello

Default State

Page 42: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Hello

Default State

Data: styling, content, etc.

Page 43: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Hello

Default State

Data: styling, content, etc.

https://dribbble.com/shots/361683-Color-checkboxes

http://pixelmonarchy.com/resources/form-checkboxes-and-radio-buttons-sky-ui-kit-psd/ https://www.filterforge.com/forum/read.php?

FID=9&TID=10550 Origin Unknown.

Page 44: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Hello

Checked State

https://dribbble.com/shots/361683-Color-checkboxes

http://pixelmonarchy.com/resources/form-checkboxes-and-radio-buttons-sky-ui-kit-psd/

https://www.filterforge.com/forum/read.php?FID=9&TID=10550 Origin Unknown.

Page 45: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Disabled-UncheckedDisabled-CheckedFocusMaybe-Checked

https://www.google.com/design/spec/components/selection-controls.html

https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/The_native_form_widgets

https://www.filterforge.com/forum/read.php?FID=9&TID=10550 Origin Unknown.

http://developer.att.com/technical-library/ui-elements/html5-checkboxes

http://www.telerik.com/forums/how-to-select-checkbox-as-indeterminate-father

Page 46: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target
Page 47: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

State Diagram to the Rescue

Default

CheckedClick

ClickDisabled

Page 48: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

State Diagram to the Rescue

Default

CheckedClick

Disabled

Maybe

Click

Click

Page 49: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

State Diagram to the Rescue

Default

CheckedClick

Disabled

Maybe

Click

Click

Shift- Click

Page 50: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Your Turn! Submit

! In pairs, brainstorm the states + transitions for a submit button.

! What does the button look like in each state? ! What are the transitions between states? ! What actions trigger the transitions? ! How does a user know what to do?

! Regroup in ~10 mins to share ideas.

Page 51: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Your Turn!

! In pairs, brainstorm the states + transitions for a textbox.

! Hint: States+transitions for the textbox but also its contents (e.g., text selection).

! Regroup in ~10 mins to share ideas.

I am a textbox

Page 52: UI Toolkits - GitHub Pagesuwdata.github.io/hcid520/17wi/lectures/01-UIToolkits.pdf · for components to react to input or changes. Event Type (mouse moved, key down, etc) Event Target

Your Turn: Interactive Prototypes

http://uwdata.github.io/hcid520/17wi/ex1/