Create an easy interface

Since I can’t make it to school tomorrow, a little post to update my progress. I’m creating a series of functions to create interfaces the easy way.

My main at the moment works like this:

int main()
// declare your screen(s)
struct CElement *screen1 = CElementCreateScreen(256, 192);

// devide your screen in 2 sections (vertically)
struct CElement *splitY = CElementCreateSplitterY(screen1, 2, 0, 0);

// Devide the first section in 3 (horizontally)
struct CElement *splitX1 = CElementCreateSplitterX(splitY, 3, 0, 0);
struct CElement *splitX2 = CElementCreateSplitterX(splitY, 3, 0, 0);

// Now we have created a white screen with 6 containers.

// Add an image to 2 containers
struct CElement *image = CElementCreateImage(NULL, "name");
CElementAdd(splitX2, image, 1); // add an image to row 2, column 1
CElementAdd(splitX2, image, 2); // also add it to row 2, column 2

// Ofcourse we can also draw a rectangle, circle, line and other stuff using
// CElementCreateLine(x1, y1, x2, y2, struct color);
// CElementCreateRectangle(left, right, width, height, lineWidth, struct color);
// CElementCreateCircle(left, right, width, height, lineWidth, struct color);
// CElementCreateTriangle(left, right, width, height, lineWidth, struct color);

// Draw it :)

Now you’ve drawn something like this (the lines surrounding the containers won’t be drawn by the application, they are only to indicate the begin and ending of a container) :

An image
An image

You won’t have to care about other stuff, all NDS related variables will be configured auto-magically 🙂

You can also draw multiple elements in one container (using CElementCreateContainer) and create a paint like application (or something like it) which I’m currently creating. The script is also using my previous published CList to keep on track of the elements within a splitter or container.

Elements within a splitter or container will be positioned relatively to the container. So if you create a container:

struct CElement *screen1 = CElementCreateScreen(256, 192);
struct CElement *container = \
CElementCreateContainer(screen1, 100, 100, 40, 40);
CElementCreateRectangle(container, 40, 40, 40, 40); 
// toElement, widht, height, left-, top-offset

It will look like this, the rectangle will be placed with an offset of 40px left and top relatively to the container:

This is the screen

This is the container


I will release my code Sunday, so others can play with it.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: