2021-10-03 13:36:05 +03:00
|
|
|
/**
|
|
|
|
* @file view_port.h
|
|
|
|
* GUI: ViewPort API
|
|
|
|
*/
|
|
|
|
|
2021-01-29 16:52:16 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <input/input.h>
|
|
|
|
#include "canvas.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct ViewPort ViewPort;
|
|
|
|
|
2021-05-19 12:43:15 +03:00
|
|
|
typedef enum {
|
|
|
|
ViewPortOrientationHorizontal,
|
2022-10-26 21:35:49 +03:00
|
|
|
ViewPortOrientationHorizontalFlip,
|
2021-05-19 12:43:15 +03:00
|
|
|
ViewPortOrientationVertical,
|
2022-10-26 21:35:49 +03:00
|
|
|
ViewPortOrientationVerticalFlip,
|
2022-11-02 17:36:17 +03:00
|
|
|
ViewPortOrientationMAX, /**< Special value, don't use it */
|
2021-05-19 12:43:15 +03:00
|
|
|
} ViewPortOrientation;
|
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** ViewPort Draw callback
|
2021-10-03 13:36:05 +03:00
|
|
|
* @warning called from GUI thread
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
typedef void (*ViewPortDrawCallback)(Canvas* canvas, void* context);
|
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** ViewPort Input callback
|
2021-10-03 13:36:05 +03:00
|
|
|
* @warning called from GUI thread
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
typedef void (*ViewPortInputCallback)(InputEvent* event, void* context);
|
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** ViewPort allocator
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
2021-01-29 16:52:16 +03:00
|
|
|
* always returns view_port or stops system if not enough memory.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @return ViewPort instance
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
ViewPort* view_port_alloc();
|
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** ViewPort deallocator
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
2021-01-29 16:52:16 +03:00
|
|
|
* Ensure that view_port was unregistered in GUI system before use.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param view_port ViewPort instance
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
void view_port_free(ViewPort* view_port);
|
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** Set view_port width.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
2021-01-29 16:52:16 +03:00
|
|
|
* Will be used to limit canvas drawing area and autolayout feature.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param view_port ViewPort instance
|
|
|
|
* @param width wanted width, 0 - auto.
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
void view_port_set_width(ViewPort* view_port, uint8_t width);
|
2023-02-09 07:58:01 +03:00
|
|
|
uint8_t view_port_get_width(const ViewPort* view_port);
|
2021-01-29 16:52:16 +03:00
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** Set view_port height.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
2021-01-29 16:52:16 +03:00
|
|
|
* Will be used to limit canvas drawing area and autolayout feature.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param view_port ViewPort instance
|
|
|
|
* @param height wanted height, 0 - auto.
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
void view_port_set_height(ViewPort* view_port, uint8_t height);
|
2023-02-09 07:58:01 +03:00
|
|
|
uint8_t view_port_get_height(const ViewPort* view_port);
|
2021-01-29 16:52:16 +03:00
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** Enable or disable view_port rendering.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param view_port ViewPort instance
|
|
|
|
* @param enabled Indicates if enabled
|
|
|
|
* @warning automatically dispatches update event
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
void view_port_enabled_set(ViewPort* view_port, bool enabled);
|
2023-02-09 07:58:01 +03:00
|
|
|
bool view_port_is_enabled(const ViewPort* view_port);
|
2021-01-29 16:52:16 +03:00
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** ViewPort event callbacks
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param view_port ViewPort instance
|
|
|
|
* @param callback appropriate callback function
|
|
|
|
* @param context context to pass to callback
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
void view_port_draw_callback_set(ViewPort* view_port, ViewPortDrawCallback callback, void* context);
|
|
|
|
void view_port_input_callback_set(
|
|
|
|
ViewPort* view_port,
|
|
|
|
ViewPortInputCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** Emit update signal to GUI system.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
2021-01-29 16:52:16 +03:00
|
|
|
* Rendering will happen later after GUI system process signal.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param view_port ViewPort instance
|
2021-01-29 16:52:16 +03:00
|
|
|
*/
|
|
|
|
void view_port_update(ViewPort* view_port);
|
|
|
|
|
2021-10-02 20:00:56 +03:00
|
|
|
/** Set ViewPort orientation.
|
2021-10-03 13:36:05 +03:00
|
|
|
*
|
|
|
|
* @param view_port ViewPort instance
|
|
|
|
* @param orientation display orientation, horizontal or vertical.
|
2021-05-19 12:43:15 +03:00
|
|
|
*/
|
|
|
|
void view_port_set_orientation(ViewPort* view_port, ViewPortOrientation orientation);
|
|
|
|
ViewPortOrientation view_port_get_orientation(const ViewPort* view_port);
|
|
|
|
|
2021-01-29 16:52:16 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|