Liqbase library overview

(New page: =liqbase :: the core library= The formatting here is rubbish and I dunno how to fix it. This is preliminary outline documentation for my library and toolkit. it will be expanded upon over...)
(wikify slightly, mark as outof date)
 
(17 intermediate revisions not shown)
Line 1: Line 1:
-
=liqbase :: the core library=
+
{{out of date}}
 +
 
 +
==liqbase :: the core library==
 +
 
 +
'''Note, this document describes a library which is not currently available, however its precursor [[liqbase]] is available for download:'''
 +
 
 +
'''http://maemo.org/downloads/product/OS2008/liqbase/.'''
-
The formatting here is rubbish and I dunno how to fix it.
 
This is preliminary outline documentation for my library and toolkit.
This is preliminary outline documentation for my library and toolkit.
-
it will be expanded upon over the coming days
+
it will be expanded upon over the coming days.
 +
 
 +
===Rationale===
 +
 
 +
liqbase was born of frustration.
-
'''Note, this describes a library which is not currently available, however its precursor [[liqbase]] is available.'''
+
It started out as a collection of ideas and principles which show off the nokia internet tablet as a fast versatile handheld computer which very rapidly grew into a large monolithic application.
 +
It was the first application I have written in C in many years has been used to learn about the device and the various libraries and interactions on the Nokia internet tablets.
-
liqbase is a simplified interface to the computer.
+
A proof of concept so to speak.
-
It has been designed to make it as easy as possible to produce high performance touch sensitive applications.
+
The library is aimed to correct the mistakes I made and to provide a framework to continue building my shiny applications.
-
The applications are resolution independent and capable of operating at high speed in with low cpu overheads.
+
It contains a small set of classes which are usable for creating rich touchable GUI components.
It contains a small set of classes which are usable for creating rich touchable GUI components.
It has been written in C for both speed and expandability.
It has been written in C for both speed and expandability.
-
The core library has been written with expansion and translation in  mind and will be happy sitting in almost any operating system.
+
At present it is very specifically focused upon the Nokia internet tablet computers though it is compilable and usable within x86 linux as well.
 +
 
 +
===Why not GTK+ or Qt?===
 +
 
 +
I looked carefully at GTK+ when I first got my tablet and would have been happy it if it had the required performance, it has (semi) sane construction methods and an expansive library of controls and utility functions.
 +
 
 +
However on the tablet graphical performance was so poor that anything I attempted felt slow and applications crawled along. Qt had its own problems and still is not a viable option on the devices.
 +
 
 +
I wanted to do things which I took for granted on my old PDA and have done for years in Visual Basic and found the existing toolkits lacking.
 +
 
 +
===Dependencies===
 +
 
 +
liqbase makes use of the following libraries:
-
At present it is very specifically targeted at the Linux platform and requires
 
*X11 window manager for the events.
*X11 window manager for the events.
*XVideo, an x11 graphics accelerator usually used for rendering video frames.
*XVideo, an x11 graphics accelerator usually used for rendering video frames.
Line 25: Line 45:
*xsp for the pressure sensitive mouse input
*xsp for the pressure sensitive mouse input
*ttflib ttf font handling
*ttflib ttf font handling
-
*libpng
+
*libpng for reading and writing image data
*libjpeg
*libjpeg
 +
*sqlite3 for the database manipulation
 +
graphics are rendered using the XV library using the YUV video format. This is a lower bandwidth video mode which has full resolution Luma, but half resolution Chroma.
-
graphics are rendered using the XV library using the YUV video format.
+
===Base Classes===
-
This is a lower bandwidth video mode which has full resolution Luma, but half resolution Chroma.
+
 +
It is being constructed around a core set of interrelated classes
 +
*liqapp core system functions
 +
*liqcanvas provides actual display backbuffer and event sink
 +
*liqimage native image class, allows alpha, files of type png and jpeg supported
 +
*liqfont a renderable font library, extensive caching
 +
*liqsketch a dynamic sketch built up from various strokes and points
 +
*liqcliprect a physical rectangle within an image with direct drawing routines
-
It is being constructed around a set of interrelated classes
+
Beyond the core there is a second layer of classes dealing with structured layout and rendering
-
*liqapp core system functions global
+
*liqcell a single unit capable of holding or representing physical or meta data
-
*liqcanvas provides actual display backbuffer and event sink global
+
*liqgraph a special resolution independent graphics interface which a cell uses
-
*liqimage native image class, allows alpha, files of type png and jpeg supported inst
+
-
*liqfont a renderable font library, extensive caching, inst
+
-
*liqsketch a dynamic sketch built up from various strokes and points inst
+
-
*liqcliprect a physical rectangle within an image with direct drawing routines inst
+
-
Beyond the core there is a whole other set of classes dealing with layout and grouping.
+
With these classes I will be able to construct the applications started inside liqbase.
-
 
+
-
*liqcell a single unit capable of holding or representing physical or meta data inst
+
-
*liqgraph a special resolution independent graphics interface which a cell uses inst
+
-
 
+
-
The cell class is capable of raising and listening for events as well as being inheritable.
+
 +
The classes outlined here existed in some form or other in the old liqbase and I have not yet documented the descendants of the cell class which sit together to form the UI itself.
   
   
-
=class structure=
+
===system class structure===
-
 
+
-
 
+
-
Most classes created in liqbase follow the same object pattern and contain the following default standard methods:
+
-
int class_new()
+
The system classes created in liqbase follow the same object pattern and contain the following default standard methods:
 +
<source lang="c">
 +
class *class_new()
{
{
// Create a brand new instance of the class
// Create a brand new instance of the class
}
}
-
int class_hold()
+
int class_hold(class *self)
{
{
// Add a reference to an existing instance
// Add a reference to an existing instance
}
}
-
int class_release()
+
int class_release(class *self)
{
{
// release a reference to an instance
// release a reference to an instance
Line 72: Line 91:
}
}
-
int class_free()
+
int class_free(class *self)
{
{
// release all memory for this instance
// release all memory for this instance
// call _release on all members of this class
// call _release on all members of this class
}
}
 +
</source>
-
The reference counting is held as a private member inside the instance itself.
+
User classes and instances built from cells do not require this interface.
 +
The reference counting is held as a private member inside the instance itself.
There is no concept of inheritance at this level, however once you have instances of cell classes (described in detail below) they follow generic inheritance rules and can expand.
There is no concept of inheritance at this level, however once you have instances of cell classes (described in detail below) they follow generic inheritance rules and can expand.
 +
===Example cell lifespan===
 +
A usual cycle goes something like this
-
+
<source lang="c">
-
Example Cell construction
+
void hello_world()
 +
{
 +
    liqcell * myform = liqcell_newwidget(“myform”,”form”, 340, 60);
 +
    liqcell *l1 = liqcell_newwidget(“hello”,”label”, 60, 60);
 +
    liqcell *l2 = liqcell_newwidget(“world”,” label”, 60, 60);
-
A usual cycle goes like this
+
    // do stuff with these instances and maybe create a tree of objects
 +
    liqcell_child_insert(myform , l1 );
 +
    liqcell_child_insert(myform , l2 );
 +
    liqcell_child_arrange_automatic(myform);
 +
    liqcell_show(myform);
-
void hello_world()
+
    // now we are finished release the root of the tree. 
-
{
+
    // all items inserted will be recursively released.
-
liqcell * myform = liqcell_newwidget(“myform”,”form”, 340, 60);
+
-
liqcell *l1                = liqcell_newwidget(“hello”,”label”, 60, 60);
+
-
liqcell *l2 = liqcell_newwidget(“world”,” label”, 60, 60);
+
-
// do stuff with these instances and maybe create a tree of objects
+
    liqcell_release(myform);
 +
}
 +
</source>
-
liqcell_child_insert(myform , l1 );
+
===Cell inheritance===
-
liqcell_child_insert(myform , l2 );
+
-
liqcell_child_arrange_automatic(myform);
+
-
liqcell_show(myform);
+
The cell class provides a basic unit which everything is built up from. When used in a visual context, it represents a rectangular area on the screen. A cell can also be used as a simple  property holding information intended for its parent. Each cell can hold references to a font, an image and a sketch or even another cell. It can be inherited from other cells which expand its utility and purpose.
-
// now we are finished release the root of the tree. 
+
===Dynamic scaling===
-
// all items inserted will be recursively released.
+
-
liqcell_release(myform);
+
liqbase is designed to operate in a truly resolution independent manner, after designing a widget according to specifications, it does not matter whether it is run on a lower or higher resolution display as the content will render correctly.
-
}
+
 
 +
I have taken special care ensuring the font class operates as expected within a dynamic resolution independent environment. At design time, the operator configures a form to certain dimensions (at 225dpi) and configures font sizes and positions relative to this. The fonts make use of extensive dynamic caching to both improve loading speed and to ensure that the correct glyph is displayed at the correct size as required.  The slight drawback with this approach is that at different scales there is some very slight variation in the exact final font size due to integer only glyph widths.
 +
 
 +
At runtime, the entire screen is situated within the available boundary and rendered accordingly. A landscape layout will run correctly in portrait mode, however it will be displayed at a reduced size to maintain its aspect ratio.
 +
 
 +
===Event handlers===
 +
 
 +
You can assign event handlers to any cell in liqbase and have a routine called when the event is required.
 +
New events can be dynamically created and utilized as required.
 +
 
 +
====Linking handler to cell====
 +
 
 +
<source lang="c">
 +
*vcell_handleradd(self,    "paint",  world_paint);
 +
</source>
 +
 
 +
====Handler Code====
 +
 
 +
<source lang="c">
 +
static int world_paint(vcell *self, vcellpainteventargs *args)
 +
{
 +
//liqapp_log("painting...");
 +
// tell the subsystem this event has been handled (returning 0 will cause the chain to continue)
 +
return 1;
 +
}
 +
</source>
 +
 
 +
====Using a handler====
 +
 
 +
<source lang="c">
 +
vcell_handlerrun(self,"paint",&paintargs);
 +
</source>
 +
 
 +
[[Category:Software]]
 +
[[Category:Documentation]]

Latest revision as of 12:59, 8 February 2011

Image:Ambox_content.png
This article is out-of-date, and needs to be updated.
Please see the talk page for discussion.

Contents

[edit] liqbase :: the core library

Note, this document describes a library which is not currently available, however its precursor liqbase is available for download:

http://maemo.org/downloads/product/OS2008/liqbase/.

This is preliminary outline documentation for my library and toolkit. it will be expanded upon over the coming days.

[edit] Rationale

liqbase was born of frustration.

It started out as a collection of ideas and principles which show off the nokia internet tablet as a fast versatile handheld computer which very rapidly grew into a large monolithic application.

It was the first application I have written in C in many years has been used to learn about the device and the various libraries and interactions on the Nokia internet tablets.

A proof of concept so to speak.

The library is aimed to correct the mistakes I made and to provide a framework to continue building my shiny applications.

It contains a small set of classes which are usable for creating rich touchable GUI components. It has been written in C for both speed and expandability.

At present it is very specifically focused upon the Nokia internet tablet computers though it is compilable and usable within x86 linux as well.

[edit] Why not GTK+ or Qt?

I looked carefully at GTK+ when I first got my tablet and would have been happy it if it had the required performance, it has (semi) sane construction methods and an expansive library of controls and utility functions.

However on the tablet graphical performance was so poor that anything I attempted felt slow and applications crawled along. Qt had its own problems and still is not a viable option on the devices.

I wanted to do things which I took for granted on my old PDA and have done for years in Visual Basic and found the existing toolkits lacking.

[edit] Dependencies

liqbase makes use of the following libraries:

  • X11 window manager for the events.
  • XVideo, an x11 graphics accelerator usually used for rendering video frames.
  • Gstreamer, for the camera
  • Esound for the audio output
  • xsp for the pressure sensitive mouse input
  • ttflib ttf font handling
  • libpng for reading and writing image data
  • libjpeg
  • sqlite3 for the database manipulation

graphics are rendered using the XV library using the YUV video format. This is a lower bandwidth video mode which has full resolution Luma, but half resolution Chroma.

[edit] Base Classes

It is being constructed around a core set of interrelated classes

  • liqapp core system functions
  • liqcanvas provides actual display backbuffer and event sink
  • liqimage native image class, allows alpha, files of type png and jpeg supported
  • liqfont a renderable font library, extensive caching
  • liqsketch a dynamic sketch built up from various strokes and points
  • liqcliprect a physical rectangle within an image with direct drawing routines

Beyond the core there is a second layer of classes dealing with structured layout and rendering

  • liqcell a single unit capable of holding or representing physical or meta data
  • liqgraph a special resolution independent graphics interface which a cell uses

With these classes I will be able to construct the applications started inside liqbase.

The classes outlined here existed in some form or other in the old liqbase and I have not yet documented the descendants of the cell class which sit together to form the UI itself.

[edit] system class structure

The system classes created in liqbase follow the same object pattern and contain the following default standard methods:

class *class_new()
{
	// Create a brand new instance of the class
}
 
int class_hold(class *self)
{
	// Add a reference to an existing instance
}
 
int class_release(class *self)
{
	// release a reference to an instance
	// if there are no more instances, call _free on the instance
}
 
int class_free(class *self)
{
	// release all memory for this instance
	// call _release on all members of this class
}

User classes and instances built from cells do not require this interface.

The reference counting is held as a private member inside the instance itself. There is no concept of inheritance at this level, however once you have instances of cell classes (described in detail below) they follow generic inheritance rules and can expand.

[edit] Example cell lifespan

A usual cycle goes something like this

void hello_world()
{
    liqcell * myform		= liqcell_newwidget(“myform”,”form”, 340, 60);
    liqcell *l1		= liqcell_newwidget(“hello”,”label”, 60, 60);
    liqcell *l2 		= liqcell_newwidget(“world”,” label”, 60, 60);
 
    // do stuff with these instances and maybe create a tree of objects
 
    liqcell_child_insert(myform , l1 );
    liqcell_child_insert(myform , l2 );
    liqcell_child_arrange_automatic(myform);
 
    liqcell_show(myform);
 
    // now we are finished release the root of the tree.  
    // all items inserted will be recursively released.
 
    liqcell_release(myform);
}

[edit] Cell inheritance

The cell class provides a basic unit which everything is built up from. When used in a visual context, it represents a rectangular area on the screen. A cell can also be used as a simple property holding information intended for its parent. Each cell can hold references to a font, an image and a sketch or even another cell. It can be inherited from other cells which expand its utility and purpose.

[edit] Dynamic scaling

liqbase is designed to operate in a truly resolution independent manner, after designing a widget according to specifications, it does not matter whether it is run on a lower or higher resolution display as the content will render correctly.

I have taken special care ensuring the font class operates as expected within a dynamic resolution independent environment. At design time, the operator configures a form to certain dimensions (at 225dpi) and configures font sizes and positions relative to this. The fonts make use of extensive dynamic caching to both improve loading speed and to ensure that the correct glyph is displayed at the correct size as required. The slight drawback with this approach is that at different scales there is some very slight variation in the exact final font size due to integer only glyph widths.

At runtime, the entire screen is situated within the available boundary and rendered accordingly. A landscape layout will run correctly in portrait mode, however it will be displayed at a reduced size to maintain its aspect ratio.

[edit] Event handlers

You can assign event handlers to any cell in liqbase and have a routine called when the event is required. New events can be dynamically created and utilized as required.

[edit] Linking handler to cell

	*vcell_handleradd(self,    "paint",   world_paint);

[edit] Handler Code

	static int world_paint(vcell *self, vcellpainteventargs *args)
	{
		//liqapp_log("painting...");
		// tell the subsystem this event has been handled (returning 0 will cause the chain to continue)
		return 1;
	}

[edit] Using a handler

	vcell_handlerrun(self,"paint",&paintargs);