Brad Myers Advanced User Interface Software, Spring, 2017

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Tk Widgets This material is best on several sources –Slides by Dr. Ernest J. Friedman-Hill –various Tcl/Tk books.
Graphic User Interfaces Layout Managers Event Handling.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
Spring /6.831 User Interface Design and Implementation1 Lecture 10: Layout.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
1 Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software.
Swing CS-328 Dick Steflik John Margulies. Swing vs AWT AWT is Java’s original set of classes for building GUIs Uses peer components of the OS; heavyweight.
Advanced Java Class GUI – part 1. Intro to GUI GUI = Graphical User Interface -- “Gooey” Just because it’s “gooey” does not mean you may write messy code.
Chapter 121 Window Interfaces Using Swing Chapter 12.
CS102--Object Oriented Programming Lecture 19: – The Swing Package (II) Copyright © 2008 Xiaoyan Li.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
GUI Layout Managers Arkadiusz Edward Komenda. Outline Components and Containers Layout Managers Flow Layout Grid Layout Border Layout Nested Containers.
1 Lecture 3: Overview of UI Software and Tools Brad Myers Advanced User Interface Software.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
Written by Liron Blecher
Java Programming Chapter 10 Graphical User Interfaces.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
MSc Workshop - © S. Kamin, U.Reddy Lect 5 – GUI Prog - 1 Lecture 5 – GUI Programming r Inner classes  this and super r Layout r Reading: m.
Fall UI Design and Implementation1 Lecture 9: Declarative UI.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
Laying Out Components Interior Design for GUIs. Nov 042 What is Widget Layout? Positioning widgets in their container (typically a JPanel or a JFrame’s.
Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© 2013.
1 Lecture 2: Overview of UI Software and Tools Brad Myers Advanced User Interface Software.
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
3461 Laying Out Components Interior Design for GUIs.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
1 Lecture 5: Interactive Tools: Prototypers (HyperCard, Director, Visual Basic), Interface Builders Brad Myers Advanced User Interface Software.
Java Swing - Lecture 3 Layout Management
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
User Interface Components. Layout Placement of UI components in a window – Size & Position Each component occupies a rectangular region in the window.
CSC 205 Programming II Lecture 7 AWT – Event Handling & Layout.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Laying out Elements with CSS
Java FX: Scene Builder.
Tk Widgets in Javascript
Chapter 9: Graphical User Interfaces
Lecture 8: Overview of UI Software and Tools
Advanced GUIs II CS Lecture
University of Central Florida COP 3330 Object Oriented Programming
Ellen Walker Hiram College
Chap 7. Building Java Graphical User Interfaces
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Fundamentals of Python: From First Programs Through Data Structures
This Week: Tkinter for GUI Interfaces Some examples
Containers and Components
GUIS: Graphical User Interfaces
Introduction to Computing Using Java
Panels & Layout Managers
Tutorial 6 Creating Dynamic Pages
Steps to Creating a GUI Interface
GUI Layouts By: Leonard & Saif.
Advanced GUIs II CS Lecture
Layout Organization and Management
Brad Myers : Interaction Techniques Spring, 2019
Advanced GUIs and Graphics
Graphical User Interface
Presentation transcript:

Brad Myers 05-830 Advanced User Interface Software, Spring, 2017 Lecture 11: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers 05-830 Advanced User Interface Software, Spring, 2017 © 2017 - Brad Myers

Happy Mardi Gras! Today! © 2013 - Brad Myers

Homeworks HW 2 regrade is in progress HW 3 due next Thursday, right before spring break © 2017 - Brad Myers

Widgets as objects Menus, buttons, scrollbars Refresh themselves and handle input, redraw if change In Unix: Motif and Tk each widget is at least one window Since windows already have mechanisms for mouse enter/leave, etc. But high overhead In most other toolkits, widgets are not windows Decorative lines, labels and boxes also are "widgets“ © 2017 - Brad Myers

Intrinsics How the widgets are implemented Motif --  "fake" object system out of C (same in Andrew) Tk -- Tcl language, and descendents Amulet -- Prototype-instance object system, constraints, Opal graphics model, Interactors input model, command objects Java (for swing): graphics2d & awt input events jQuery, etc. – JavaScript’s Prototype-instance object model © 2017 - Brad Myers

“Resources” Starting from original Macintosh as “resource fork” – for language independence (& better memory management) All natural language strings and their positions in a separate file Every parameter of widgets in Motif Passed as a parameter to the create routine, set afterwards, or read from a configuration file Called "options" by Tk Each resource has a default value defined by the class In an X file = appl.widget1.resource: value appl.widget1.widget2.resource: value *.resource: value © 2017 - Brad Myers

Callbacks In Motif, associate C procedures with widgets Many different callbacks for the same widget create, start, abort, finish, destroy, ... Registered (set) at widget creation time, invoked at run time Are "resources" There are also "actions" which are internal to the widget and called by events. In VB, “event handlers” Button: click, focus-in/out, change, etc. In tk, associate tcl script with "events" in widgets or the widget action if it has one In Amulet, invoke Command Objects on "interactors" or widget finish, and call-back is the DO method. © 2017 - Brad Myers

Widget Hierarchies Inheritance to give the right methods to widgets Functions down the parent or class hierarchy Java swing hierarchy: http://docs.oracle.com/javase/8/docs/api/index.html?javax/swing/package-tree.html Thousands of interfaces, classes, subclasses, etc. Separate hierarchies for internal look-and-feel classes Visible when debugging © 2017 - Brad Myers

Geometry Management Widgets don't set their own location. Widgets put into special group objects called "geometry managers" that perform the layout by setting the component's positions and size Each widget negotiates with parent for more room when resize © 2017 - Brad Myers

History: TeX layout model Typesetting system designed and mostly written by Donald Knuth starting in 1977 Boxes (of type) connected by “glue” \vspace also between characters, etc. Can control the “stretchiness” of the glue © 2017 - Brad Myers

History: Interviews layout model “Interviews” – one of the first C++ toolkits Linton, M.A., Vlissides, J.M., and Calder, P.R., “Composing user interfaces with InterViews.” IEEE Computer, Feb, 1989. 22(2): pp. 8-22. Adopted the TeX boxes and glue metaphor hbox tiles its components horizontally hglue vbox tiles them vertically Vglue Controls have a “natural” size Different glues and controls have different stretchiness © 2017 - Brad Myers

Motif Geometry Management RowColumn - add widgets and it lays them out Treats all children the same, so not for ScrollBars Form - generic constrained layout Put extra resources on the children widgets "For details, see the Motif Reference Manual, because the complete behavior of Form is quite complicated." Each edge can be constrained at a position or offset from an edge of the Form at an offset from an edge of another widget percent of the way across the Form (edge, not center) a percent calculated based on the initial position If wrong, widgets are on top of each other © 2017 - Brad Myers

TK Geometry Management All widgets must be in a geometry manager, or else not displayed Any widget with any geometry manager Layout depends on widget specified sizes programmer specifications, size of geometry manager itself Widgets must adjust themselves to the size given Geometry manager requests size recursively © 2017 - Brad Myers

TK Geometry, Cont. Placer - specific location for each widget Each widget treated independently Place "anchor" in absolute coords or as a % of way across then say which part of object is at the anchor n, ne, e, se, ... center Packer - "constraint based" specify position of each widget in available space side left, right, top, bottom fill x, -fill y stretch widget to fill available space Text Canvas - mix graphics and widgets © 2017 - Brad Myers

Amulet geometry management Group can have the Am_LAYOUT slot set with a constraint that depends on other slots Sets positions of parts by side effect Default layout routines: Horizontal and Vertical layout, for lists or tables. (Like the LayoutGroup of HW#2) Rest done by arbitrary constraints © 2017 - Brad Myers

Java Widget Layout “Using Layout Managers” BorderLayout – layout around the edges, center gets extra space BoxLayout – vertical or horizontal columns CardLayout – overlapping JPanels FlowLayout – fills row, then goes to next row GridBagLayout – “one of the most flexible — and complex — layout managers the Java platform provides…. uses a grid of rows and columns, allowing specified components to span multiple rows or columns.” – see funny video (2:42) GridLayout -- components in a grid of cells. Resizes children to fill cell GroupLayout – new, designed for use by IBs SpringLayout -- also new for IBs, constraints for layouts © 2017 - Brad Myers

“Struts and Springs” layout For stretchy or rigid constraints Graphical interface layouts NeXTStep (1989), MacOS & Galaxy (~1992) Also : http://doi.acm.org/10.1145/98188.98201 Interactive specification of flexible user interface displays Scott E. Hudson & Shamim P. Mohamed © 2017 - Brad Myers

Web Layout Model Html/css elements can be positioned many ways Tables, floating “div”, etc. Tables no longer recommended for layout Position by absolute or % of container: div.container { width: 100%; …} … width: 10px; … 1em; nav { float: left; … } Many parameters and controls on positions & size: margin-left, padding, … Can have “responsive design” in CSS3 – depends on container width. © 2017 - Brad Myers

Web call-back model Form controls (buttons, text field) have various events or “actions” Built-in actions like “submit” Attach script code to run when used <button type="submit" formaction="/action_page2.php"> AngularJS supports “data bindings” Like Amulet constraints or ConstraintJS Connects JavaScript variable to html element <p ng-bind="firstname"></p> Can be two-way © 2017 - Brad Myers

jQuery JavaScript toolkit Widgets can use standard html/css layout mechanisms jQuery layout plug-in: http://layout.jquery-dev.com/ Subdivides screen into “panes” <div class="ui-layout-center">Center</div> <div class="ui-layout-north">North</div> … Can be draggable, nestable, etc. © 2017 - Brad Myers

iOS Can manually place elements of UI “Auto Layout” Constraint-based layout system Helps with adaptive UI Can set up constraints in the interface builder or programmatically cite © 2017 - Brad Myers

Android Similar to Java Swing Layout: Different kinds of containers that lay out children Linear, grid, etc. Attach layouts to “view”s Listeners for handling events: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Perform action on click } © 2017 - Brad Myers