GUIs and Events CSE 3541/5541 Matt Boggus.

Slides:



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

DETAILED DESIGN, IMPLEMENTATIONA AND TESTING Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Survey of Graphics and Games. Outline Overview of computer graphics – Coursework – Research Programming using game engines Computer game and animation.
Normans Principles Usability Engineering. Normans Principle Norman’s model of interaction is perhaps the most influential in human computer interaction.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
1 Case Study: Starting the Student Registration System Chapter 3.
Introduction to AppInventor Dr. José M. Reyes Álamo.
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Introduction to Matlab & Data Analysis
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 6 Program Design 4/18/09 Python Mini-Course: Day 2 - Lesson 6 1.
SE 320 – Introduction to Game Development Lecture 8: Animations, GUIs, Debugging and IDEs Lecturer: Gazihan Alankuş Please look at the last two slides.
Introduction to Windows Programming
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Control flow for interactive applications CSE 3541 Matt Boggus.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Comparing model-based and dynamic event-extraction based GUI testing techniques : An empirical study Gigon Bae, Gregg Rothermel, Doo-Hwan Bae The Journal.
Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
Event Handling Tonga Institute of Higher Education.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 15 Event-Driven Programming and.
GameDevClub CODE CHEAT SHEET NOTE: ALL OF THE CODE IS CASE-SENSITIVE AND THE SYNTAX IS STRICT SO A LOT OF YOUR ERRORS WILL PROBABLY COME FROM TYPOS If.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Procedural programming Procedural programming is where you specify the steps required. You do this by making the program in steps. Procedural 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.
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
Programming Logic and Design Seventh Edition Chapter 12 Event-Driven GUI Programming, Multithreading, and Animation.
Programming Paradigms, Software Architectural Patterns, and MVC CS 378 – Mobile Computing for iOS Dr. William C. Bulko.
Interactive Animation
Game and animation control flow
Unit 2 Technology Systems
Event Loops and GUI Intro2CS – weeks
Introduction to Event-Driven Programming
Chapter Topics 15.1 Graphical User Interfaces
Event-driven programming
Event loops 16-Jun-18.
An Introduction to Programming
Lesson 1: Buttons and Events – 12/18
Ellen Walker Hiram College
Game and animation control flow
Event Driven Programming
EE 422C Java FX.
Unit 14 Event Driven Programming
Updating an Animated Scene
Event loops.
Using JDeveloper.
While Loops and If-Else Structures
Android Topics UI Thread and Limited processing resources
Event loops 17-Jan-19.
Event loops 17-Jan-19.
While Loops and If-Else Structures
While Loops and If-Else Structures
Norman 7 A: User-Centered Design
Introduction to AppInventor
Introduction to Unity 2D Game Development
Chapter 15: GUI Applications & Event-Driven Programming
Event loops 8-Apr-19.
Tonga Institute of Higher Education
While Loops and If-Else Structures
An Introduction to Programming
CSE 1020:Software Development
Event loops.
While Loops And If-Else Structures
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

GUIs and Events CSE 3541/5541 Matt Boggus

Outline GUIs and GUI components GUI design Event-driven programming paradigm Control flow in an event loop Code samples using delegates and events

Graphical user interfaces

GUI – graphical user interface Screenshot from video: https://unity3d.com/learn/tutorials/topics/user-interface-ui/ui-canvas?playlist=17111

Affordances Actions an object is obviously suited for Image sources: https://doctordisruption.com/principles-of-design-51-affordance/ https://paaralan.blogspot.com/2010/09/affordance-and-educational-games.html

Image source: http://www3. ntu. edu

Image (third party) source: http://slideplayer.com/slide/7337676/

Unity specific GUI component reference materials For more info these types, refer to: https://unity3d.com/learn/tutorials/s/user-interface-ui https://docs.unity3d.com/ScriptReference/

Design reference By: Donald A. Norman

Seven principles for design Use knowledge in the world and knowledge in the head Make things visible Get the mappings right Simplify the structure of tasks Exploit the power of constraints Design for error When all else fails, standardize

Event-Driven Programming

Some programming paradigms Event-driven programming Control flow determined by events Input (mouse click, key press, sensors) Timers or other object update logic Messages from other programs or threads For comparison, study Imperative programming Structured programming Procedural programming

Event-driven programming Control flow or program state changes driven based on responding to events rather than a strict ordering of statements Implementation details can vary Software I topic: polling vs. callbacks Software I topic: model-view-controllers

Game/Animation loop main(){ Initialize(); while(true){ DrawScene(); HandleEvents(); UpdateObjects(); }

Unity example script using UnityEngine; using System.Collections; public class SomeScript : MonoBehaviour { // fields void Start() { // code to run when start is pressed } void Update () { // code to run on repeat during execution } // other methods }

Note about class definition public class SomeScript : MonoBehaviour vs. public class SomeOtherClass

Unity example script – event polling public class SomeExampleScript : MonoBehaviour { void Update () { if ( Input.GetKeyDown(“r”) ) { Reset(); } if (Input.GetKeyDown(“a”) || Input.GetKeyDown(“left”) { MoveLeft(); // …

Delegates

public class DelegateScript : MonoBehaviour { delegate void MyDelegate(int num); MyDelegate myDelegate; void Start () { myDelegate = PrintNum; myDelegate(50); myDelegate = DoubleNum; } void PrintNum(int num) print ("Print Num: " + num); void DoubleNum(int num) print ("Double Num: " + num * 2);

public class MulticastScript : MonoBehaviour { delegate void MultiDelegate(); MultiDelegate myMultiDelegate; void Start () { myMultiDelegate += PowerUp; myMultiDelegate += TurnRed; if(myMultiDelegate != null) myMultiDelegate(); } void PowerUp(){ print ("Orb is powering up!"); void TurnRed(){ renderer.material.color = Color.red;

events

public class EventManager : MonoBehaviour { public delegate void ClickAction(); public static event ClickAction OnClicked; void OnGUI() if(GUI.Button( new Rect(Screen.width / 2 - 50, 5, 100, 30), "Click")) if(OnClicked != null) OnClicked(); }

public class TeleportScript : MonoBehaviour { void OnEnable() EventManager.OnClicked += Teleport; } void OnDisable() EventManager.OnClicked -= Teleport; void Teleport() Vector3 pos = transform.position; pos.y = Random.Range(1.0f, 3.0f); transform.position = pos;

public class TurnColorScript : MonoBehaviour { void OnEnable() EventManager.OnClicked += TurnColor; } void OnDisable() EventManager.OnClicked -= TurnColor; void TurnColor() Color col = new Color(Random.value, Random.value, Random.value); renderer.material.color = col;

Summary GUIs and GUI components GUI design Event-driven programming paradigm Control flow in an event loop Code samples using delegates and events

Additional slides

Image source in image

Common GUI object types http://www.sttheresaotcj.org/File_Uploads/Technology/common_gui_objects_2.pdf

http://slideplayer.com/slide/7337676/