GUI library for programmers (C)

Contributors: Laura Willot, Rémi Battet


This one-month project goal was to make a library allowing programmers to develop easily a GUI including windows and widgets like buttons or textboxes.

During this project, I was responsible of :

  • supporting transparency in drawing
  • full geometry manager
  • full event manager

Being given functions to access pixels on screen, drawing text and receiving user interactions (key pressed, mouse moved), our library had to offer several services to programmers.

Graphic primitives drawing

The library featured two kinds of graphic primitives drawing functions :

  • broken lines drawing
  • full polygon drawing

Both function had to be as optimised as possible to reduce execution time. Therefore, broken lines drawing was implemented using Bresenham algorithm while the full polygon drawing uses a scanline fill algorithm. More, clipping is performed using Sutherland-Hodgman’s algorithm.

Creation and configuration of various widgets

Widgets like buttons had to be implemented with various parameters like size, content (picture or text), design (embossed or not), etc… More, widgets can be inside one another and this hierarchy impacts the visibility on screen : widgets higher in the hierarchy are covered by their descendants, resulting in them not being drawn on screen.

Geometry manager

The geometry manager defines size and position of a widget in a window. The implemented geometry manager is a placer, meaning the position and size of a widget can be defined either in absolute terms or relative to its parent.

Event manager

The library also needs to deal with users interactions such as moving or resizing a window. More, programmers should be able to define customized functions to call on the press of a button for example. To achieve this, the library differentiate internal events, handled by the library and corresponding to the standard behaviour when the widget is clicked, and external behaviours, defined by the programmer. Likewise, to know which widget needs to react, each widget drawing is done twice : once on screen and once on a picking surface, making it easy to get the corresponding widget. This can be seen on the image below : picking.jpg