🌐 English

    GUI Framework API#

    It is called within the oasis::ui namespace category.

    Header File#

    OasisUI.h

    Setup and Cleanup#

    int32_t setup ( key_value_map_t & parameters )
    OasisUI.h
    Initializes oasis::ui and creates the default screen object.
    Parameters
    parameters  The key-value map required for oasis::ui initialization.
    Return Value
    • 0: Success
    • -1: Failure

    The key-value map required for oasis::ui initialization is as follows:

    Key
    Default
    M
    Description
    system-font-path
     
    The font file path used by Oasis. It supports TrueType fonts. If this key value is already specified in oasis::initialize, it will be overwritten.
    system-font-size
    10
     
    The default font size used by Oasis, measured in points. If this key value is already specified in oasis::initialize, it will be overwritten.
    display-rotation
    0
     
    Rotates the display device by the given angle. When operating to rotate by 90 degrees or 270 degrees, the GUI screen width uses the height value of the display device, and the screen height uses the width value of the display device. The height and width values of the display are configured by the oasis::display::setup API.
    enable-touch
    1
     
    Activates the touch device.
    touch-cal-data-path
     
    The touch calibration data file path. If this data file is invalid, the touch function is deactivated. The content of the data file is a string listing 9 numbers separated by whitespace on a single line. For example, in the case of a 480x320 display device, it is "302 3967 244 3829 8583 5850 65536 480 320".
    fb0-hlayer
     
    The display HLAYER string used in the graphic context of the GUI. The string consists of each layer component ID separated by ":". For example, it is formatted like "1:1:0".
    vi0-hlayer
     
    The display HLAYER string used in YUV channels such as camera video. The string consists of each layer component ID separated by ":". For example, it is formatted like "1:0:0".
    hide-unmanaged-ui-layer
     
    The hLAYER string dedicated to external UI components (such as Qt) that are not managed by Oasis GUI. The string consists of each layer component ID separated by ":". For example, it is formatted like "1:2:0".
    hide-unmanaged-ui-layers
     
    The hLAYER list dedicated to external UI components (such as Qt) that are not managed by Oasis GUI. Each HLAYER is separated by a comma (,). For example, it is formatted like "1:2:0,1:3:0".
    lcd-dpi-x
    96.0
     
    The dPI x value of the display.
    lcd-dpi-y
    96.0
     
    The dPI y value of the display.
    lcd-dpi
    96.0
     
    The dPI x and y values of the display.

    Note

    If both hide-unmanaged-ui-layer and hide-unmanaged-ui-layers keys are specified, hide-unmanaged-ui-layers is used.

    The display module of the chipset supports multiple channels per purpose, and multiple layers per channel. It supports at least one channel and one layer. Oasis manages the GUI side by dividing it into HLAYER to match the layer structure supported by the display module of each chipset.

    HLAYER is a 32-bit integer value and has a 3-tuple structure with (channel, hard layer, soft layer) as its elements. When having a (channel, layer) structure depending on the chipset, the hLAYER string format is specified as a 2-tuple like "0:1". For example, if there are multiple cores responsible for display control, channel specifies the core index as 0, 1, 2, etc., hard layer specifies the layer supported by each core, and soft layer can have a structure generated by Oasis as needed.

    Touch calibration data values are calculated using 5 points obtained by touching, as shown in the function below.

    struct {
      int32_t x;
      int32_t y;
    } touch[5] = { 0, };
    
    int32_t cal[9] = { 0, };
    
    void calibrate() 
    {
        double dx_min, dy_min, dx_max, dy_max;
        double dx_ratio, dy_ratio, scale = 65536.0;
        int32_t i;
    
        double x_distance = 0.0, y_distance = 0.0;
    
        x_distance += (double)(touch[4].x-touch[0].x);
        x_distance += (double)(touch[4].x-touch[3].x);
        x_distance += (double)(touch[1].x-touch[4].x);
        x_distance += (double)(touch[2].x-touch[4].x);
        x_distance /= 4.0;
        dx_ratio = (double)(screen[4].x-screen[0].x)/x_distance;
    
        y_distance += (double)(touch[4].y-touch[0].y);
        y_distance += (double)(touch[4].y-touch[1].y);
        y_distance += (double)(touch[3].y-touch[4].y);
        y_distance += (double)(touch[2].y-touch[4].y);
        y_distance /= 4.0;
        dy_ratio = (double)(screen[4].y-screen[0].y)/y_distance;
    
        dx_min = dx_max = 0.0;
        dy_min = dy_max = 0.0;
    
        for(i=0; i<5; i++) {
            dx_min += (double)touch[i].x - (double)screen[i].x/dx_ratio;
            dx_max += (double)touch[i].x + (double)(width_-screen[i].x)/dx_ratio;
            dy_min += (double)touch[i].y - (double)screen[i].y/dy_ratio;
            dy_max += (double)touch[i].y + (double)(height_-screen[i].y)/dy_ratio;
        }
        dx_min /= 5.0;
        dy_min /= 5.0;
        dx_max /= 5.0;
        dy_max /= 5.0;
    
        cal[0] = (int32_t)dx_min;
        cal[1] = (int32_t)dx_max;
        cal[2] = (int32_t)dy_min;
        cal[3] = (int32_t)dy_max;
        cal[4] = (int32_t)(dx_ratio*scale);
        cal[5] = (int32_t)(dy_ratio*scale);
        cal[6] = (int32_t)scale;
        cal[7] = 480;  //display width
        cal[8] = 320;  //display height
    }
    
    size_t save(const char *path)
    {
        FILE *f = fopen(path, "w");
        if(!f) {
            return 0;
        }
    
        char cal_buffer[256];
        ssize_t len = sprintf(cal_buffer,"%d %d %d %d %d %d %d %d %d", 
                cal[0], cal[1], cal[2], cal[3], cal[4], cal[5], cal[6], cal[7], cal[8]);
        fwrite (cal_buffer, 1, len, f);
        fclose(f);
    
        return len;
    }
    

    Physical (x, y) coordinates obtained when a touch event occurs are converted into screen coordinates used by the GUI, as shown in the function below.

    struct {
      int32_t x;
      int32_t y;
    } ui_touch;
    
    void touchToScreen(int32_t x, int32_t y)
    {
        ui_touch.x = (x - cal[0])*cal[4]/cal[6];
        ui_touch.y = (y - cal[2])*cal[5]/cal[6];
    }
    

    Below is an initialization example.

    oasis::key_value_map_t parameters;
    
    parameters["system-font-size"] = "11";
    parameters["system-font-path"] = "/mnt/sd/NanumGothicCoding.ttf";
    parameters["display-rotation"] = "0";
    parameters["enable-touch"] = "1";
    parameters["touch-cal-data-path"] = "/mnt/sd/cal.dat";
    
    parameters["vi0-hlayer"] = "1:0:0";
    parameters["fb0-hlayer"] = "1:1:0";
    parameters["hide-unmanaged-ui-layer"] = "1:2:0";
    
    ui::setup(parameters);
    

    Below is an initialization example when using the display rotated by 270 degrees.

    ////////////////////////////////////////////////////////////////////////////////////////////
    // display setup
    parameters.clear();
    
    parameters["memory-type"] = "ion"; //cma
    parameters["screen-width"] = "720";
    parameters["screen-height"] = "1920";
    
    display::setup(parameters);
    
    
    //////////////////////////////////////////////////////////////////////////////////////////
    // ui setup
    parameters.clear();
    
    parameters["system-font-size"] = "10";
    parameters["system-font-path"] = "/mnt/sd/consola.ttf";
    
    parameters["display-rotation"] = "270";
    parameters["enable-touch"] = "0";
    
    parameters["fb0-hlayer"] = "0:1:0";
    parameters["vi0-hlayer"] = "0:0:0";
    
    err = ui::setup(parameters);
    if (err < 0) {
      DLOG(DLOG_ERROR, "Oasis ui::setup failed\n");
      return -1;
    }
    
    int32_t cleanup ( )
    OasisUI.h
    Releases resources allocated in oasis::ui and terminates.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t getDisplayFD ( )
    OasisUI.h
    If the chipset driver exposes the display device to the device node tree like /dev/disp, it returns the corresponding device driver handle.
    Return Value
    Returns the device handle number on success. Returns -1 if it is not supported or fails.
    void * getDisplayHandle ( )
    OasisUI.h
    If the chipset driver uses a handle object for the display device, it obtains that object. This object is the display handle pointer of the chipset.
    Return Value
    Returns the display handle object on success. Returns nullptr if it is not supported or fails.
    hlayer_t stringToHlayer ( const char * str )
    OasisUI.h
    Converts an HLAYER string format into an integer type of hlayer_t.
    Parameters
    str  The hLAYER string pointer. The string consists of each layer component ID separated by ":". For example, it is formatted like "1:2:0".
    Return Value
    Returns the converted value as hlayer_t on success. Returns -1 if the format is incorrect.

    Note

    The stringToHlayer API exists in the oasis namespace, not oasis::ui.

    Screen#

    ScreenRef getDefaultScreen ( )
    OasisUI.h
    Obtains the default screen object.
    Return Value
    Returns the default screen object if ui::setup is successful. Returns nullptr if it fails.
    int32_t screenWidth ( const ScreenRef & screen )
    OasisUI.h
    Obtains the width of the screen object.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t screenHeight ( const ScreenRef & screen )
    OasisUI.h
    Obtains the height of the screen object.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    Return Value
    • 0: Success
    • -1: Failure
    void screenHide ( const ScreenRef & screen )
    OasisUI.h
    Hides the screen.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    void screenShow ( const ScreenRef & screen )
    OasisUI.h
    Makes the screen visible.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    int64_t screenLastDrawnElapsedTimeInUsec ( const ScreenRef & screen )
    OasisUI.h
    Returns the time taken to draw the screen in microseconds.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    Return Value
    The time taken for drawing, measured in microseconds.
    ssize_t takeScreenShot ( const ScreenRef & screen , std::vector<uint8_t> & png_data , uint32_t flags = 0 )
    OasisUI.h
    Generates screen capture data. The data format is PNG.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    png_data  OUT Returns the capture data.
    flags  The flag value. Specify "0".
    Return Value
    Returns the capture data size on success. Returns -1 on failure.
    void screenAdd ( const ScreenRef & screen , const WindowRef & window )
    OasisUI.h
    Adds the top-level window object to the screen.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    window  The window object created via createWindow.
    void screenRemove ( const ScreenRef & screen , const WindowRef & window )
    OasisUI.h
    Removes the specified top-level window object from the screen. If there is no reference to the specified window, it is destroyed.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    window  The window object created via createWindow.
    bool screenTouchInputEnabled ( const ScreenRef & screen )
    OasisUI.h
    Verifies whether the screen touch function is activated.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    Return Value
    Returns true if activated. Returns false if deactivated.
    bool screenTouchCalDataPathValid ( const ScreenRef & screen )
    OasisUI.h
    Verifies whether the screen touch calibration data is valid.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    Return Value
    Returns true if valid. Returns false if invalid.
    const char * screenTouchCalDataPath ( const ScreenRef & screen )
    OasisUI.h
    Obtains the touch calibration data file path.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    Return Value
    Returns the touch calibration data file path.
    bool screenUpdateTouchCalData ( const ScreenRef & screen , const char * cal_data_path )
    OasisUI.h
    Updates the touch calibration data.
    Parameters
    screen  The screen object obtained via getDefaultScreen.
    cal_data_path  The absolute path of the touch calibration data file.
    Return Value
    Returns true if the update is successful. Returns false if it fails.
    bool isUnmanagedUILayerOpen ( int32_t hlayer )
    OasisUI.h
    Verifies whether an external UI component layer such as Qt is open.
    Parameters
    hlayer  The hLAYER used by the external UI component.
    Return Value
    Returns true if the external UI component layer is open. Returns false if it is closed.
    int32_t closeUnmanagedUILayer ( int32_t hlayer )
    OasisUI.h
    Closes an external UI component layer such as Qt. When closed, it is not visible on the display.
    Parameters
    hlayer  The hLAYER used by the external UI component.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t openUnmanagedUILayer ( int32_t hlayer )
    OasisUI.h
    Opens an external UI component layer such as Qt.
    Parameters
    hlayer  The hLAYER used by the external UI component.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t pixelToPoint ( int32_t pixel_size )
    OasisUI.h
    Converts a pixel value into a point value according to the DPI value of the display.
    Parameters
    pixel_size  The pixel value to convert.
    Return Value
    The converted point value. Returns 0 if the display, screen, or DPI value is incorrect.
    int32_t pointToPixel ( int32_t point_size )
    OasisUI.h
    Converts a point value into a pixel value according to the DPI value of the display.
    Parameters
    point_size  The point value to convert.
    Return Value
    The converted pixel value. Returns 0 if the display, screen, or DPI value is incorrect.
    void setDevelFlags ( uint64_t flags , bool set = true )
    OasisUI.h
    Activates flags for UI development.
    Parameters
    flags  The flag value to activate or deactivate.
    set  Activates if true, and clears the corresponding flag value if false.

    The flags are as follows:

    enum UIDevelFlags : uint64_t {
        kUIDevelFlag_Border = 0x0000000000000001ull,
        kUIDevelFlag_PrintCallStackOnLayout = 0x0000000000000002ull
    };
    

    kUIDevelFlag_Border draws the border of each widget. The kUIDevelFlag_PrintCallStackOnLayout value is not used.

    Widget#

    void setID ( const WidgetRef & widget , const char * id )
    OasisUI.h
    Specifies a string ID for the widget. The specified ID is also reflected in the class name of the widget. The ID is an empty string upon widget creation.
    Parameters
    widget  Widget objects such as Button, Image, Label, Container, Window, etc.
    id  The widget ID string to set.
    const char * getID ( const WidgetRef & widget )
    OasisUI.h
    Returns the iD string of the widget.
    Parameters
    widget  The widget object.
    Return Value
    The ID string of the widget.
    const char * clsName ( const WidgetRef & widget )
    OasisUI.h
    Obtains the class name of the widget.
    Parameters
    widget  The widget object.
    Return Value
    The class name of the widget.

    The default class names of widgets are as follows:

    Widget Object Class Name
    Button Button
    Dialog Dialog
    DrawingArea DrawingArea
    FixedLayout Fixed
    GridLayout Grid
    BoxLayout Box
    SingleLayout Single
    Image Image
    Label Label
    ListBox ListBox
    Window Window

    When setting an ID string for a widget using ui::setID, the class name is changed to <Class Name>::<ID String>.

    void setPos ( const WidgetRef & widget , int32_t x , int32_t y )
    OasisUI.h
    Specifies the starting position (x, y) of the widget. Each coordinate value is relative to the screen.
    Parameters
    widget  The widget object.
    x  The x coordinate value of the widget.
    y  The y coordinate value of the widget.
    void setFixedSize ( const WidgetRef & widget , int32_t width , int32_t height )
    OasisUI.h
    Specifies a fixed size for the widget. For a widget with a fixed size configured, the container widget uses the fixed size when calculating the layout of this widget.
    Parameters
    widget  The widget object.
    width  The fixed size width of the widget.
    height  The fixed size height of the widget.
    void setFixedHeight ( const WidgetRef & widget , int32_t height )
    OasisUI.h
    Specifies a fixed size height for the widget. For a widget with a fixed size configured, the container widget uses the fixed size height when calculating the layout of this widget.
    Parameters
    widget  The widget object.
    height  The fixed size height of the widget.
    void setFixedWidth ( const WidgetRef & widget , int32_t width )
    OasisUI.h
    Specifies a fixed size width for the widget. For a widget with a fixed size configured, the container widget uses the fixed size width when calculating the layout of this widget.
    Parameters
    widget  The widget object.
    width  The fixed size width of the widget.
    void setSizeRequestMode ( const WidgetRef & widget , SizeRequestMode size_mode )
    OasisUI.h
    Specifies the mode preferred by the widget when requesting size calculation. The container widget calculates the size of the widget based on this mode value.
    Parameters
    widget  The widget object.
    size_mode  The size request mode.

    The SizeRequestMode values are as follows:

    SizeRequestMode Value Description
    kSize​Request​Height​For​Width 0 The widget calculates its preferred height while its width is known.
    kSize​Request​Width​For​Height 1 The widget calculates its preferred width while its height is known. When calling preferredWidth, the container widget calls preferredHeight first to know the height of the widget, and then calls preferredWidthForHeight.
    kSize​Request​Constant​Size 2 The widget can respond to any size calculation request from the container widget. In this case, the container widget requests preferredWidth and preferredHeight first.
    void getCanvasRect ( const WidgetRef & widget , Rect & rect )
    OasisUI.h
    Returns the drawing area of the widget. The graphic Context can draw within this area.
    Parameters
    widget  The widget object.
    rect  OUT Returns the drawing area.

    Note

    The drawing area excludes the margin and padding sizes from the widget.

    void * setUserData ( const WidgetRef & widget , void * user_data )
    OasisUI.h
    Configures user-defined data for the widget.
    Parameters
    widget  The widget object.
    user_data  The user-defined data pointer.
    Return Value
    void * getUserData ( const WidgetRef & widget )
    OasisUI.h
    Obtains user-defined data of the widget.
    Parameters
    widget  The widget object.
    Return Value
    Returns the user-defined data. Returns nullptr if user-defined data is not configured.
    void setDataset ( const WidgetRef & widget , const char * attr , const char * value )
    OasisUI.h
    Configures a dataset value for the widget.
    Parameters
    widget  The widget object.
    attr  The key value of the dataset to be configured.
    value  The value of the dataset.
    const char * getDataset ( const WidgetRef & widget , const char * attr )
    OasisUI.h
    Obtains the dataset value of the widget.
    Parameters
    widget  The widget object.
    attr  The dataset key.
    Return Value
    Returns the corresponding value if the value matching the key value exists, and returns nullptr if it does not exist.
    bool hasDataset ( const WidgetRef & widget , const char * attr )
    OasisUI.h
    Verifies whether the widget possesses the dataset key value.
    Parameters
    widget  The widget object.
    attr  The dataset key.
    Return Value
    • true: The key value exists.
    • false: The key value does not exist.
    bool setVisible ( const WidgetRef & widget , bool visible )
    OasisUI.h
    Applies the widget to be visible or invisible.
    Parameters
    widget  The widget object.
    visible  Makes the widget visible if true, and hides the widget if false.
    Return Value
    Returns the previous state.
    bool isVisible ( const WidgetRef & widget )
    OasisUI.h
    Verifies whether the widget is visible.
    Parameters
    widget  The widget object.
    Return Value
    • true: State is configured to be visible.
    • false: State is configured to be invisible.
    Color setBgColor ( const WidgetRef & widget , Color clr , bool repaint = true )
    OasisUI.h
    Specifies the background color of the widget.
    Parameters
    widget  The widget object.
    clr  The background color value.
    repaint  Specifies whether to repaint immediately after background color specification. Repaints if true.
    Return Value
    Returns the previous background color.
    Color setBorderColor ( const WidgetRef & widget , Color clr , bool repaint = true )
    OasisUI.h
    Specifies the border color of the widget.
    Parameters
    widget  The widget object.
    clr  The border color.
    repaint  Specifies whether to repaint immediately after border color specification. Repaints if true.
    Return Value
    Returns the previous border color.
    void setBorderSize ( const WidgetRef & widget , int32_t size , bool repaint = true )
    OasisUI.h
    Specifies the border thickness of the widget.
    Parameters
    widget  The widget object.
    size  The border thickness, measured in pixels.
    repaint  Specifies whether to repaint after border thickness changes. Repaints if true.
    void setVAlign ( const WidgetRef & widget , AlignType valign )
    OasisUI.h
    Configures the vertical alignment of the widget inside the container widget.
    Parameters
    widget  The widget object.
    valign  The vertical alignment value.

    The horizontal/vertical alignment values are as follows:

    AlignType Value Description
    kAlignFill 0 Fills the widget completely. For vertical alignment, it expands the height. For horizontal alignment, it expands the width.
    kAlignStart 1 Aligns the widget to the starting position. For vertical alignment, it places it at the top. For horizontal alignment, it places it on the left.
    kAlignEnd 2 Aligns the widget to the ending position. For vertical alignment, it places it at the bottom. For horizontal alignment, it places it on the right.
    kAlignFill 3 Aligns the widget to the center position.
    kAlignBaseline 4 Limited to vertical alignment, aligns to the baseline of the container of the widget.
    void setHAlign ( const WidgetRef & widget , AlignType halign )
    OasisUI.h
    Configures the horizontal alignment of the widget inside the container widget.
    Parameters
    widget  The widget object.
    halign  The horizontal alignment value.
    void setMargin ( const WidgetRef & widget , int32_t margin )
    OasisUI.h
    Specifies the margin value of the widget.
    Parameters
    widget  The widget object.
    margin  The margin value applied uniformly to top, bottom, left, and right, measured in pixels.
    void setMargin ( const WidgetRef & widget , int32_t margin_se , int32_t margin_tb )
    OasisUI.h
    Specifies the margin value of the widget.
    Parameters
    widget  The widget object.
    margin_se  The left and right margin value, measured in pixels.
    margin_tb  The top and bottom margin value, measured in pixels.
    void setMargin ( const WidgetRef & widget , int32_t margin_start , int32_t margin_top , int32_t margin_end , int32_t margin_bottom )
    OasisUI.h
    Specifies the margin value of the widget.
    Parameters
    widget  The widget object.
    margin_start  The starting (left) margin value.
    margin_top  The top margin value.
    margin_end  The ending (right) margin value.
    margin_bottom  The bottom margin value.
    void setMarginStart ( const WidgetRef & widget , int32_t margin_start )
    OasisUI.h
    Specifies the starting (left) margin of the widget.
    Parameters
    widget  The widget object.
    margin_start  The left margin value.
    void setMarginEnd ( const WidgetRef & widget , int32_t margin_end )
    OasisUI.h
    Specifies the ending (right) margin of the widget.
    Parameters
    widget  The widget object.
    margin_end  The right margin value.
    void setMarginTop ( const WidgetRef & widget , int32_t margin_top )
    OasisUI.h
    Specifies the top margin of the widget.
    Parameters
    widget  The widget object.
    margin_top  The top margin value.
    void setMarginBottom ( const WidgetRef & widget , int32_t margin_bottom )
    OasisUI.h
    Specifies the bottom margin of the widget.
    Parameters
    widget  The widget object.
    margin_bottom  The bottom margin value.
    void setPadding ( const WidgetRef & widget , int32_t padding )
    OasisUI.h
    Specifies the padding value for the widget.
    Parameters
    widget  The widget object.
    padding  The padding value applied uniformly to top, bottom, left, and right, measured in pixels.
    void setPadding ( const WidgetRef & widget , int32_t margin_se , int32_t margin_tb )
    OasisUI.h
    Specifies the padding value for the widget.
    Parameters
    widget  The widget object.
    margin_se  The left and right padding value, measured in pixels.
    margin_tb  The top and bottom padding value, measured in pixels.
    void setPadding ( const WidgetRef & widget , int32_t margin_start , int32_t margin_top , int32_t margin_end , int32_t margin_bottom )
    OasisUI.h
    Specifies the padding value for the widget.
    Parameters
    widget  The widget object.
    margin_start  The starting (left) padding value.
    margin_top  The top padding value.
    margin_end  The ending (right) padding value.
    margin_bottom  The bottom padding value.
    void setPaddingStart ( const WidgetRef & widget , int32_t padding_start )
    OasisUI.h
    Specifies the starting (left) padding of the widget.
    Parameters
    widget  The widget object.
    padding_start  The starting padding value.
    void setPaddingEnd ( const WidgetRef & widget , int32_t padding_end )
    OasisUI.h
    Specifies the ending (right) padding of the widget.
    Parameters
    widget  The widget object.
    padding_end  The ending padding value.
    void setPaddingTop ( const WidgetRef & widget , int32_t padding_top )
    OasisUI.h
    Specifies the top padding of the widget.
    Parameters
    widget  The widget object.
    padding_top  The top padding value.
    void setPaddingBottom ( const WidgetRef & widget , int32_t padding_bottom )
    OasisUI.h
    Specifies the bottom padding of the widget.
    Parameters
    widget  The widget object.
    padding_bottom  The bottom padding value.
    WidgetRef findWidgetById ( const WidgetRef & widget , const char * id )
    OasisUI.h
    Searches for a widget by ID.
    Parameters
    widget  The parent Container widget object.
    id  The ID string of the widget to find.
    Return Value
    If a widget having id is found among child widgets, it returns that widget object. Returns nullptr if not found or if the parent widget is invalid.
    void queueResize ( const WidgetRef & widget )
    OasisUI.h
    Requests resizing of the widget. The container widget receives this request and proceeds with layout calculation.
    Parameters
    widget  The widget object.
    void queueRepaint ( const WidgetRef & widget )
    OasisUI.h
    Requests repainting of the widget.
    Parameters
    widget  The widget object.
    void preferredSize ( const WidgetRef & widget , Size & size )
    OasisUI.h
    Verifies the preferred size of the widget.
    Parameters
    widget  The widget object.
    size  OUT Returns the preferred size of the widget.
    void lockUpdate ( const WidgetRef & widget )
    OasisUI.h
    Temporarily prevents widget geometry updating and repainting.
    Parameters
    widget  The widget object.
    void unlockUpdate ( const WidgetRef & widget )
    OasisUI.h
    Unlocks the temporarily prevented widget geometry updating and repainting.
    Parameters
    widget  The widget object.
    int32_t requestAnimatedFrame ( const WidgetRef & widget , raf_bind_t bind )
    OasisUI.h
    Requests animation drawing on the widget (rAF). Once the callback is invoked, rAF can be requested again. If it is not requested, the animation drawing process stops.
    Parameters
    widget  The widget object.
    bind  The animation drawing callback function.
    Return Value
    • 0: Success
    • -1: Failure

    raf_bind_t is defined as follows:

    typedef std::function<void(WidgetRef,GraphicContextRef)> raf_bind_t
    OasisUI.h

    To perform animation drawing on a DrawArea widget, implement it in the following manner:

    // Creates a drawingArea from a player object and requests rAF on it.
    int32_t Player::startDrawPictures()
    {
        std::function<void(ui::WidgetRef,GraphicContextRef)> canvas_draw_bind = std::bind(&Player::draw, this, std::placeholders::_1, std::placeholders::_2);
        ui::DrawingAreaRef canvas = ui::createDrawingArea(canvas_draw_bind);
        ui::setID(canvas, "picture_canvas");
        ui::boxPackStart(vbox, canvas, true, true, 0);
        ui::requestAnimatedFrame(canvas, canvas_draw_bind);
    }
    
    void Player::draw(ui::WidgetRef widget, GraphicContextRef gc) 
    {
        Rect rect;
        ui::getCanvasRect(widget, rect);
    
        // Perform drawing.
    
        if(!completed_) {
            // Request rAF again as needed.
            std::function<void(ui::WidgetRef,GraphicContextRef)> canvas_draw_bind = std::bind(&Player::draw, this, std::placeholders::_1, std::placeholders::_2);
            ui::requestAnimatedFrame(widget, canvas_draw_bind);
        }
    }
    
    void enableLayoutLog ( const WidgetRef & widget , bool enable = true , bool apply_to_children = true )
    OasisUI.h
    Activates layout-related logging.
    Parameters
    widget  The widget object.
    enable  Activates logging if true, and clears logging if false.
    apply_to_children  Specifies whether to apply this to child widgets. Applies to child widgets if true. Does not apply to child widgets if false.
    void setWidgetDevelFlags ( const WidgetRef & widget , uint64_t flags , bool set = true , bool apply_to_children = true )
    OasisUI.h
    Configures developer flags on the widget.
    Parameters
    widget  The widget object.
    flags  The flag.
    set  The flag value is configured if true, and the flag value is cleared if false. Refer to the setDevelFlags API for flag values.
    apply_to_children  Specifies whether to apply this to child widgets. Applies to child widgets if true. Does not apply to child widgets if false.

    Container Interface#

    Oasis GUI layouts child widgets using the following layout containers:

    • Box container widget for arranging in vertical or horizontal directions
    • Fixed container widget for arranging at fixed positions
    • Grid container widget for arranging by specifying rows and columns in a grid manner
    • Single container widget that has only a single child widget
    • ListBox container widget capable of scrolling in a list style

    These are widgets derived from the container interface.

    A container widget can include other container widgets.

    The container interface is created via createBox, createFixed, createGrid, createWindow, createButton, createListBox, etc.

    void containerAdd ( const ContainerRef & container , const WidgetRef & widget )
    OasisUI.h
    Adds a widget as a child to the layout container widget.
    Parameters
    container  The container object.
    widget  The widget object to add.
    void containerRemove ( const ContainerRef & container , const WidgetRef & widget )
    OasisUI.h
    Removes a widget from the layout container widget.
    Parameters
    container  The container object.
    widget  The widget object.

    Box Container#

    The box container widget arranges child widgets horizontally or vertically.

    BoxRef createBox ( Orientation orientation , bool homogeneous , int32_t spacing )
    OasisUI.h
    Creates a box container widget.
    Parameters
    orientation  Specifies the layout direction. Enter either ui::kOrientationVertical or ui::kOrientationHorizontal. ui::kOrientationVertical arranges child widgets from top to bottom, and ui::kOrientationHorizontal arranges child widgets from left to right.
    homogeneous  If set to true, child widgets have a homogeneous size. For ui::kOrientationVertical, heights are homogeneous; for ui::kOrientationHorizontal, widths are homogeneous.
    spacing  Specifies the space between each child widget, measured in pixels.
    Return Value
    Returns the box container widget on success. Returns nullptr on failure.
    void drawBoxLine ( const BoxRef & box , int32_t x0 , int32_t y0 , int32_t x1 , int32_t y1 , Color clr )
    OasisUI.h
    Draws the border of the box container widget.
    Parameters
    box  The box container widget created via createBox.
    x0  The x coordinate of the top-left corner.
    y0  The y coordinate of the top-left corner.
    x1  The x coordinate of the bottom-right corner.
    y1  The y coordinate of the bottom-right corner.
    clr  The border color.
    void boxPackStart ( const BoxRef & box , const WidgetRef & widget , bool expand , bool fill , int32_t padding )
    OasisUI.h
    Adds a child widget to the box container widget based on the starting position of the box. If there are widgets already added via boxPackStart, it is appended immediately after them.
    Parameters
    box  The box container widget created via createBox.
    widget  The child widget object to add.
    expand  Specifies whether to expand the widget. When arranging in the ui::kOrientationVertical direction, it expands the height. When arranging in the ui::kOrientationHorizontal direction, it expands the width. If the expand property of multiple child widgets is true, those child widgets expand proportionally to their sizes.
    fill  Specifies whether to fill the widget in the expanded height or width. When arranging in the ui::kOrientationVertical direction, it fills the height. When arranging in the ui::kOrientationHorizontal direction, it fills the width. If fill is false, it is arranged to match the align property value of the widget. Applied only when expand is true.
    padding  The spacing with the widget added just before, measured in pixels. The total space size between widget and widget equals the sum of box spacing and this padding value. The padding of the widget itself is applied inside the widget.
    void boxPackEnd ( const BoxRef & box , const WidgetRef & widget , bool expand , bool fill , int32_t padding )
    OasisUI.h
    Adds a child widget to the box container widget based on the ending position of the box. If there are widgets already added via boxPackEnd, it is appended immediately before them.
    Parameters
    box  The box container widget created via createBox.
    widget  The child widget object to add.
    expand  Specifies whether to expand the widget. When arranging in the ui::kOrientationVertical direction, it expands the height. When arranging in the ui::kOrientationHorizontal direction, it expands the width. If the expand property of multiple child widgets is true, those child widgets expand proportionally to their sizes.
    fill  Specifies whether to fill the widget in the expanded height or width. When arranging in the ui::kOrientationVertical direction, it fills the height. When arranging in the ui::kOrientationHorizontal direction, it fills the width. If fill is false, it is arranged to match the align property value of the widget. Applied only when expand is true.
    padding  The spacing with the widget added just before, measured in pixels. The total space size between widget and widget equals the sum of box spacing and this padding value. The padding of the widget itself is applied inside the widget.

    Fixed Container#

    The fixed container widget places child widgets at fixed positions.

    FixedRef createFixed ( )
    OasisUI.h
    Creates a fixed container widget.
    Return Value
    Returns the fixed container widget.
    void fixedPut ( const FixedRef & fixed , const WidgetRef & widget , int32_t x , int32_t y )
    OasisUI.h
    Adds a child widget to the fixed container widget at the given (x, y).
    Parameters
    fixed  The fixed container widget created via createFixed.
    widget  The child widget object to add.
    x  The x coordinate of the child widget.
    y  The y coordinate of the child widget.
    void fixedRemove ( const FixedRef & fixed , const WidgetRef & widget )
    OasisUI.h
    Parameters
    fixed  The fixed container widget created via createFixed.
    widget  The child widget object to remove.

    Grid Container#

    The grid container widget arranges child widgets based on rows and columns.

    GridRef createGrid ( )
    OasisUI.h
    Creates a grid container widget.
    Return Value
    Returns the grid container widget.
    void gridSetRowHomogeneous ( const GridRef & grid , bool homogeneous )
    OasisUI.h
    Arranges rows so that their heights are equal.
    Parameters
    grid  The grid container widget created via createGrid.
    homogeneous  Arranges child widgets by setting grid rows to the same size.
    void gridSetColumnHomogeneous ( const GridRef & grid , bool homogeneous )
    OasisUI.h
    Arranges columns so that their widths are equal.
    Parameters
    grid  The grid container widget created via createGrid.
    homogeneous  Arranges child widgets by setting grid columns to the same size.
    void gridSetRowSpacing ( const GridRef & grid , int32_t spacing )
    OasisUI.h
    Configures spacing between rows.
    Parameters
    grid  The grid container widget created via createGrid.
    spacing  Specifies the spacing between rows, measured in pixels.
    void gridSetColumnSpacing ( const GridRef & grid , int32_t spacing )
    OasisUI.h
    Configures spacing between columns.
    Parameters
    grid  The grid container widget created via createGrid.
    spacing  Specifies the spacing between columns, measured in pixels.
    void gridSetColumnFixedWidth ( const GridRef & grid , int32_t col , int32_t width )
    OasisUI.h
    Configures column width to a fixed width.
    Parameters
    grid  The grid container widget created via createGrid.
    col  The column index, starting from 0.
    width  The fixed width, measured in pixels.
    void gridSetRowFixedHeight ( const GridRef & grid , int32_t row , int32_t height )
    OasisUI.h
    Configures row height to a fixed height.
    Parameters
    grid  The grid container widget created via createGrid.
    row  The row index, starting from 0.
    height  The fixed height, measured in pixels.
    void gridAttach ( const GridRef & grid , const WidgetRef & widget , int32_t left , int32_t top , int32_t width , int32_t height )
    OasisUI.h
    Adds a child widget to the grid container widget.
    Parameters
    grid  The grid container widget created via createGrid.
    widget  The child widget object to add.
    left  The starting column index of the grid where the child widget will be located.
    top  The starting row index of the grid where the child widget will be located.
    width  The number of grid columns occupied by the child widget.
    height  The number of grid rows occupied by the child widget.

    Single Container#

    Created via createWindow, createDialog, createButton, etc.

    ListBox Container#

    The listBox container widget arranges child widgets as a scrollable container.

    ListBoxRef createListBox ( const ListBoxType type )
    OasisUI.h
    Creates a listBox container widget.
    Parameters
    type  Specifies the listBox type. Specify either ui::kListBoxFixedItemSize or ui::kListBoxDynamicItemSize.
    Return Value
    Returns the listBox container widget.
    void listBoxInsert ( const ListBoxRef & listbox , const WidgetRef & widget , int32_t position )
    OasisUI.h
    Adds a child widget to the listBox container widget at the specified position.
    Parameters
    listbox  The listBox container widget object created via createListBox.
    widget  The child widget object to add.
    position  Specifies the position of the child to add. If the position value is -1 or greater than the current number of child widgets in the listBox, it is appended to the end. If the position value is 0, it is prepended to the front.
    void listBoxRemove ( const ListBoxRef & listbox , const WidgetRef & widget )
    OasisUI.h
    Removes a child widget from the listBox container widget.
    Parameters
    listbox  The listBox container widget object created via createListBox.
    widget  The child widget object to remove.
    void listBoxRemoveAll ( const ListBoxRef & listbox )
    OasisUI.h
    Removes all child widgets from the listBox container widget.
    Parameters
    listbox  The listBox container widget object created via createListBox.
    void listBoxSetPlaceHolder ( const ListBoxRef & listbox , const WidgetRef & placeholder )
    OasisUI.h
    Adds a child widget visible when the listBox container widget is empty. This widget is not a child widget actually included in the listBox. It is not visible if there is one or more child widgets.
    Parameters
    listbox  The listBox container widget object created via createListBox.
    placeholder  The widget object to be displayed in an empty ListBox.
    void listBoxGoUp ( const ListBoxRef & listbox )
    OasisUI.h
    Scrolls up.
    Parameters
    listbox  The listBox container widget object created via createListBox.
    void listBoxGoDown ( const ListBoxRef & listbox )
    OasisUI.h
    Scrolls down.
    Parameters
    listbox  The listBox container widget object created via createListBox.
    void listBoxGoPageUp ( const ListBoxRef & listbox )
    OasisUI.h
    Pages up.
    Parameters
    listbox  The listBox container widget object created via createListBox.
    void listBoxGoPageDown ( const ListBoxRef & listbox )
    OasisUI.h
    Pages down.
    Parameters
    listbox  The listBox container widget object created via createListBox.

    Window#

    WindowRef createWindow ( const char * title )
    OasisUI.h
    Creates a top-level window object. The parent class of the window object is SingleLayout. The window object is created in an invisible state. Call showWindow or similar to make it visible on screen.
    Parameters
    title  The title of the window. Specifying nullptr does not create the window title bar.
    Return Value
    Returns the window object on success, and returns nullptr on failure.
    void destroyWindow ( const WindowRef & window )
    OasisUI.h
    Releases the window object.
    Parameters
    window  The window object created via createWindow.
    void showWindowTitle ( const WindowRef & window , bool show )
    OasisUI.h
    Specifies whether to display the title bar on the window.
    Parameters
    window  The window object created via createWindow.
    show  The title bar is visible if true, and the title bar is invisible if false.
    WindowRef findWindowById ( const char * id )
    OasisUI.h
    Finds the window object corresponding to the iD.
    Parameters
    id  The ID of the window object. Differs from the title value.
    Return Value
    Returns the window object if found, and returns nullptr if not found.
    int32_t setTopmostWindow ( const WindowRef & window )
    OasisUI.h
    Specifies as the topmost window. The topmost window exists above all windows and is not obscured by other windows.
    Parameters
    window  The window object created via createWindow.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t waitForWindowDestroyed ( const WindowRef & window )
    OasisUI.h
    Waits until the specified window object is released. Other UI events are processed by creating an independent RunLoop.
    Parameters
    window  The window object created via createWindow.
    Return Value
    • 0: Success
    • -1: Failure

    Dialog#

    DialogRef createDialog ( const WindowRef & parent_window , const char * title = nullptr )
    OasisUI.h
    Creates a dialog widget.
    Parameters
    parent_window  The parent window widget of the dialog object.
    title  Specifies the title of the dialog window. If nullptr, the title bar is not created.
    Return Value
    Returns the dialog widget object on success. Returns nullptr on failure.
    BoxRef getDialogContainerBox ( const DialogRef & dialog )
    OasisUI.h
    Returns the box container widget responsible for the overall layout of the dialog widget.
    Parameters
    dialog  The dialog object created via createDialog.
    Return Value
    The box container widget object.
    BoxRef getDialogContentArea ( const DialogRef & dialog )
    OasisUI.h
    Returns the box container widget responsible for the arrangement of the content area of the dialog widget.
    Parameters
    dialog  The dialog object created via createDialog.
    Return Value
    The box container widget object.
    ButtonRef addDialogButtonWithText ( const DialogRef & dialog , const char * button_text , int32_t response_id )
    OasisUI.h
    Adds a text button to the dialog widget.
    Parameters
    dialog  The dialog object created via createDialog.
    button_text  The text of the button.
    response_id  Specifies the iD value generated upon clicking or touching.
    Return Value
    Returns the created button widget on success. Returns nullptr on failure.
    ButtonRef addDialogButtonWithImage ( const DialogRef & dialog , const char * image_path , int32_t response_id )
    OasisUI.h
    Adds an image button to the dialog widget.
    Parameters
    dialog  The dialog object created via createDialog.
    image_path  The path to the image file of PNG or JPEG type.
    response_id  Specifies the iD value generated upon clicking or touching.
    Return Value
    Returns the created button widget on success. Returns nullptr on failure.
    int32_t addDialogButtonWithWidget ( const DialogRef & dialog , const WidgetRef & widget )
    OasisUI.h
    Adds a button to the dialog widget. The ID value of the button is used as the response value upon clicking or touching.
    Parameters
    dialog  The dialog object created via createDialog.
    widget  The button widget object.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setDialogAutoCloseTimeout ( const DialogRef & dialog , int32_t timeout_msecs , int32_t response_id )
    OasisUI.h
    Specifies the waiting time when letting the dialog widget close automatically.
    Parameters
    dialog  The dialog object created via createDialog.
    timeout_msecs  The waiting time in milliseconds.
    response_id  The response code value when closed automatically.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setDialogDefaultResponseId ( const DialogRef & dialog , int32_t response_id )
    OasisUI.h
    Configures the default response code value of the dialog widget.
    Parameters
    dialog  The dialog object created via createDialog.
    response_id  The default response code value.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t runDialog ( const DialogRef & dialog )
    OasisUI.h
    Displays the dialog widget on the screen. It waits until the dialog terminates.
    Parameters
    dialog  The dialog object created via createDialog.
    Return Value
    The response code value of the dialog widget. Returns -1 on failure.
    void responseDialog ( const DialogRef & dialog , int32_t response_id )
    OasisUI.h
    Returns the response code of the dialog widget and terminates.
    Parameters
    dialog  The dialog object created via createDialog.
    response_id  The response code value.
    void destroyDialog ( const DialogRef & dialog )
    OasisUI.h
    Releases the dialog widget.
    Parameters
    dialog  The dialog object created via createDialog.

    Button#

    ButtonRef createButtonWithImage ( const char * image_path )
    OasisUI.h
    Creates an image button widget.
    Parameters
    image_path  The path to the image file of PNG or JPEG type.
    Return Value
    Returns the button widget object on success. Returns nullptr on failure.
    ButtonRef createButtonWithLabel ( const char * label , bool single_line = true )
    OasisUI.h
    Creates a text button widget.
    Parameters
    label  The text.
    single_line  Displayed on a single line if true. Displayed on multiple lines if false.
    Return Value
    Returns the button widget object on success. Returns nullptr on failure.
    ButtonRef createButtonWithLabelAndImage ( const char * label , const char * image_path , int32_t orientation = kOrientationVertical , bool single_line = true )
    OasisUI.h
    Creates a button widget object having an image and text.
    Parameters
    label  The text.
    image_path  The path to the image file of PNG or JPEG type.
    orientation  Specifies the image and text arrangement method. Specify either kOrientationVertical or kOrientationHorizontal. If kOrientationVertical, the image and text are arranged vertically; if kOrientationHorizontal, the image and text are arranged horizontally.
    single_line  The text is displayed on a single line if true. The text is displayed on multiple lines if false.
    Return Value
    Returns the button widget object on success. Returns nullptr on failure.
    LabelRef getButtonLabel ( const ButtonRef & button )
    OasisUI.h
    Obtains the label widget object of the button widget.
    Parameters
    button  The button widget object.
    Return Value
    Returns the label widget object.
    ImageRef getButtonImage ( const ButtonRef & button )
    OasisUI.h
    Obtains the image widget object of the button widget.
    Parameters
    button  The button widget object.
    Return Value
    The image widget object.
    int32_t setButtonText ( const ButtonRef & button , const char * text )
    OasisUI.h
    Changes the text of the button widget. Creates the label widget if it does not exist.
    Parameters
    button  The button widget object.
    text  The text.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setButtonTextColor ( const ButtonRef & button , Color clr )
    OasisUI.h
    Specifies the text color.
    Parameters
    button  The button widget object.
    clr  The text color.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setButtonImage ( const ButtonRef & button , const char * image_path )
    OasisUI.h
    Sets the image of the button. Creates the image widget if it does not exist.
    Parameters
    button  The button widget object.
    image_path  The path to the image file of PNG or JPEG type.
    Return Value
    • 0: Success
    • -1: Failure

    Image#

    ImageRef createImageFromPath ( const char * image_path )
    OasisUI.h
    Creates an Image widget from a pNG file.
    Parameters
    image_path  The path to the image file of PNG or JPEG type.
    Return Value
    Returns the image widget object on success. Returns nullptr on failure.
    ImageRef createImageFromPathWithFormat ( const char * image_path , int32_t format )
    OasisUI.h
    Creates an Image widget object applying a specific image format.
    Parameters
    image_path  The path to the image file of PNG or JPEG type.
    format  Specifies the specific image format to use. Specifying a value of -1 assigns the OASIS_PIXEL_FORMAT_BGRA_8888 format. Refer to the oasisTypes.h header file for pixel formats.
    Return Value
    Returns the image widget object on success. Returns nullptr on failure.

    The pixel formats supported for PNG image files are as follows:

    • OASIS_PIXEL_FORMAT_BGRA_8888
    • OASIS_PIXEL_FORMAT_BGRX_8888
    • OASIS_PIXEL_FORMAT_ABGR_8888
    • OASIS_PIXEL_FORMAT_XBGR_8888
    • OASIS_PIXEL_FORMAT_ARGB_8888
    • OASIS_PIXEL_FORMAT_XRGB_8888

    The pixel formats supported for JPEG image files are as follows:

    • OASIS_PIXEL_FORMAT_BGRA_8888
    • OASIS_PIXEL_FORMAT_RGBA_8888
    • OASIS_PIXEL_FORMAT_ARGB_8888
    • OASIS_PIXEL_FORMAT_ABGR_8888
    • OASIS_PIXEL_FORMAT_XRGB_8888
    • OASIS_PIXEL_FORMAT_XBGR_8888
    • OASIS_PIXEL_FORMAT_RGBX_8888
    • OASIS_PIXEL_FORMAT_BGRX_8888
    • OASIS_PIXEL_FORMAT_RGB_888
    • OASIS_PIXEL_FORMAT_BGR_888
    ImageRef createImageFromPathWithPaddigns ( const char * image_path , int32_t paddings )
    OasisUI.h
    Creates an Image widget object applying paddings.
    Parameters
    image_path  The path to the image file of PNG or JPEG type.
    paddings  Specifies top, bottom, left, and right padding, measured in pixels.
    Return Value
    Returns the image widget object on success. Returns nullptr on failure.
    ImageRef createImageFromPathWithFormatAndPaddings ( const char * image_path , int32_t format , int32_t paddings )
    OasisUI.h
    Creates an Image widget object applying a specific image format and paddings.
    Parameters
    image_path  The path to the image file of PNG or JPEG type.
    format  Specifies the specific image format to use. Specifying a value of -1 assigns the OASIS_PIXEL_FORMAT_BGRA_8888 format. Refer to the oasisTypes.h header file for pixel formats.
    paddings  Specifies top, bottom, left, and right padding, measured in pixels.
    Return Value
    Returns the image widget object on success. Returns nullptr on failure.
    ImageRef createImageFromRefImage ( const ImageRef & ref_image , int32_t crop_x , int32_t crop_y , int32_t crop_width , int32_t crop_height )
    OasisUI.h
    Creates a new Image widget object by selecting a specific region of another Image widget.
    Parameters
    ref_image  The reference target Image widget object.
    crop_x  The top-left x coordinate of the cROP region.
    crop_y  The top-left y coordinate of the cROP region.
    crop_width  The width of the cROP region.
    crop_height  The height of the cROP region.
    Return Value
    Returns the image widget object on success. Returns nullptr on failure.
    int32_t setImagePath ( const ImageRef & image , const char * image_path )
    OasisUI.h
    Updates with a new image.
    Parameters
    image  The image widget object.
    image_path  The path to the image file of PNG or JPEG type.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setImageRefImage ( const ImageRef & image , const ImageRef & ref_image , int32_t crop_x , int32_t crop_y , int32_t crop_width , int32_t crop_height )
    OasisUI.h
    Copies the image of a new CROP region from a reference Image widget.
    Parameters
    image  The image widget object.
    ref_image  The reference Image widget object.
    crop_x  The top-left x coordinate of the cROP region.
    crop_y  The top-left y coordinate of the cROP region.
    crop_width  The width of the cROP region.
    crop_height  The height of the cROP region.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setImageColorKey ( const ImageRef & image , Color color_key )
    OasisUI.h
    Configures the color key.
    Parameters
    image  The image widget object.
    color_key  The color key value. All parts matching this color are processed as transparent.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t disableImageAlphaChannel ( const ImageRef & image )
    OasisUI.h
    Deactivates the alpha channel.
    Parameters
    image  The image widget object.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t imageWidth ( const ImageRef & image )
    OasisUI.h
    Obtains the image width.
    Parameters
    image  The image widget object.
    Return Value
    Returns the image width, measured in pixels.
    int32_t imageHeight ( const ImageRef & image )
    OasisUI.h
    Obtains the image height.
    Parameters
    image  The image widget object.
    Return Value
    Returns the image height, measured in pixels.
    int32_t imageSize ( const ImageRef & image , Size & size )
    OasisUI.h
    Obtains the image size.
    Parameters
    image  The image widget object.
    size  OUT Returns the image size.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t rotateImage ( const ImageRef & image , Rect * src_rect , Rect * dst_rect , double angle , Point * center )
    OasisUI.h
    Rotates the image by the specified angle.
    Parameters
    image  The image widget object.
    src_rect  The target region to rotate.
    dst_rect  The destination region to which rotation is applied.
    angle  The angle to rotate.
    center  The center coordinates of the rotation axis.
    Return Value
    • 0: Success
    • -1: Failure

    Label#

    LabelRef createLabelWithText ( const char * label )
    OasisUI.h
    Creates a label widget.
    Parameters
    label  The label text.
    Return Value
    Returns the label widget object on success. Returns nullptr on failure.
    int32_t setLabelText ( const LabelRef & label , const char * text )
    OasisUI.h
    Changes the label text.
    Parameters
    label  The label widget object.
    text  The label text to change.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setLabelHorzJustification ( const LabelRef & label , Justification Justification )
    OasisUI.h
    Specifies the label horizontal alignment method.
    Parameters
    label  The label widget object.
    Justification  Enter one of the Justification values.
    Return Value
    • 0: Success
    • -1: Failure

    The horizontal Justification values are as follows:

    Justification Value Description
    kJustificationLeft 0 Aligns to the left.
    kJustificationRight 1 Aligns to the right.
    kJustificationCenter 2 Aligns to the center.
    kJustificationFill 3 Aligns equally.
    int32_t setLabelVertJustification ( const LabelRef & label , Justification Justification )
    OasisUI.h
    Specifies the label vertical alignment method.
    Parameters
    label  The label widget object.
    Justification  Enter one of the Justification values.
    Return Value
    • 0: Success
    • -1: Failure

    The vertical Justification values are as follows:

    Justification Value Description
    kJustificationTop 0 Aligns to the top.
    kJustificationBottom 1 Aligns to the bottom.
    kJustificationVCenter 2 Aligns to the vertical center.
    kJustificationFill 3 Aligns equally.
    int32_t enableLabelWordWrap ( const LabelRef & label , bool enable = true )
    OasisUI.h
    Specifies whether to automatically wrap lines by character unit.
    Parameters
    label  The label widget object.
    enable  Wraps lines automatically by character unit if true.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t disableLabelMultiline ( const LabelRef & label , bool disable = true )
    OasisUI.h
    Specifies whether to support multiple lines.
    Parameters
    label  The label widget object.
    disable  Renders as a single line instead of multiple lines if true.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setLabelTextColor ( const LabelRef & label , Color clr )
    OasisUI.h
    Specifies the label text color.
    Parameters
    label  The label widget object.
    clr  The label text color.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setLabelFont ( const LabelRef & label , int32_t point_size , const char * font_path )
    OasisUI.h
    Changes the label text font and point size.
    Parameters
    label  The label widget object.
    point_size  The label font size, measured in points.
    font_path  The label font file path.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t setLabelFontPointSize ( const LabelRef & label , int32_t point_size )
    OasisUI.h
    Sets the label font size.
    Parameters
    label  The label widget object.
    point_size  The point size of the label text.
    Return Value
    • 0: Success
    • -1: Failure
    void setLabelAlphaMode ( const LabelRef & label , bool enable )
    OasisUI.h
    Specifies whether to apply alpha mode when rendering the label.
    Parameters
    label  The label widget object.
    enable  Alpha mode is applied to render with anti-aliasing if true.

    Graphic Context#

    Oasis performs operations to draw on the screen using the graphicContext object.

    If hardware acceleration is supported, it uses hardware acceleration.

    Drawing can be performed via the drawingArea widget.

    GraphicContextRef getGraphicContext ( const WidgetRef & widget )
    OasisUI.h
    Obtains the graphicContext object from a widget object.
    Parameters
    widget  The widget object.
    Return Value
    Returns the graphicContext object on success. Returns nullptr on failure.
    int32_t beginDrawing ( const GraphicContextRef & graphic_context )
    OasisUI.h
    Starts drawing.
    Parameters
    graphic_context  The graphicContext object.
    Return Value
    • 0: Success
    • -1: Failure
    int32_t endDrawing ( const GraphicContextRef & graphic_context )
    OasisUI.h
    Ends drawing. Reflects the contents drawn during that time to the display.
    Parameters
    graphic_context  The graphicContext object.
    Return Value
    • 0: Success
    • -1: Failure
    void saveGraphicContext ( const GraphicContextRef & graphic_context )
    OasisUI.h
    Saves the current GraphicContext properties to the stack.
    Parameters
    graphic_context  The graphicContext object.
    void restoreGraphicContext ( const GraphicContextRef & graphic_context )
    OasisUI.h
    Restores the immediately previously saved GraphicContext from the stack.
    Parameters
    graphic_context  The graphicContext object.
    void drawLine ( const GraphicContextRef & graphic_context , int32_t x0 , int32_t y0 , int32_t x1 , int32_t y1 , Color clr )
    OasisUI.h
    Draws a line.
    Parameters
    graphic_context  The graphicContext object.
    x0  The starting x coordinate of the line.
    y0  The starting y coordinate of the line.
    x1  The ending x coordinate of the line.
    y1  The ending y coordinate of the line.
    clr  The line color.
    void drawVline ( const GraphicContextRef & graphic_context , int32_t x , int32_t top , int32_t bottom , Color clr )
    OasisUI.h
    Draws a vertical line.
    Parameters
    graphic_context  The graphicContext object.
    x  The x coordinate of the vertical line.
    top  The starting y coordinate of the vertical line.
    bottom  The ending y coordinate of the vertical line.
    clr  The line color.
    void drawHline ( const GraphicContextRef & graphic_context , int32_t y , int32_t left , int32_t right , Color clr )
    OasisUI.h
    Draws a horizontal line.
    Parameters
    graphic_context  The graphicContext object.
    y  The y coordinate of the horizontal line.
    left  The starting x coordinate of the horizontal line.
    right  The ending x coordinate of the horizontal line.
    clr  The line color.
    void drawRectangle ( const GraphicContextRef & graphic_context , int32_t left , int32_t top , int32_t right , int32_t bottom , Color clr )
    OasisUI.h
    Draws a rectangle.
    Parameters
    graphic_context  The graphicContext object.
    left  The top-left x coordinate of the rectangle.
    top  The top-left y coordinate of the rectangle.
    right  The bottom-right x coordinate of the rectangle.
    bottom  The bottom-right y coordinate of the rectangle.
    clr  The border color.
    void fillRectangle ( const GraphicContextRef & graphic_context , int32_t left , int32_t top , int32_t right , int32_t bottom , Color clr )
    OasisUI.h
    Fills a rectangle.
    Parameters
    graphic_context  The graphicContext object.
    left  The top-left x coordinate of the rectangle.
    top  The top-left y coordinate of the rectangle.
    right  The bottom-right x coordinate of the rectangle.
    bottom  The bottom-right y coordinate of the rectangle.
    clr  The color to fill.
    int32_t setFont ( const GraphicContextRef & graphic_context , int32_t point_size , const char * font_path = nullptr )
    OasisUI.h
    Changes font and font size.
    Parameters
    graphic_context  The graphicContext object.
    point_size  The font size, measured in points.
    font_path  The path to the font file.
    Return Value
    • 0: Success
    • -1: Failure
    void setTextForeColor ( const GraphicContextRef & graphic_context , uint32_t argb )
    OasisUI.h
    Specifies the character foreground color.
    Parameters
    graphic_context  The graphicContext object.
    argb  The character color.
    void setTextBgColor ( const GraphicContextRef & graphic_context , uint32_t argb )
    OasisUI.h
    Specifies the character background color.
    Parameters
    graphic_context  The graphicContext object.
    argb  The character background color.
    void setTextBkMode ( const GraphicContextRef & graphic_context , text_bk_mode_t bk_mode )
    OasisUI.h
    Specifies the character background color processing method.
    Parameters
    graphic_context  The graphicContext object.
    bk_mode  Specifying kTextBkModeTransparent processes the character background as transparent. Specifying kTextBkModeOpaque applies the character background color.
    int32_t drawText ( const GraphicContextRef & graphic_context , std::vector<int32_t> & string , int32_t left , int32_t top , int32_t width , int32_t height , uint32_t flags = DT_LEFT|DT_TOP , int32_t caret_index = -1 , Point * caret_pos = nullptr )
    OasisUI.h
    Draws text.
    Parameters
    graphic_context  The graphicContext object.
    string  The 32-bit UNICODE string vector.
    left  The top-left x coordinate of the region where the string will be drawn.
    top  The top-left y coordinate of the region where the string will be drawn.
    width  The width of the region where the string will be drawn.
    height  The height of the region where the string will be drawn.
    flags  The flag value to be referenced when drawing strings.
    caret_index  The cursor shape to use. Not used
    caret_pos  The cursor position. Not used
    Return Value
    • 0: Success
    • -1: Failure

    The flags value of drawText performs OR'ing of the following values:

    flag
    Value
    Meaning
    DT_TOP 0x00000000 Aligns the vertical reference of the text to the top.
    DT_LEFT 0x00000000 Aligns the text to the left.
    DT_CENTER 0x00000001 Aligns the text to the center.
    DT_RIGHT 0x00000002 Aligns the text to the right.
    DT_VCENTER 0x00000004 Aligns the vertical reference of the text to the center.
    DT_BOTTOM 0x00000008 Aligns the vertical reference of the text to the bottom.
    DT_WORDBREAK 0x00000010 Allows line breaking by word unit.
    DT_SINGLELINE 0x00000020 Processes as a single line.
    DT_CALCRECT 0x00000400 Calculates the region where the string will be drawn. It does not actually draw.
    DT_NOPREFIX 0x00000800 Does not process the prefix symbol (&) in the string. If it is \"&abc\", it is drawn as \"abc\".
    DT_NOFULLWIDTHCHARBREAK 0x00080010 If a single character exceeds the allowed width, it processes that character without line breaking.
    int32_t drawText ( const GraphicContextRef & graphic_context , std::string & string , int32_t left , int32_t top , int32_t width , int32_t height , uint32_t flags = DT_LEFT|DT_TOP , int32_t caret_index = -1 , Point * caret_pos = nullptr )
    OasisUI.h
    Parameters
    graphic_context  The graphicContext object.
    string  The string.
    left  The top-left x coordinate of the region where the string will be drawn.
    top  The top-left y coordinate of the region where the string will be drawn.
    width  The width of the region where the string will be drawn.
    height  The height of the region where the string will be drawn.
    flags  The flag value to be referenced when drawing strings.
    caret_index  The cursor shape to use. Not used
    caret_pos  The cursor position. Not used
    Return Value
    • 0: Success
    • -1: Failure
    void setWidgetBgColor ( const GraphicContextRef & graphic_context , Color clr )
    OasisUI.h
    Specifies the background color of the widget. It is applied only when drawing, and overwrites the background color of the original widget.
    Parameters
    graphic_context  The graphicContext object.
    clr  The background color.

    Drawing Area#

    DrawingAreaRef createDrawingArea ( std::function<void(WidgetRef, GraphicContextRef)> handler )
    OasisUI.h
    Creates a drawingArea widget.
    Parameters
    handler  The drawing callback function.
    Return Value
    Returns the drawingArea widget on success. Returns nullptr on failure.

    Below is an example of creating and drawing a drawingArea:

    int32_t App::create()
    {
        // Creates a drawingArea object.
        canvas_ = ui::createDrawingArea(std::bind(&App::draw, this, std::placeholders::_1, std::placeholders::_2));
        ui::setID(canvas_, "my_drawingarea");
        ui::gridAttach(grid, canvas_, 0, 0, 1, 1);  
    }
    
    void App::draw(ui::WidgetRef widget, GraphicContextRef gc) 
    {
        // Paints the entirety in black.
        Color clr_bk(255, 0, 0, 0);
        ui::fillRectangle(gc, 0, 0, width_, height_, clr_bk);
    
        // Draws a yellow box.
        Color clr_line(255, 255, 255, 0);
        ui::drawRectangle(gc, 10, 10, 100, 100, clr_line);
    
        // Draws a string.
        std::string text = "μ•ˆλ…•ν•˜μ„Έμš”!";
        ui::setFont(gc, 11);
        ui::setTextForeColor(gc, Color(255, COLOR_WHITE)());
        ui::drawText(gc, str, 20, 20, 80, 80, DT_CENTER|DT_VCENTER);
    }
    

    Keypad#

    KeypadRef createKeypad ( const WidgetRef & parent_window , const char * keypad_title , const char * init_value = "" , const char * cancel_label = "" , const char * ok_label = "" )
    OasisUI.h
    Creates a keypad.
    Parameters
    parent_window  The parent window object.
    keypad_title  The keypad title.
    init_value  The initial value of the keypad string.
    cancel_label  The label of the cancel button.
    ok_label  The label of the oK button.
    Return Value
    Returns a keypad object on success. Returns nullptr on failure.
    void destroyKeypad ( const KeypadRef & keypad )
    OasisUI.h
    Releases the keypad object.
    Parameters
    keypad  The keypad object.
    const char * showKeypad ( const KeypadRef & keypad )
    OasisUI.h
    Displays the keypad and waits until the user presses the oK or cancel button.
    Parameters
    keypad  The keypad object.
    Return Value
    Returns the modified string. If cancel is pressed, the original string is returned without modification.

    Below is an example utilizing the keyboard:

    void cancel_handler(int sig)
    {
        ui::quitAllRunContexts();
        got_interrupt = true;
    }
    
    int main(int argc, char *argv[])
    {
        int32_t err;
    
        signal(SIGINT, cancel_handler);
    
        oasis::key_value_map_t parameters;
    
        parameters["offs-disable"] = "1";
        if(oasis::initialize(parameters) < 0) {
            DLOG(DLOG_ERROR, "Oasis init failed\n");
            return -1;
        }
    
        ////////////////////////////////////////////////////////////////////////////////////////////
        // display setup
        parameters.clear();
    
        parameters["memory-type"] = "ion"; //cma
        parameters["screen-width"] = "480";
        parameters["screen-height"] = "320";
    
        display::setup(parameters);
    
        //////////////////////////////////////////////////////////////////////////////////////////
        // ui setup
        parameters.clear();
    
        parameters["system-font-size"] = "11";
        parameters["system-font-path"] = "/mnt/sd/NanumGothicCoding.ttf";
        parameters["display-rotation"] = "0";
        parameters["enable-touch"] = "1";
        parameters["touch-cal-data-path"] = "/mnt/sd/cal.dat";
    
        err = ui::setup(parameters);
        if (err < 0) {
            DLOG(DLOG_ERROR, "Oasis ui::setup failed\n");
            return -1;
        }
    
        //////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////
    
        ui::ScreenRef screen = ui::getDefaultScreen();
    
        int32_t screen_width = ui::screenWidth(screen);
        int32_t screen_height = ui::screenHeight(screen);
    
        ui::DialogRef dialog = ui::createDialog(nullptr);
        ui::setBgColor(dialog, Color(255, COLOR_BLACK));
        ui::setBorderSize(dialog, 0, false);
    
        ui::BoxRef dialog_container = ui::getDialogContainerBox(dialog);
        ui::setHAlign(dialog_container, ui::kAlignFill);
        ui::setVAlign(dialog_container, ui::kAlignFill);
        ui::setMargin(dialog_container, 0);
    
        ui::BoxRef content_area = ui::getDialogContentArea(dialog); //horz box layout
    
        ui::KeypadRef keypad = ui::createKeypad(dialog, "μ•”ν˜Έ μž…λ ₯", "1122334455", "μ·¨μ†Œ", "확인");
    
        ui::screenAdd(screen, dialog);
    
        std::string str = ui::showKeypad(keypad);
    
        err = ui::runDialog(dialog);
    
        ui::destroyDialog(dialog);
    
        err = ui::cleanup();
    
        oasis::finalize();
    
        return 0;
    }
    

    This is the keypad screen displayed in the application example:

    Keypad

    Timer#

    int32_t timeoutAdd ( const char * timeout_name , int64_t intervalUs , const source_slot_t & slot )
    OasisUI.h
    Creates a timer.
    Parameters
    timeout_name  The name of the timer.
    intervalUs  Specifies the occurrence cycle of the timer event, measured in microseconds.
    slot  Registers the timer event handler.
    Return Value
    Returns the timer ID on success. Returns -1 on failure.

    source_slot_t is defined as follows:

    typedef sig::slot<bool(void)> source_slot_t
    OasisTypes.h
    The user-defined timer callback function.
    Return Value
    • true: Maintains timer operation.
    • false: Stops and removes the timer automatically.
    int32_t timeoutEnable ( int32_t timeout_id , bool enable )
    OasisUI.h
    Activates the timer.
    Parameters
    timeout_id  The timer ID value.
    enable  Activates the timer if true, and stops the timer if false.
    Return Value
    • 0: Success
    • -1: Failure
    bool isTimeoutRunning ( int32_t timeout_id )
    OasisUI.h
    Verifies whether the timer is currently operating.
    Parameters
    timeout_id  The timer ID.
    Return Value
    • true: The timer is operating.
    • false: The timer is stopped.
    int32_t timeoutRemove ( int32_t timeout_id )
    OasisUI.h
    Removes the timer.
    Parameters
    timeout_id  The timer ID.
    Return Value
    • 0: Success
    • -1: Failure

    Below is an example triggering a timer at 1-second intervals:

    // Creates a timer.
    timer_id_ = ui::timeoutAdd("tick_timer", 1000000, sig::mem_fn(*this, &App::tickTimer));
    if(timer_id_ > 0) {
      // Starts the timer.
      ui::timeoutEnable(timer_id_, true);
    }
    
    bool App::tickTimer()
    {
      // Perform timer task.
    
      // Return false to release the timer.
      //return false;
      return true;
    }
    

    Signaling#

    Oasis GUI event generation and processing utilizes the signal-slot mechanism.

    uint32_t connectSignal ( const ObjectRef & object , const char * signal_name , const sig::slot_base& slot , uint32_t flags )
    OasisUI.h
    Connects an event handler function to a target object.
    Parameters
    object  The object that triggers the event, acting as the target object for signal connection.
    signal_name  The event signal name.
    slot  The event handler function.
    flags  The flag value. Configure 0.
    Return Value
    Returns the signal ID.
    int32_t disconnectSignal ( uint32_t signal_id )
    OasisUI.h
    Disconnects an event handler function connection. When the target widget is released, the signal processing connection is automatically disconnected.
    Parameters
    signal_id  The signal ID value to disconnect.
    Return Value
    • 0: Success
    • -1: Failure

    Oasis utilizes a signaling template for handling the following click and touch events:

    • clicked
    • touch-up-event
    • touch-down-event
    • touch-move-event

    The types for individual event handler functions are as follows:

    typedef sig::slot<void(ui::WidgetRef)> clicked_slot_t
    OasisTypes.h
    The user-defined click event callback function.
    Parameters
    ui::WidgetRef  The widget object where the click event occurred.
    typedef sig::slot<void(ui::ScreenRef, ui::TouchEvent*)> touch_down_event_slot_t
    OasisTypes.h
    The user-defined touch down event callback function.
    Parameters
    ui::ScreenRef  The screen object where the touch event occurred.
    ui::TouchEvent*  The touch event data.
    typedef sig::slot<void(ui::ScreenRef, ui::TouchEvent*)> touch_up_event_slot_t
    OasisTypes.h
    The user-defined touch up event callback function.
    Parameters
    ui::ScreenRef  The screen object where the touch event occurred.
    ui::TouchEvent*  The touch event data.
    typedef sig::slot<void(ui::ScreenRef, ui::TouchEvent*)> touch_move_event_slot_t
    OasisTypes.h
    The user-defined touch move event callback function.
    Parameters
    ui::ScreenRef  The screen object where the touch event occurred.
    ui::TouchEvent*  The touch event data.
    struct TouchEvent
    Oasis.h
    Member Type & Name
    Description
    int32_t x
    The x coordinate of the device.
    int32_t y
    The y coordinate of the device.
    int32_t z
    The z coordinate of the device. Indicates the pressure value.
    int32_t screen_x
    The x coordinate on the screen.
    int32_t screen_y
    The y coordinate on the screen.
    bool is_down
    Possesses a value of true if pressed.
    int32_t repeat
    Indicates the repeat count. Used to distinguish double touch, triple touch, etc.
    uint64_t timestamp
    The timestamp at the time of occurrence, measured in microseconds.
    int32_t holding_msec
    The duration of maintaining the pressed state, measured in milliseconds.

    Below are Signal connection examples:

    // Connects the "clicked" signal handler
    uint32_t clicked_sigid = ui::connectSignal(apply_button, "clicked", clicked_slot_t(sig::mem_fn(*this, &App::applyButtonClicked)), 0);
    
    // Connects the "touch-down-event" signal handler
    uint32_t touch_down_event_sigid = ui::connectSignal(drawing_canvas, "touch-down-event", touch_down_event_slot_t(sig::mem_fn(*this, &App::touchedDown)), 0);
    
    // Connects the "touch-up-event" signal handler
    uint32_t touch_up_event_sigid = ui::connectSignal(drawing_canvas, "touch-up-event", touch_up_event_slot_t(sig::mem_fn(*this, &App::touchedUp)), 0);
    
    // Connects the "touch-move-event" signal handler
    uint32_t touch_move_event_sigid = ui::connectSignal(drawing_canvas, "touch-move-event", touch_move_event_slot_t(sig::mem_fn(*this, &App::touchedMove)), 0);
    

    Running Context#

    Oasis utilizes RunningLoop for event processing. RunningLoop contains RunContext.

    Used when attempting to forcibly terminate the application from a signal handler such as SIGINT.

    OasisUI.h
    Terminates all RunContexts.