Windows can be placed in any layer or display, drawing operations can be used on any layer or display. Since there are really only smaller differences from this point of view, multiple layers and multiple displays are handled the same way (Using the same API routines) and are simply referred to as multiple layers, even if the particular embedded system uses multiple displays. The µC/GUI viewer allows you to look at every individual layer (display), but in the case of multiple layer systems also to look at the actual output (the composite view).
Limitations
Currently systems with multiple displays and multiple layers can be used, but not simulated. Currently systems with a total of max 5 displays / layers are supported.
Sub-Section
When drawing directly, per default layer 0 is used. An other layer can be selected by using GUI_SelLayer().
Sample
The following sample shows how to select a layer for drawing operations:
void MainTask(void) {
GUI_Init();
/* Draw something on default layer 0 */
GUI_SetBkColor(GUI_GREEN);
GUI_Clear();
GUI_DispStringHCenterAt("Layer 0", 100, 46);
/* Draw somethingon layer 1 */
GUI_SelLayer(1); /* Select layer 1 */
GUI_SetBkColor(GUI_RED);
GUI_Clear();
GUI_SetColor(GUI_BLUE);
GUI_FillRect(20, 20, 179, 79);
GUI_SetColor(GUI_WHITE);
GUI_SetTextMode(GUI_TM_TRANS);
GUI_DispStringHCenterAt("Layer 1", 100, 46);
while(1) {
GUI_Delay(100);
}
}
Screenshot of above sample
Selecting a layer for a window
The window manager automatically keeps track of which window is located in which layer. This is done in a fairly easy way: If the window manager is used, every layer has a top level (desktop) window. Any other window in this layer is visible only if it is a descendent (a child or grand- child or ...) of one of these desktop windows. Which layer a window is in depends solely on which desktop window it is a descendent of.
Sample
hWin0 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(0), WM_CF_SHOW, _cbWin0, 0);
/* Create 2 child windows on destop 1 */
hWin1 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin1, 0);
hWin2 = WM_CreateWindowAsChild(110, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin2, 0);
Screenshot of above sample
Screenshot Window hierarchy
Moving a window from one layer to an other
This can sometime be very desireable and can easily be accomplished: If a window is detached from its parent (The desktop window of one layer or any descenedent of this ldesktop window) and attached to a window which lies in an other layer, this win- dow actually moves from one layer to an other layer.
Sample
The following sample shows how to detach a window from its parent window and how to attach it to a new parent window:
/* Create 1 child window on destop 0 */
hWin0 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(0), WM_CF_SHOW, _cbWin0, 0);
/* Create 2 child windows on destop 1 */
hWin1 = WM_CreateWindowAsChild( 10, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin1, 0);
hWin2 = WM_CreateWindowAsChild(110, 20, 80, 70, WM_GetDesktopWindowEx(1), WM_CF_SHOW, _cbWin2, 0); GUI_Delay(1000);
/* Detach window 2 from desktop 1 and attach it to desktop 0 */
WM_AttachWindow(hWin2, WM_GetDesktopWindowEx(0));
Any other window in this layer is visible only if it is a descendent (a child or grand- child or ...) of one of these desktop windows. Which layer a window is in depends solely on which desktop window it is a descendent of.
Screenshot Window hierarchy
The next table shows the screenshot and the window hierarchy of the above sample after attaching the window to the new parent:
Screenshot Window hierarchy
Using multi layer support
µC/GUI does not distinguish between multiple layers or multiple displays. When using multiple layers normally the size and the driver for each layer is the same. The viewer shows each layer in a separate window. The composite window of the viewer shows the layers one above the other:
Using the viewer with multiple layers
The µC/GUI viewer treats pixels with index 0 in a layer above layer 0 as transparent. This means in the composite view the pixels of the layers below are visible.
Using transparency
The following sample shows how to draw transparent and non transparent:
GUI_SelLayer(1);
GUI_SetBkColor(GUI_WHITE);
/* Select white for the background */
GUI_Clear();
GUI_SetColor(GUI_BLACK);
/* Select black for the text */
GUI_SetFont(&GUI_FontComic24B_ASCII);
GUI_DispStringHCenterAt("Layer#:1", XSize / 2, 5);
GUI_SetColorIndex(0);
/* Select transparency */
GUI_FillCircle(LCD_GetXSize() / 2, YSize / 2 + 15, YSize / 2 - 20);
/* A transparent circle will be drawn */
Multi layer sample
The sample below contains a screenshot of the viewer with 2 layers. The simulated LCD-controller is the integrated LCD-controller of a Toshiba TMPR3916 (Capricorn 2). Layer 0(E) shows color bars with a high color configuration. Layer 1(B) shows a transparent circle on a white background with colored rectangles. The composite win- dow shows the result which is actually visible on the display:
Since for all but layer 0 Index 0 means transparency, Index 0 can not be used to dis- play colors. This also means that the color conversion should never yield 0 as best match for a color, since this would result in a transparent pixel. This means that only some fixed palette modes should be used and that you need to be careful when defining you own palette. You need to make sure that the color conversion (24 bit RGB -> Index) never yields 0 as result.
More informations: