simple ui toolkits

56
Andrew Ko Simple UI Toolkits

Upload: kare

Post on 27-Jan-2016

114 views

Category:

Documents


0 download

DESCRIPTION

Simple UI Toolkits. Andrew Ko. What does “simple” mean?. For most simple UI toolkits, “simple” means Better initial usability and learnability Limited scope and expressiveness A more descriptive term would be “simple gui-glue-scripts” Most support limited graphical toolkit abilities - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Simple UI Toolkits

Andrew Ko

Simple UI Toolkits

Page 2: Simple UI Toolkits

For most simple UI toolkits, “simple” means Better initial usability and learnabilityLimited scope and expressiveness

A more descriptive term would be “simple gui-glue-scripts”

Most support limited graphical toolkit abilitiesMost are aimed at gluing together applications and components with standard widgets

What does “simple” mean?

Page 3: Simple UI Toolkits

Programs are often written in simple scripting languages or subsets of general languagesVery little code required to create basic, default, user interface componentsSome automatically generate code from user interface builders, but don’t generalize from changes in code to interface

Common Characteristics

Page 4: Simple UI Toolkits

Object creation (how does a widget get made?)Object properties (position, appearance, etc.)Object architecture (how are objects related?)Connections (how do objects respond to and broadcast messages and events?)

Dimensions of Comparison

Page 5: Simple UI Toolkits

Tcl/TkSUITVisual BasicCocoaAliceSummary

Outline

Page 6: Simple UI Toolkits

John Ousterhout, 1988, while on sabatticalTcl = Tool Command Language

Intended to be an “embeddable command language”Open source, multi-platform scripting language, much like Perl, Python, and PHPPitched as “application glue”, like other popular scripting languages

Tcl/Tk

Page 7: Simple UI Toolkits

Tk

John Ousterhout, 1990Motivation was to test how good Tcl was at integrating componentsUsed in Tcl originally, then Perl and PythonOriginally popular because easiest way to create GUIs on UNIX platformsPorted to Windows and Mac in 1994

Tk

Page 8: Simple UI Toolkits

Widgets are the atomic unitAll widgets created are globalContainer hierarchiesThe code to the left represents “the text of label 2 of button 5 of container 3 in window 1 of the application

ArchitectureTk

.w1.c3.b5.l2 - text

Page 9: Simple UI Toolkits

Objects created programmatically in a script, then compiled and executedThere are no interface builders directly associated with Tk (I don’t know of any)

Creating ObjectsTk

Page 10: Simple UI Toolkits

First line creates a window frame called “My Window” as child of “.”, which represents the shellSecond line sets title of root window to “My Window”Third line creates a button inside “My Window” with text “Quit”

Creating Objectsframe .f -borderwidth 2wm title . "My Window"button .f.b -text "Quit"bind .f.b <Button-2-ButtonRelease { quit }pack .f

Tk

Page 11: Simple UI Toolkits

“bind” sets the callback for pressing the button with the second mouse buttonThe callback quits the application“pack” lays out window “My Window”

EventsTk

frame .f -borderwidth 2wm title . "My Window"button .f.b -text "Quit"bind .f.b <Button-2-ButtonRelease { quit }pack .f

Page 12: Simple UI Toolkits

Because Tk objects are all global, sending messages is a matter of directly changing widget state and propertiesSame problem of spaghetti code as with other event-based languages

EventsTk

Page 13: Simple UI Toolkits

Widgets have standard properties, and widget specific propertiesProperties of widgets are not visible, except through documentationProperties are set using Tcl or other scripting languages

Object propertiesTk

Page 14: Simple UI Toolkits

- In regard to Tcl, HCII Ph.D. student Jeff Nichols says

+Very little overhead for creating simple applications

- Unfamiliar syntax for most programmers+Highly portable- No interface builder

Evaluation

“it just has the worst syntax I've ever seen...its really restrictive...its unintuitive for C programmers”

Tk

Page 15: Simple UI Toolkits

Simple User Interface ToolkitRandy Pauch at Virginia Tech, 1992Design principles

Exploit knowledge and skills of usersMake easy things easy and hard things possiblePerform end-user testing early and often

SUIT

Page 16: Simple UI Toolkits

Built on prototype instance modelOne object is like another, as opposed to inherits fromSame model as Amulet and Garnet

Objects’ properties stored in external database

ArchitectureSUIT

Page 17: Simple UI Toolkits

Each object has:State, contained in property list, including position, size, and other basic propertiesC procedure that examines state and rendersC procedure that handles user input and updates state

Objects PropertiesSUIT

Page 18: Simple UI Toolkits

Small set of widget creation methodsCode above

Defines callback “hi”Creates button associated with “hi”

Creating ObjectsSUIT

void Hi(SUIT_object obj){ printf("Hello, world\n");}SUIT_createButton("hello", Hi);

Page 19: Simple UI Toolkits

Used graphical menu to modify object propertiesInstead of being set,

Booleans were toggled in property editorElements were selected from a listProperties also set programmatically

Properties deleted by dragging to trash

Modifying PropertiesSUIT

Page 20: Simple UI Toolkits

Explicitly avoided “code dumping” model of UI interface buildersInstead, layout done at runtime with direct manipulationBuild mode accessed with SHIFT and CONTROLOtherwise, application was in run mode

Modifying PropertiesSUIT

Page 21: Simple UI Toolkits

Connections between on screen components achieved by “exporting” propertiesExported by dragging a property to an export buttonSystem would generate a new object that controlled the “exported” propertyNot general component to component communication, but covered most cases

ConnectionsSUIT

Page 22: Simple UI Toolkits

No general constraint systemProgrammer registers “interest” in an object by specifying an “interest procedure”When property of interest is changed, property, property name, and old and new values sent to “interest procedure”Allowed for constraining button size to label size

ConnectionsSUIT

Page 23: Simple UI Toolkits

In general, three types of connections:Exporting a property to create a widget that affects propertyRegistering interest in a propertyCallbacks

ConnectionsSUIT

Page 24: Simple UI Toolkits

- Debugging name space was difficult: misspelling property created new property with 0 value- Common to all prototype instance

models- Hard to create custom widgets without

additional knowledge of toolkit architecture

+Learnable in a few hours by programmers who know C

EvaluationSUIT

Page 25: Simple UI Toolkits

BASIC = Beginner’s All-purpose Symbolic Instruction CodeBASIC developed in ‘64 by students at DartmouthEventually sold to Microsoft, and used as a scripting language for Windows OSesOne type of application and component glue for connecting Microsoft appsVB.Net is a whole different (object-oriented) beast, and will not be discussed here

Visual BASIC

Page 26: Simple UI Toolkits

“forms” contain widgetsWidgets have lots of propertiesWidgets can see parent form’s properties

ArchitectureVB

Page 27: Simple UI Toolkits

Common widgets providedImage, label, text, frame, option, list...

Many useful forms providedAbout dialog, web browser, ok/cancel dialog, ODBC login

Can create custom forms using widgets and defining event handlers

Creating ObjectsVBVB

Page 28: Simple UI Toolkits

Every object has default propertiesName, index, dimensions, font...Visible at start and enabled

Most of the details are managed internallyThe focus is on modifying and using user-defined properties

Object PropertiesVB

Page 29: Simple UI Toolkits

All properties managed by system can modified through direct manipulation or property editorsProgrammer modifies user-defined properties programaticallyProgrammatically modifying system properties is difficult because

There are many ways to modifyEach way uses a different notation and/or convention

Modifying PropertiesVB

Page 30: Simple UI Toolkits

Callbacks can be defined for each widgetIn this example, pressing the okay button executes “OK_Click()”

Pulls the text and height from the text fieldsPuts volume in the volume text field

ConnectionsVB

Private Sub OK_Click( ) r = Val(radius.Text) h = Val(hght.Text) pi = 22 / 7 v = pi * (r ^ 2) * h volume.Text= Str$(v) End Sub

Page 31: Simple UI Toolkits

Widgets have many predefined events, which take the shape of callbacks

Initialize, load, activateKey and mouse events also broadcast

Write functions to respond to default set

ConnectionsVB

Page 32: Simple UI Toolkits

+Great for creating simple Windows-only applications

- Doesn’t scale to large applications because data management is difficult

- Has a low ceiling: creating custom widgets is nearly impossible

EvaluationVB

Page 33: Simple UI Toolkits

Designed to be a rapid prototyping framework for windowed OS X applicationsRoots are in UI toolkit developed for NeXT systemsHighly parameterizable set of standard widgetsNo code necessary for standard behaviors

Cocoa

Page 34: Simple UI Toolkits

Object-oriented, model-view-controller architectureNSApplication encapsulates views/controllers

Main event-loopWindows and menusEvent distribution and message passing

Delegate object manages model (data and logic)Delegate is only code written by programmer

ArchitectureCocoa

Page 35: Simple UI Toolkits

Small set of highly parameterizable widgetsButtons, sheets, color picker, menus, etc.

Objects are all containers, able to contain other graphical objectsNo programming necessary for drag and drop, spell checking, localization, printing...

ArchitectureCocoa

Page 36: Simple UI Toolkits

NSViewHolds the visualization of modele.g., what a button looks like based on properties

NSControlMaintains control logic of modele.g., what happens to button’s state when pressed and released

Object PropertiesCocoa

Page 37: Simple UI Toolkits

Use Interface BuilderWYSIWYG, generates “NIB” rather than code

NIB containsMenu, windows, widgets, images, localization info, soundsMessage connections between widgetsView and control object hierarchy

Creating ObjectsCocoa

Page 38: Simple UI Toolkits

Modifying view is done in Interface Builder w/ direct manipulationModifying control (creating custom widget logic) is done by changing parameters in Interface BuilderCustom views and controls done programmatically

Modifying PropertiesCocoa

Page 39: Simple UI Toolkits

Connections are establish by drawing lines from sending object to receiving objectConnection is stored in NIB and handled automaticallyConnections to custom views and models also done in Interface Builder

ConnectionsCocoa

Page 40: Simple UI Toolkits

User input events handled automaticallyResponding to events (defining the model) is done with Java, C, C++, Objective-C, or...AppleScript, which is the “simple” way

Scripting language designed for gluing Mac OS applications together(overly) flexible natural language-like syntax

ConnectionsCocoa

Page 41: Simple UI Toolkits

“on” handles event“tell” sends an event to an application or object“try” attempts to do something, and allows for handling failuresEvents go to any application or application object, as defined by Interface Builder

Connectionson clicked theObject tell window of the object try set theRate to contents of text field "rate" as number set theAmount to contents of text field "amount" as number set contents of text field "total" to 0

Cocoa

Page 42: Simple UI Toolkits

“should” asks whether operation should take place

“on should close” could see if a window should close based on GUI state

“will” is when on operation is about to take place“on will close” prepares window for closing

“did” is when an operation already took place“on did close” might play an exit sound and quit app

ConnectionsCocoa

Page 43: Simple UI Toolkits

Cocoa objects and applications expose their model via “dictionaries”AppleScripts use dictionaries to manipulate model data and behavior

DictionariesCocoa

tell application "Safari"set this_URL to the URL of document 1

end telltell application "Mail"

activateset this_message to make new outgoing message with properties {subject:"Cool URL!",

content:this_URL}end tell

Page 44: Simple UI Toolkits

Objects with custom controls (actions and outlets only) created in Interface Builder

Connected in Interface BuilderEvents defined for actions and outlets with Applescript

Objects with custom views also follow this process, but drawRect() function must be defined to visualize

Custom ObjectsCocoa

Page 45: Simple UI Toolkits

- Mac OS X only- AppleScript is more difficult to read and

write than VB+UI definition and modification is done

completely by direct manipulation+Highly parameterizable widgets reduce

need for custom widgets+Only programming necessary is definition

of model via response to events

EvaluationCocoa

Page 46: Simple UI Toolkits

3D Programming EnvironmentCurrently used for building virtual worlds

Useful for building simple 3D user interfaces

Alice

Page 47: Simple UI Toolkits

World objectContains 3D user objects and camera

3D objects contained in worldObjects can be vehicles of other objects

Vehicles define coordinate systemsAll data is global except for local variables

ArchitectureAlice

Page 48: Simple UI Toolkits

Arbitrary 3D model“skin” for the modelVisibility, opacity, position, orientationUser-defined dataMethods (side-effects only)Questions (computation only)

Object PropertiesAlice

Page 49: Simple UI Toolkits

Select from a list of models and add to the worldNew objects must be modeled in 3D modeling programVehicles can be set programatically or by choosing from a list

Creating ObjectsAlice

Page 50: Simple UI Toolkits

Position and orientationby direct manipulationbuilt-in animation methods

Other properties set in property listchanged programmatically

Modifying PropertiesAlice

Page 51: Simple UI Toolkits

Since all properties are global, methods directly operate on objects and properties of interest

ConnectionsAlice

Page 52: Simple UI Toolkits

Events are defined in global event listWhen the world startsWhile <condition> is true

Begin, during, endWhen key pressedWhen variable changes

ConnectionsAlice

Page 53: Simple UI Toolkits

+Powerful 3D user interface toolkit- Must use events provided- All data is global- Reuse is nearly impossible- Aimed at novice programmers, rather

than 3D UI designers

EvaluationAlice

Page 54: Simple UI Toolkits

Support very rapid prototypingStandardized interfacesEasier to learn for novices and expertsAllows (motivated) non-programmers to design UIs

Advantages of Simple UI Toolkits

Page 55: Simple UI Toolkits

Often have a steep learning curve at a certain level of complexityDomain-specific, so they don’t allow for design exploration in new domainsOften slower, since many are used with scripting languagesEvent-based programming style brings new programming problems

Disadvantages of Simple UI Toolkits

Page 56: Simple UI Toolkits

Simple UI toolkits may be all we need for commercial end user applications

Speed is increasingly unimportantNew domains are infrequentIf standard UIs are preferred, programmers may never reach the steep learning curve

New domains still need “complex” UI toolkits to explore design space

Conclusion