Data types

struct _s3dw_style

struct _s3dw_style {
	const char *name;
	const char *fontface;
	float surface_mat;
	float input_mat;
	float inputback_mat;
	float text_mat;
	float title_mat;
	float title_text_mat;

With s3dw_style you can change the colors/materials of your widgets. materials are in the same as in s3d_push_materials_a, that means red,green,blue and alpha float values (between 0.0 and 1.0) for ambience, specular and diffuse color.


name of the style ... kind of redundant


font face for all used fonts


material for the surface background


material for button boxes and other widgets


material for input field background


material for the text on buttons and inputs


material for the title bar


material for the text on the title bar

struct _s3dw_widget

struct _s3dw_widget {
	int type;
	s3dw_widget *parent;
	s3dw_style *style;
	int nobj;
	s3dw_widget **pobj;
	int focus;
	int flags;
	float ax;
	float ay;
	float az;
	float as;
	float arx;
	float ary;
	float arz;
	float width;
	float height;
	uint32_t oid;
	void *ptr;
	float x;
	float y;
	float z;
	float s;
	float rx;
	float ry;
	float rz;

This is the most basic widget type, it contains all the "general" widget information. If you want to move a widget, you'd change x,y,z,s and rx,ry,rz and call s3dw_moveit to turn your action reality. Every other widget has this type as first entry, so a simple typecast to s3dw_widget will give you the widgets "general" information. For typecast, you may use S3DWIDGET().

The pointer ptr allows linking to user-specific data structures. That comes in handy if the widget is called back by an event, and the program must now find out on which data the user reacted.

struct _s3dw_button

struct _s3dw_button {
	s3dw_widget widget;
	char *text;
	uint32_t oid_text;
	s3dw_callback onclick;

The buttons is just a button as you would expect it in a 2D widget library. It only reacts on clicks.

struct _s3dw_label

struct _s3dw_label {
	s3dw_widget widget;
	char *text;
	s3dw_callback onclick;

The labels is an label-field where a user may type things. onclick reacts on click in the field.

struct _s3dw_scrollbar

struct _s3dw_scrollbar {
	s3dw_widget widget;
	float pos;
	float max;
	int type;
	int loid;
	int roid;
	int baroid;
	s3dw_callback lonclick;
	s3dw_callback ronclick;

The Scrollbar should be placed around scrollable content. Currently only the left and right icons are clickable (lonclick and ronclick callbacks), in vertical mode lonclick is the callback for the up icon, ronclick the callback for the down icon.

struct _s3dw_textbox

struct _s3dw_textbox {
	s3dw_widget widget;
	s3dw_scrollbar *scroll_vertical;
	s3dw_scrollbar *scroll_horizontal;
	char *text;
	int n_lineoids;
	int *p_lineoids;
	int window_x;
	int window_y;
	s3dw_callback onclick;

A textbox shows some text with scrollbars to scroll around. It can currently only react to a click event.

struct _s3dw_input

struct _s3dw_input {
	s3dw_widget widget;
	char *text;
	uint32_t oid_text;
	s3dw_callback onclick;
	s3dw_callback onedit;

The inputs is an input-field where a user may type things. onclick reacts on click in the field, onedit notifies you when someone writes in the field.

struct _s3dw_surface

struct _s3dw_surface {
	s3dw_widget widget;
	uint32_t oid_title;
	uint32_t oid_tbar;
	char *title;

A surface is the window of this widget library, holding all of our elements like buttons, input fields etc ...

typedef s3dw_widget

typedef struct _s3dw_widget s3dw_widget

typedef s3dw_button

typedef struct _s3dw_button s3dw_button

typedef s3dw_label

typedef struct _s3dw_label s3dw_label

typedef s3dw_textbox

typedef struct _s3dw_textbox s3dw_textbox

typedef s3dw_scrollbar

typedef struct _s3dw_scrollbar s3dw_scrollbar

typedef s3dw_input

typedef struct _s3dw_input s3dw_input

typedef s3dw_surface

typedef struct _s3dw_surface s3dw_surface

typedef s3dw_style

typedef struct _s3dw_style s3dw_style

typedef s3dw_callback

typedef void(* s3dw_callback)(s3dw_widget *)

The callback type. Receive the widget which is affected as argument.

 // example
 void my_handler(s3dw_widget *widget)
         // do something with the widget