July 20021 FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.

Slides:



Advertisements
Similar presentations
Chapter 16 Graphical User Interfaces
Advertisements

OpenGL Open a Win32 Console Application in Microsoft Visual C++.
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.
CS 4731 Lecture 2: Intro to 2D, 3D, OpenGL and GLUT (Part I) Emmanuel Agu.
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.
OpenGL Basics Donghui Han. Assignment Grading Visual Studio Glut Files of four types needed: – Source code:.cpp,.h – Executable file:.exe (build in release.
CSE 557: Impressionist Help Session Keith Grochow.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Project 1: Impressionist Help Session And your friendly neighborhood TA is… Young-Mi.
Project 1: Impressionist Help Session Jonathan Su
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSE 457: Impressionist Help Session...And Your Friendly TA is: Steve Martin.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Based on slides created by Edward Angel
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.
Bertrand Bellenot ROOT Users Workshop Mar ROOT GUI Builder Status & Plans ROOT & External GUI World MFC, FOX, Qt, PVSS… Snapshot of the Future.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
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.
WORKING WITH CALLBACKS Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive.
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.
CD2012 Principles of Interactive Graphics Lecture 01 Introduction Abir Hussain (Rome: 6.33,Tel , Web:
Managing Multiple Windows with OpenGL and GLUT
Introduction to Windows Programming
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
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.
FLTK. Оконная система, DWM XWindows (Linux/UNIX) Windows DWM (Win Vista, 7, 8)
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.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Computer Graphics I, Fall 2010 Working with Callbacks.
July Doxygen A Code Documentation System Doxygen generates documentation directly from the structure and comments in the code –Browsable HTML documentation.
Project 1: Impressionist Help Session. The Skeleton Code.
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  .
Lesson 28: More on the GUI button, frame and actions.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Project 1: Impressionist Help Session Zinnia Zheng
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Working with Callbacks.
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.
CSE 457: Impressionist Help Session...And Your Friendly TA is: Siobhan Quinn.
Topics Graphical User Interfaces Using the tkinter Module
FLTK The Fast Light Toolkit
Event Driven Programming
Topics Graphical User Interfaces Using the tkinter Module
Event Driven Programming Anatomy – Handle
Constructors, GUI’s(Using Swing) and ActionListner
Processes in Unix and Windows
Presentation transcript:

July 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

July 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

July 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

July 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();

July FLTK Example - Hello World #include 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(); }

July FLTK Example - Hello World

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

July 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)

July 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)

July 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);

July FLTK Example - Buttons #include 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(); }

July 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)

July Drawing Example - A Circle #include 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(); }

July 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()

July 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)

July 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

July 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

July 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.

July FLUID - Hello World with Switch  Generate HelloWorld class HelloWorldUI new  code  class

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

July FLUID - Hello World with Switch  Create the main window inside the constructor method new  group  window

July FLUID - Hello World with Switch  Create a tile widget new  group  tile

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

July FLUID - Hello World with Switch  Create the main function new  code  method/function

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

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

July 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