wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions | Variables
menu_item.h File Reference
#include <libbase/libbase.h>
#include <cairo.h>
Include dependency graph for menu_item.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wlmaker_menu_item_descriptor_t
 

Macros

#define WLMAKER_MENU_ITEM_DESCRIPTOR_ENTRY(_label, _callback)
 
#define WLMAKER_MENU_ITEM_DESCRIPTOR_SENTINEL()
 

Typedefs

typedef struct _wlmaker_menu_item_t wlmaker_menu_item_t
 

Enumerations

enum  wlmaker_menu_item_type_t { WLMAKER_MENU_ITEM_SENTINEL = 0 , WLMAKER_MENU_ITEM_ENTRY , WLMAKER_MENU_ITEM_SEPARATOR }
 

Functions

wlmaker_menu_item_twlmaker_menu_item_create (const wlmaker_menu_item_descriptor_t *desc_ptr, void *callback_ud_ptr)
 
void wlmaker_menu_item_destroy (wlmaker_menu_item_t *menu_item_ptr)
 
void wlmaker_menu_item_get_desired_size (const wlmaker_menu_item_t *menu_item_ptr, uint32_t *width_ptr, uint32_t *height_ptr)
 
void wlmaker_menu_item_set_size (wlmaker_menu_item_t *menu_item_ptr, uint32_t width, uint32_t height)
 
void wlmaker_menu_item_set_position (wlmaker_menu_item_t *menu_item_ptr, uint32_t x, uint32_t y)
 
void wlmaker_menu_item_draw (wlmaker_menu_item_t *menu_item_ptr, cairo_t *cairo_ptr)
 
bs_dllist_node_t * wlmaker_dlnode_from_menu_item (wlmaker_menu_item_t *item_ptr)
 
wlmaker_menu_item_twlmaker_menu_item_from_dlnode (bs_dllist_node_t *dlnode_ptr)
 
void wlmaker_menu_item_set_focus (wlmaker_menu_item_t *menu_item_ptr, bool focussed)
 
bool wlmaker_menu_item_contains (const wlmaker_menu_item_t *menu_item_ptr, double x, double y)
 
bool wlmaker_menu_item_redraw_needed (const wlmaker_menu_item_t *menu_item_ptr)
 
void wlmaker_menu_item_execute (const wlmaker_menu_item_t *menu_item_ptr)
 

Variables

const bs_test_case_t wlmaker_menu_item_test_cases []
 

Detailed Description

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Macro Definition Documentation

◆ WLMAKER_MENU_ITEM_DESCRIPTOR_ENTRY

#define WLMAKER_MENU_ITEM_DESCRIPTOR_ENTRY ( _label,
_callback )
Value:
{ \
.type = WLMAKER_MENU_ITEM_ENTRY, \
.param = { .entry = { \
.label_ptr = _label, \
.callback = _callback \
} } \
}

Defines a menu entry descriptor.

◆ WLMAKER_MENU_ITEM_DESCRIPTOR_SENTINEL

#define WLMAKER_MENU_ITEM_DESCRIPTOR_SENTINEL ( )
Value:
{ \
.type = WLMAKER_MENU_ITEM_SENTINEL \
}

Defines a sentinel descriptor.

Typedef Documentation

◆ wlmaker_menu_item_t

Forward definition of the menu item handler.

Enumeration Type Documentation

◆ wlmaker_menu_item_type_t

Types of menu items.

Function Documentation

◆ wlmaker_dlnode_from_menu_item()

bs_dllist_node_t * wlmaker_dlnode_from_menu_item ( wlmaker_menu_item_t * item_ptr)

Cast: Returns the a pointer to the bs_dllist_node_t of |item_ptr|.

Parameters
item_ptr
Returns
The pointer.

◆ wlmaker_menu_item_contains()

bool wlmaker_menu_item_contains ( const wlmaker_menu_item_t * menu_item_ptr,
double x,
double y )

Returns whether the menu item contains |x|, |y|.

This is satisfied if |x| is in [item.x, item.x + width) and |y| is in [item.y, item.y + height).

Parameters
menu_item_ptr
x
y

◆ wlmaker_menu_item_create()

wlmaker_menu_item_t * wlmaker_menu_item_create ( const wlmaker_menu_item_descriptor_t * desc_ptr,
void * callback_ud_ptr )

Creates a menu item from the given descriptor.

Parameters
desc_ptr
callback_ud_ptrArgument to provide to item's callbacks.
Returns
A pointer to a wlmaker_menu_item_t or NULL on error. Must be destroyed by calling wlmaker_menu_item_destroy().

◆ wlmaker_menu_item_destroy()

void wlmaker_menu_item_destroy ( wlmaker_menu_item_t * menu_item_ptr)

Destroys a menu item previously created by wlmaker_menu_item_create().

Parameters
menu_item_ptr

◆ wlmaker_menu_item_draw()

void wlmaker_menu_item_draw ( wlmaker_menu_item_t * menu_item_ptr,
cairo_t * cairo_ptr )

Draws the menu item. Uses the position and size set previously.

Parameters
menu_item_ptr
cairo_ptr

◆ wlmaker_menu_item_execute()

void wlmaker_menu_item_execute ( const wlmaker_menu_item_t * menu_item_ptr)

Executes the action associated with the menu item, ie. call the callback.

Parameters
menu_item_ptr

◆ wlmaker_menu_item_from_dlnode()

wlmaker_menu_item_t * wlmaker_menu_item_from_dlnode ( bs_dllist_node_t * dlnode_ptr)

Cast: Returns the wlmaker_menu_item_t holding the |dlnode_ptr|.

Parameters
dlnode_ptr
Returns
The pointer.

◆ wlmaker_menu_item_get_desired_size()

void wlmaker_menu_item_get_desired_size ( const wlmaker_menu_item_t * menu_item_ptr,
uint32_t * width_ptr,
uint32_t * height_ptr )

Retrieves the desired size by the menu item.

This provides the size sufficient to show the full menu item information. If the menu opts to draw the item with a smaller size, some information may be omitted, eg. the label might get clipped.

Parameters
menu_item_ptr
width_ptrMay be NULL.
height_ptrMay be NULL.

◆ wlmaker_menu_item_redraw_needed()

bool wlmaker_menu_item_redraw_needed ( const wlmaker_menu_item_t * menu_item_ptr)

Returns whether the menu item should be redrawn.

This is the case when the state becomes different from the drawn state.

Parameters
menu_item_ptr

◆ wlmaker_menu_item_set_focus()

void wlmaker_menu_item_set_focus ( wlmaker_menu_item_t * menu_item_ptr,
bool focussed )

Sets the pointer focus state of the menu item (show as selected).

Parameters
menu_item_ptr
focussed

◆ wlmaker_menu_item_set_position()

void wlmaker_menu_item_set_position ( wlmaker_menu_item_t * menu_item_ptr,
uint32_t x,
uint32_t y )

Sets the size of this menu item, relative to the cairo_t it will draw in.

Parameters
menu_item_ptr
x
y

◆ wlmaker_menu_item_set_size()

void wlmaker_menu_item_set_size ( wlmaker_menu_item_t * menu_item_ptr,
uint32_t width,
uint32_t height )

Sets the size of the menu item. Will be used throughout subsequent draw operations.

Parameters
menu_item_ptr
width
height

Variable Documentation

◆ wlmaker_menu_item_test_cases

const bs_test_case_t wlmaker_menu_item_test_cases[]
extern

Unit tests.