FLTK The Fast Light Toolkit

Slides:



Advertisements
Similar presentations
OpenGL Open a Win32 Console Application in Microsoft Visual C++.
Advertisements

OpenGL CMSC340 3D Character Design & Animation. What is OpenGL? A low-level graphics library specification designed for use with the C and C++ provides…
OPEN GL. Install GLUT Download package di sini Dari devcpp, buka Tools->PackageManager-
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
FLUID  The Fast Light User Interface Designer, or FLUID, is a graphical editor that is used to produce FLTK source code  Creates C++ code  Compile.fl.
CSE 557: Impressionist Help Session Ian Simon. What we’ll be going over Getting Set Up The Skeleton Code OpenGL Basic FLTK How to make a new brush Good.
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.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Based on slides created by Edward Angel
Using Graphics Libraries Lecture 3 Mon, Sep 1, 2003.
Bertrand Bellenot ROOT Users Workshop Mar ROOT GUI Builder Status & Plans ROOT & External GUI World MFC, FOX, Qt, PVSS… Snapshot of the Future.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
Interaction with Graphics System
FLTK Tutorial.
Lecture 5: Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
Computer Graphics I, Fall 2010 Input and Interaction.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical.
Managing Multiple Windows with OpenGL and GLUT
Introduction to Windows Programming
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
FLTK. Objectives Install and Use FLTK Widgets ◦Callbacks Handling event ◦System events ◦Mouse events ◦Keyboard events.
1 Chapter 12 GUI C/C++ Language Programming Wanxiang Che.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
Spring 2010Topics in Computer Graphics FLTK and OpenGL Jyun-Ming Chen.
Concurrent Programming and Threads Threads Blocking a User Interface.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
GUI With GTK+ Under Linux Fanfan Xiong. Introduction GTK+ (GIMP toolkit) : A library for creating graphical user interfaces(GUI) Two examples developed.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 21.1 Test-Driving the Painter Application.
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.
July Doxygen A Code Documentation System Doxygen generates documentation directly from the structure and comments in the code –Browsable HTML documentation.
NoufNaief.net TA: Nouf Al-harbi.
GLUT functions glutInit allows application to get command line arguments and initializes system gluInitDisplayMode requests properties for the window.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Java - hello world example public class HelloWorld { public static void main (String args[]) { System.out.println("Hello World"); }
OpenGL in FLTK  .
Project 1: Impressionist Help Session Zinnia Zheng
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics -practical- Lecture 6. (visual c++) open gl library To use open GL with VC++ we add these files:- 1)Glut.h C:\program files\ Microsoft.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
CSC 205 Programming II Lecture 5 AWT - I.
Topics Graphical User Interfaces Using the tkinter Module
Protection of System Resources
Lecture 18: FLTK and Curves Li Zhang Spring 2008
CSC461 Lecture 8: Input Devices
Project 1: Impressionist Help Session
Ellen Walker Hiram College
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
The User Interface Lecture 2 Mon, Aug 27, 2007.
Event Driven Programming
Introduction to Computing Using Java
Help Session . . .And Your Friendly TA is: Andrew Stoneman
Working with Callbacks
UNIT-5.
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Drawing in the plane 455.
Project 1: Impressionist Help Session
Topics Graphical User Interfaces Using the tkinter Module
Event Driven Programming Anatomy – Handle
Constructors, GUI’s(Using Swing) and ActionListner
Graphics and FLTK CSCE 121 J. Michael Moore
Managing Multiple Windows with OpenGL and GLUT
Processes in Unix and Windows
Project 1: Impressionist Help Session
Input and Interaction Ed Angel Professor Emeritus of Computer Science,
Presentation transcript:

FLTK The Fast Light Toolkit A C++ graphical user interface toolkit Can be used under X, Windows, MacOS Supports OpenGL Provides: Interactive user interface builder program (fluid) Compatibility headers for XForms and GLUT Support for OpenGL overlay hardware

FLTK Basics and Naming FLTK provides a library (and associated header files) containing: Window and Widget classes (buttons, boxes, sliders, etc.) Fl_Foo Basic methods for creation, displaying, drawing, etc. Fl::foo() or fl_foo() A set of constants for types, events, etc. FL_FOO

FLTK Operation FLTK applications are based on a simple event processing model. User actions (keystrokes, mouse klicks, etc.) cause events that are sent to the active window Idle, timer, and file events are triggered internally. Applications have to actively listen for and process events from the event queue Fl::check() checks for events queue Fl::wait() waits for an event to appear Fl::run() sets up an event processing loop

Basic FLTK Application Basic steps to create an FLTK application: Create the main window new Fl_Window(width, height, title) Create the desired widgets new Fl_Widget(x, y, width, height, label) Set the appropriate widget properties Close the widget tree associated with the main window window->end() Display the window window->show(argc, argv) Start the event loop return Fl::run();

FLTK Example - Hello World #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Box.H> int main(int argc, char **argv) { Fl_Window *window = new Fl_Window(300,180); Fl_Box *box = new Fl_Box(20,40,260,100,"Hello, World!"); box->box(FL_UP_BOX); box->labelsize(36); box->labelfont(FL_BOLD+FL_ITALIC); box->labeltype(FL_SHADOW_LABEL); window->end(); window->show(argc, argv); return Fl::run(); }

FLTK Example - Hello World

FLTK Widget Types Buttons: Text Valuators (sliders, counters, dials) Boxes

FLTK Widget Methods Each widget class provides a set of methods to change widget properties. E.g.: widget->position(x, y) widget->resize(x, y, width, height) widget->size(width, height) widget->color(color) (e.g. FL_BLUE) widget->labelcolor(color) widget->when(event) widget->callback(static function, data)

FLTK Callbacks Callbacks link functions to events widget->when(event) determines for which event the callback function is executed. E.g.: widget->when(FL_WHEN_ENTER_KEY) widget->when(FL_WHEN_RELEASE) widget->callback(callfnc, data) sets what function to call and what data to pass to it. Callback functions have to be static Callback functions are sent a Fl_Widget pointer of the widget that changed and the data spcified. void callfnc(Fl_Widget *w, void *data)

FLTK Callbacks Using static class methods for callback: Define a static method in your class that accepts a pointer to the class: class foo { void my_callback(Widget *); static void my_static_callback(Widget *w, foo *f) { f->my_callback(w); } ... } Provide the callback with a pointer to the instance of your class: widget->callback(my_static_callback, this);

FLTK Example - Buttons #include <stdlib.h> #include <stdio.h> #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> void beepcb(Fl_Widget *, void *) { printf("\007"); fflush(stdout); } void exitcb(Fl_Widget *, void *) { exit(0); } int main(int argc, char ** argv) { Fl_Window *window = new Fl_Window(320,65); Fl_Button *b1 = new Fl_Button(20, 20, 80, 25, "&Beep"); new Fl_Button(120,20, 80, 25, "&no op"); Fl_Button *b3 = new Fl_Button(220,20, 80, 25, "E&xit"); b1->callback(beepcb,0); b3->callback(exitcb,0); window->end(); window->show(argc,argv); return Fl::run(); }

Drawing Drawing in a widget is achieved using the virtual method Fl_Widget::draw() Create the widget as a subclass of an existing widget class and implement the draw method Various drawing routines are provided: Lines fl_line(x, y, x1, y1) Polygons fl_polygon(x, y, x1, y1, x2, y2) Ellipses fl_arc(x, y, w, h, a1, a2) Text fl_draw(text, x, y)

Drawing Example - A Circle #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/fl_draw.H> class Drawing : public Fl_Widget { void draw() { fl_color(FL_WHITE); fl_arc(140,140,70,0,-360); fl_end_line(); } public: Drawing(int X,int Y,int W,int H) : Fl_Widget(X,Y,W,H) {} }; Int main(int argc, char** argv) { Fl_Window window(300,300); Drawing drawing(10,10,280,280); window.end(); window.show(argc,argv); return Fl::run(); }

Events Events are passed as an argument to the Fl_Widget::handle() virtual method. Mouse Events: FL_PUSH, FL_RELEASE, FL_MOVE, ... Focus Events: FL_FOCUS, FL_LEAVE, ... Keyboard Events: FL_KEYDOWN, FL_KEYUP, ... Event type and content are available via the Fl::event_*() methods. E.g.: Fl::event_button() Fl::event_x() Fl::event_key()

Using OpenGL FLTK provides the Fl_Gl_Window class to generate OpenGL applications. The draw method in this class has to be implemented using OpenGL calls. E.g.: gl_draw(text, x, y) gl_rect(x, y, width, height)

FLUID The Fast Light User Interface Designer FLUID is a graphical interface to create FLTK applications Graphical design of widgets Display of widget tree structure Integrating basic interface code Automatic code generation

FLUID The Fast Light User Interface Designer Generate the main windows class Generate the window Generate the widgets Insert callbacks if required Generate the methods for the main class Insert code

FLUID - Hello World with Switch Generat a window class that generates a window with a text display and a button that lets a user toogle between two labels.

FLUID - Hello World with Switch Generate HelloWorld class HelloWorldUI new®code®class

FLUID - Hello World with Switch Create the constructor method for the window class to build the window new®code®method/function

FLUID - Hello World with Switch Create the main window inside the constructor method new®group®window

FLUID - Hello World with Switch Create a tile widget new®group®tile

FLUID - Hello World with Switch Create a toggle button with callback and color initialization new®group®button

FLUID - Hello World with Switch Create the main function new®code®method/function

FLUID - Hello World with Switch Create code to create a window class and display the window new®code®code

FLUID - Hello World with Switch Save the fluid specification file file®save Generate the C++ code for the program file®write code Compile the application and run it