Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

Understanding an Apps Architecture ASFA Computer Science: Principles Fall 2013.
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
Lecture 2Slide 1 Event Driven Computing Basic Interaction Handling –Interactive programs - must pay attention to the user interface.
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
0 CS 160: Design Process: Implement Event-based UI Programming, Model-View-Controller, and the Web Jeffrey Nichols IBM Almaden Research Center
Based on slides created by Edward Angel
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
CS 480/680 Computer Graphics Programming with Open GL Part 8: Working with Callbacks Dr. Frederick C Harris, Jr. Fall 2011.
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Lecture 7: Objects and Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Welcome to CIS 083 ! Events CIS 068.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Introduction to Matlab & Data Analysis
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
1 Working with Callbacks Yuanfeng Zhou Shandong University.
WORKING WITH CALLBACKS Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive.
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Lecture 3 OpenGL.
1 Input and Interaction. 2 Input Devices Physical input devices Keyboard devices and pointing devices Logical input devices.
Computer Graphics I, Fall 2010 Input and Interaction.
C H A P T E R T E N Event-Driven Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013.
CD2012 Principles of Interactive Graphics Lecture 01 Introduction Abir Hussain (Rome: 6.33,Tel , Web:
CS 480/680 Computer Graphics Programming with Open GL Part 7: Input and Interaction Dr. Frederick C Harris, Jr. Fall 2011.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
CS350 – Windows Programming Formerly and more properly named: Event Driven Programming Dr. Randy Ribler.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 13 : Swing I King Fahd University of Petroleum & Minerals College of Computer Science.
School of Computer Science & Information Technology G6DICP - Lecture 17 GUI (Graphical User Interface) Programming.
Lecture 11: Exam Revision 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271  Coursework.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
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.
Introduction to Computer Graphics 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Lecture 2: Some definitions of terms 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Build-A-Button Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, October 8, 2003.
Program 2 due 02/01  Be sure to document your program  program level doc  your name  what the program does  each function  describe the arguments.
Object Oriented Programming.  Interface  Event Handling.
1 Input and Interaction. 2 Objectives Introduce the basic input devices ­Physical Devices ­Logical Devices ­Input Modes Event-driven input Introduce double.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Computer Graphics I, Fall 2010 Working with Callbacks.
University of New Mexico
Pop-Up Menus Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 26, 2003.
Mouse events, Advanced camera control George Georgiev Telerik Corporation
Events Part I Mouse Events. Learning Objectives By the end of this lecture, you should be able to: – Understand what is meant by an ‘event’ – Appreciate.
Creating User Interfaces Event-Driven Programming.
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.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Working with Callbacks.
CSC Graphics Programming Budditha Hettige Department of Statistics and Computer Science.
Introducing Scratch Learning resources for the implementation of the scenario
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
Event loops 16-Jun-18.
Introduction to the Mouse
CSC461 Lecture 8: Input Devices
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
The User Interface Lecture 2 Mon, Aug 27, 2007.
Event Driven Programming
Event loops.
Working with Callbacks
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Event loops 8-Apr-19.
Event loops.
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271   Web page includes: announcements, handouts, web links, reading hints, frequently asked questions

Lecture 5: Interaction 2 Today’s Lecture: Interaction  Review of Tutorial: Transforms - check out the solutions sheet on L:\cd2012\Tutorial 3 Solution or web page  Coursework 1: Any questions, ask me in the Lab  Compilation under Borland C++ ? Check the web links on the module web page to see if you are having #include or linking problems  Today: Handling Interaction events

Lecture 5: Interaction 3 Handling Interaction Events  Most computer graphics courses will teach you more than you ever wanted to know about graphics output  … but … most graphics applications are useless without a good appreciation of handling user input  This will become more apparent in CMSCD3001 User interface design  There is a standard event handling model that all graphics and windows programs use ….

Lecture 5: Interaction 4 Event Handling Model  In Lecture 1 we said:  Every interactive graphics program has the same model  Initialise the application data and graphics environment  Create the contents of the display  Paint the contents of the display on a window  Set-up functions to handle input events  Start an infinite loop to handle input events  This is event-driven programming  We will look at this model in more detail

Lecture 5: Interaction 5 General Event Handling Model  A Graphics Program registers certain functions as event handling functions  The Program then goes into an infinite loop waiting for events  When an event arrives a notification system decides how it should be handled  The event structure is then passed to the function that was registered for that event  The function exits and returns control to the main loop

Lecture 5: Interaction 6 Callback functions  The basic mechanism for handling input events is to register callback functions to handle specific events.  These events could be  Window events: moving, hiding or resizing a window  input device events: mouse, keyboard, tracker etc  timer events that are generated by a clock in the application  So far we have seen functions to handle window events...

Lecture 5: Interaction 7 Window Event Functions  glutDisplayFunc(display) reacts to events from the Window system to draw (or re-draw) the contents of the window  For example, in MS Windows if the window has been  Minimised/Maximised  Hidden/Shown relative to other windows  glutReshapeFunc(reshape) reacts to events when the Window is resized  The callback function (e.g. reshape) takes as arguments the new width and height of the window  Every window system has similar functions to handle these events

Lecture 5: Interaction 8 Input Device Events  Similarly every windows systems has handlers for dealing with device-specific input events  The main devices always supported are keyboard and mouse  OpenGL has functions for registering other functions as handlers for input device events, e.g.  glutKeyboardFunc(keys) registered the function keys to handle keyboard events  The keys function takes as parameters the ASCII code of the keyboard character and the x,y position of the mouse  See input_events.cpp example

Lecture 5: Interaction 9 Mouse input  Similarly the function glutMouseFunc(mouse) would register mouse() to handle mouse button events  See the mouse() function in example code  The function receives the index of the button that was pressed and the state of the button, plus x,y coordinates, e.g.  GLUT_LEFT_BUTTON, GLUT_RIGHT_BUTTON  GLUT_UP, GLUT_DOWN  The handler function then performs some graphics or application function in response to the event

Lecture 5: Interaction 10 Mouse input...  Windows systems also support event handlers for mouse motion, e.g. (1) glutMotionFunc(motion) (2) glutPassiveMotionFunc(passive)  (1) Registers motion() to handle moving the mouse with a button pressed  (2) Registers passive() to handle moving the mouse with a button released  By managing the input state - knowing which button was pressed last, its x,y coordinates etc. - we can support the behaviour of most user interface objects...

Lecture 5: Interaction 11 User Interface State Examples  A Simple graphics button  Press mouse button with cursor over button  Change appearance of button  Release mouse button with cursor still over button  Perform button action or  Release mouse button with cursor NOT over button  Cancel button action and restore appearance of button Save

Lecture 5: Interaction 12 User Interface State Examples  Question: Given the previous example how could you model the state of other components and operations such as:  The parts of a scrollbar (includes motion events)?  A pop-up menu? (See example bitfont.cpp)  Drawing a line, circle, polyline or rectangle in a drawing program?  The important programming point is to maintain the appropriate state until the operation is completed or cancelled

Lecture 5: Interaction 13 User Interface State...  Producers of graphics and user interface toolkits usually refer to the unique look and feel of their systems  User interface state defines the feel part of the user interface  A scrollbar might look and behave differently between, say, MS Windows, Apple MacOS and UNIX X Windows.  A package like Java Swing tries to incorporate different look and feel libraries to mimic the appearance and behaviour of the host windows environment

Lecture 5: Interaction 14 Timer Generated Events  While the main event loop is running the program can only respond to external events.  If we want something to happen between events we have to register handlers to run either  When the program is idle  Or in response to timer generated events  glutIdleFunc() will register a function to run whenever the program is not handling other events  However, this function should return quickly or the program may be unable to respond to other events

Lecture 5: Interaction 15 Timer Generated Events...  We can register a function to be called every few milliseconds by glutTimerFunc  Again see the example code where myTimer() draws a box containing the time in seconds since the program started.

Lecture 5: Interaction 16 Summary  We have looked at how graphics programs handle events generated by windows systems, input events and timers  We have seen how we can register functions to handle these events  We saw how we can define the user interface state to control how the system responds to events  The is no official tutorial - but you should look at the example code input_events.cpp and consider how you would implement the user interface states in slide 12  Coursework 2 will be a small interactive drawing program