Changeset b71c0fc in mainline for uspace/lib/ui/src/window.c


Ignore:
Timestamp:
2020-11-07T16:07:22Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d55ab823
Parents:
fa01c05
Message:

Make fixed layout a UI control and hook it up to the window

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/window.c

    rfa01c05 rb71c0fc  
    4242#include <mem.h>
    4343#include <stdlib.h>
     44#include <ui/control.h>
    4445#include <ui/resource.h>
    4546#include <ui/wdecor.h>
    4647#include <ui/window.h>
     48#include "../private/control.h"
    4749#include "../private/dummygc.h"
    4850#include "../private/resource.h"
     
    170172                return;
    171173
     174        ui_control_destroy(window->control);
    172175        ui_wdecor_destroy(window->wdecor);
    173176        ui_resource_destroy(window->res);
     
    177180}
    178181
     182/** Add control to window.
     183 *
     184 * Only one control can be added to a window. If more than one control
     185 * is added, the results are undefined.
     186 *
     187 * @param fixed Fixed layout
     188 * @param control Control
     189 * @return EOK on success, ENOMEM if out of memory
     190 */
     191void ui_window_add(ui_window_t *window, ui_control_t *control)
     192{
     193        assert(window->control == NULL);
     194
     195        window->control = control;
     196        control->elemp = (void *) window;
     197}
     198
     199/** Remove control from window.
     200 *
     201 * @param window Window
     202 * @param control Control
     203 */
     204void ui_window_remove(ui_window_t *window, ui_control_t *control)
     205{
     206        assert(window->control == control);
     207        assert((ui_window_t *) control->elemp == window);
     208
     209        window->control = NULL;
     210        control->elemp = NULL;
     211}
     212
    179213/** Set window callbacks.
    180214 *
     
    343377        if (window->cb != NULL && window->cb->pos != NULL)
    344378                window->cb->pos(window, window->arg, pos);
     379        else
     380                ui_window_def_pos(window, pos);
    345381}
    346382
     
    375411                return rc;
    376412
     413        if (window->control != NULL)
     414                return ui_control_paint(window->control);
     415
    377416        return EOK;
    378417}
    379418
     419/** Default window position event routine.
     420 *
     421 * @param window Window
     422 * @return EOK on success or an error code
     423 */
     424void ui_window_def_pos(ui_window_t *window, pos_event_t *pos)
     425{
     426        if (window->control != NULL)
     427                ui_control_pos_event(window->control, pos);
     428}
     429
    380430/** @}
    381431 */
Note: See TracChangeset for help on using the changeset viewer.