Event-driven Programming: GUIs

Similar documents
User Interaction. User Interaction. Input devices. Input devices. Input devices GUIs and GUI design Event-driven programming 3D interaction

CSE 331 Software Design & Implementation

Lecture 19 GUI Events

CSE 331 Software Design and Implementation. Lecture 19 GUI Events

Event Driven Programming

CMSC427 Interac/ve programs in Processing: Polyline editor

MOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface?

Windows and Events. created originally by Brian Bailey

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

UI Toolkits. HCID 520 User Interface Software & Technology

Composite Pattern Diagram. Explanation. JavaFX Subclass Hierarchy, cont. JavaFX: Node. JavaFX Layout Classes. Top-Level Containers 10/12/2018

User Interfaces for Web Sites and Mobile Devices. System and Networks

CS 4300 Computer Graphics

Model-View-Controller

RHINO SURFACE MAKING PART 1

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

Solutions to Chapter Exercises. GUI Objects and Event-Driven Programming

Case studies: Outline Case Study: Noughts and Crosses

stanford hci group / cs376 UI Software Tools Scott Klemmer 14 October research topics in human-computer interaction

GUI Software Architecture

We will talk about Alt-Tab from the usability perspective. Think about: - Is it learnable? - Is it efficient? - What about errors and safety?

Graphical User Interfaces 2

TYPES OF INTERACTORS Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill

CSE 331. Model/View Separation and Observer Pattern

GUI Implementation Support

CS 116x Winter 2015 Craig S. Kaplan. Module 03 Graphical User Interfaces. Topics

UI Toolkits. HCID 520 User Interface Software & Technology

Widget. Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down

Chapter 0 : MVC review / Threading & Concurrency. CSCI 251 Android App Development

P2: Collaborations. CSE 335, Spring 2009

UI Toolkits. HCID 520 User Interface Software & Technology

Index. Guide. Camera Detect Event Guide. AcuraVision

Association, Aggregation and Composition. Software Engineering CITS1220

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Model-view-controller View hierarchy Observer

C30c: Model-View-Controller and Writing Larger JavaFX Apps

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. 2.4 Event Dispatch 1

Generating Vectors Overview

Event Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. Event Architecture. A pipeline: Event Capture

Fall UI Design and Implementation 1

Software System/Design & Architecture. Eng.Muhammad Fahad Khan Assistant Professor Department of Software Engineering

Java Programming. Events and Listeners

Module 2. Input and output devices Page 11

Model-View-Controller Architecture

The Rectangular Problem

Java Concurrency in practice Chapter 9 GUI Applications

Graphical User Interface (GUI)

CITS3403 Agile Web Development Semester 1, 2018

Graphical User Interface (GUI)

Event-based Programming

Unit A451: Computer systems and programming. Section 3: Software 1 Intro to software

1. Create a map of the layer and attribute that needs to be queried

Event-Driven Programming with GUIs. Slides derived (or copied) from slides created by Rick Mercer for CSc 335

Common Architectural Styles & Patterns

Widget Toolkits CS MVC

Game Programming with. presented by Nathan Baur

Graphical User Interfaces 2

Lab 4. D0010E Object-Oriented Programming and Design. Today s lecture. GUI programming in

1 Getting started with Processing

Web Front Technology: Interstage Interaction Manager

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Graphical User Interfaces 2

Widgets. Widgets Widget Toolkits. User Interface Widget

UI Software Organization

CISC 1600, Lab 2.2: Interactivity in Processing

CS 160: Interactive Programming

Designing Forms in Access

Module 05 User Interfaces. CS 106 Winter 2018

The MUI (Micro User Interface) facility

FSA Algebra 1 EOC Practice Test Guide

UI Elements. If you are not working in 2D mode, you need to change the texture type to Sprite (2D and UI)

GUI Event Handlers (Part I)

CSC207H: Software Design Lecture 11

Erasmus+ Project: Yestermorrow Year 1 Maths: Pythagorean Theorem

Grade 8 FSA Mathematics Practice Test Guide

Model-View Controller IAT351

Widgets. Overview. Widget. Widgets Widget toolkits Lightweight vs. heavyweight widgets Swing Widget Demo

Graphical User Interface. GUI in MATLAB. Eng. Banan Ahmad Allaqta

2. (10 pts) Which of the following classes implements the Shape interface? Circle all that apply. a) Ellipse2D b) Area c) Stroke d) AffineTransform e)

CISC 1600, Lab 3.2: Interactivity in Processing

Programming in the Simple Raster Graphics Package (SRGP)

Basic Input and Output

Exploring Processing

Organization of User Interface Software

FSA Geometry EOC Practice Test Guide

Lecture 24. GUI Applications

16.6. Parametric Surfaces. Parametric Surfaces. Parametric Surfaces. Vector Calculus. Parametric Surfaces and Their Areas

Event Dispatch. Dispatching events to windows and widgets.

! ios 10 Feature Guide

Chapter 1: Symmetry and Surface Area

Lecture 3: Java Graphics & Events

Script for Administering the Civics EOC Practice Test (epat)

Outline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

CS 106A, Lecture 14 Events and Instance Variables

Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Mid Unit Review. Of the four learning outcomes for this unit, we have covered the first two. 1.1 LO1 2.1 LO2 LO2

Event-driven Programming, Separation of Concerns, the Observer pattern and the JavaFX Event Infrastructure

Transcription:

Dr. Sarah Abraham University of Texas at Austin Computer Science Department Event-driven Programming: GUIs Elements of Graphics CS324e Spring 2018

Event-driven Programming Programming model where code runs based on events Events occur asynchronously throughout program execution System-generated events User-generated events Some part of system signaled/messaged when event is triggered Change program flow based on user input, sensor output, or system messages

System-generated Events System initiates an event outside of user s control Generated by: External hardware beyond application (e.g. a system timer) Internal software within application (e.g. notification of task completion) Application responds to event

User-generated Events System initiates an event based on user input onto connected hardware Keyboard press Mouse movement/click Joystick control Operating system stores user input as event in a queue UI toolkits provide checks and responses to events Programmer determines behavior based on events

GUI and Menus Graphical user interfaces (GUIs) determine input based on mouse (or stylus) position on the screen Standard events already built into system Window minimize, window close, etc Custom events added by programmer Game paused, change music volume, etc User interacts with elements at any point of the program execution

Callbacks Tells the system what to do when particular event arrives Necessary code executes automatically Standard technique for a GUI system: 1. Application implements function to handle event 2. Application notifies GUI which function to call 3. GUI handles this functionality when user interacts with the system What are some callbacks built into Processing?

Graphical User Interface Computer interface with a visual component Direct interaction with the screen rather than interactions via command line Designed for easier, more intuitive experience Based on event-driven programming

Uses Text editors Web browsers Music controls Video games Many, many more (imovie)

Consider How are some ways we can interact with a GUI?

Widgets Interactable objects within a GUI: Buttons Check boxes Radio buttons Sliders Provide different ways of interacting with program behavior

Example Widget (http://compsci.ca)

Buttons Allow for functionality upon mouse click Must be aware of mouse position and button boundary Circles and rectangles have accessible formulae to determine boundaries Circles check based on radius from center position Rectangles check based on width/height distance from corner (or center) position

Thinking More about Events Consider mousepressed() Listens for events while draw() runs Called every time a mouse button is pressed Consider mousepressed(mouseevent event) Event explicitly accessible to mousepressed callback Tracks x and y position and mouse button pressed Information accessible outside of the event (a Processingspecific feature)

Event Class Contains action, modifiers and length of action Parent class of: KeyEvent Key and key code information included MouseEvent Position, button and click count included TouchEvent

Custom Events Possible to implement custom events Based on observer pattern Object maintains list of dependent objects (observers) Object notifies its observers of state changes Appropriate observer method called in response Same concept used in GUI programming and for communicating in MVC (Model-View-Controller) pattern

Observers and Observables java.util.observer creates Observer interface Notified of changes in associated observable objects Receive notification via update method java.util.observable is data that is observed Notifies one or more observers of change to some value Sends notification via notifyobservers method

Hands-on: Understanding GUI Events Today s activities: 1. Implement a Button class that checks when the mouse is over it, and when the mouse clicks on it 2. Create both rectangular and circular buttons 3. Experiment with the mousepressed and mousereleased event calls 4. Add functionality so that the sketch s background color changes every time a button is pressed