wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
rectangle.c File Reference
#include "rectangle.h"
#include <libbase/libbase.h>
#include <stdbool.h>
#include <stdlib.h>
#include <wayland-server-core.h>
#include <wayland-util.h>
#include <wlr/types/wlr_scene.h>
#include "container.h"
#include "input.h"
#include "util.h"
Include dependency graph for rectangle.c:

Classes

struct  _wlmtk_rectangle_t
 

Functions

static void _wlmtk_rectangle_element_destroy (wlmtk_element_t *element_ptr)
 
static struct wlr_scene_node * _wlmtk_rectangle_element_create_scene_node (wlmtk_element_t *element_ptr, struct wlr_scene_tree *wlr_scene_tree_ptr)
 
static bool _wlmtk_rectangle_element_pointer_motion (wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr)
 
static void _wlmtk_rectangle_get_dimensions (wlmtk_element_t *element_ptr, int *x1_ptr, int *y1_ptr, int *x2_ptr, int *y2_ptr)
 
static void handle_wlr_scene_rect_node_destroy (struct wl_listener *listener_ptr, void *data_ptr)
 
wlmtk_rectangle_twlmtk_rectangle_create (int width, int height, uint32_t color)
 
void wlmtk_rectangle_destroy (wlmtk_rectangle_t *rectangle_ptr)
 
void wlmtk_rectangle_set_size (wlmtk_rectangle_t *rectangle_ptr, int width, int height)
 
void wlmtk_rectangle_set_color (wlmtk_rectangle_t *rectangle_ptr, uint32_t color)
 
wlmtk_element_twlmtk_rectangle_element (wlmtk_rectangle_t *rectangle_ptr)
 
wlmtk_rectangle_twlmtk_rectangle_from_element (wlmtk_element_t *element_ptr)
 
static void test_create_destroy (bs_test_t *test_ptr)
 
static void test_create_destroy_scene (bs_test_t *test_ptr)
 

Variables

static const wlmtk_element_vmt_t _wlmtk_rectangle_element_vmt
 
const bs_test_case_t wlmtk_rectangle_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.

Function Documentation

◆ _wlmtk_rectangle_element_create_scene_node()

struct wlr_scene_node * _wlmtk_rectangle_element_create_scene_node ( wlmtk_element_t element_ptr,
struct wlr_scene_tree *  wlr_scene_tree_ptr 
)
static

Implementation of the superclass wlmtk_element_t::create_scene_node method.

Creates a struct wlr_scene_rect attached to wlr_scene_tree_ptr.

Parameters
element_ptr
wlr_scene_tree_ptr

◆ _wlmtk_rectangle_element_destroy()

void _wlmtk_rectangle_element_destroy ( wlmtk_element_t element_ptr)
static

Virtual dtor: Invoke the rectangle's dtor.

◆ _wlmtk_rectangle_element_pointer_motion()

bool _wlmtk_rectangle_element_pointer_motion ( wlmtk_element_t element_ptr,
wlmtk_pointer_motion_event_t motion_event_ptr 
)
static

Implements wlmtk_element_vmt_t::pointer_motion. Sets cursor.

◆ _wlmtk_rectangle_get_dimensions()

void _wlmtk_rectangle_get_dimensions ( wlmtk_element_t element_ptr,
int *  x1_ptr,
int *  y1_ptr,
int *  x2_ptr,
int *  y2_ptr 
)
static

Implementation of the element's get_dimensions method: Return dimensions.

Parameters
element_ptr
x1_ptr0.
y1_ptr0.
x2_ptrWidth. May be NULL.
y2_ptrHeight. May be NULL.

◆ handle_wlr_scene_rect_node_destroy()

void handle_wlr_scene_rect_node_destroy ( struct wl_listener *  listener_ptr,
void *  data_ptr 
)
static

Handles the 'destroy' callback of wlr_scene_rect_ptr->node.

Will reset the wlr_scene_rect_ptr value. Destruction of the node had been triggered (hence the callback).

Parameters
listener_ptr
data_ptr

◆ test_create_destroy()

void test_create_destroy ( bs_test_t *  test_ptr)
static

Tests setup and teardown of rectangle.

◆ test_create_destroy_scene()

void test_create_destroy_scene ( bs_test_t *  test_ptr)
static

Tests setup and teardown of rectangle, when attached to scene graph.

◆ wlmtk_rectangle_create()

wlmtk_rectangle_t * wlmtk_rectangle_create ( int  width,
int  height,
uint32_t  color 
)

Creates a rectangle. Useful for margins and borders.

Parameters
width
height
color
Returns
Pointer to the rectangle state or NULL on error.

◆ wlmtk_rectangle_destroy()

void wlmtk_rectangle_destroy ( wlmtk_rectangle_t rectangle_ptr)

Destroys the rectangle.

Parameters
rectangle_ptr

◆ wlmtk_rectangle_element()

wlmtk_element_t * wlmtk_rectangle_element ( wlmtk_rectangle_t rectangle_ptr)

Returns the superclass wlmtk_element_t of the rectangle.

◆ wlmtk_rectangle_from_element()

wlmtk_rectangle_t * wlmtk_rectangle_from_element ( wlmtk_element_t element_ptr)

Gets the wlmtk_rectangle_t instance from it's element superclass.

Requires element_ptr as pointer to wlmtk_rectangle_t::super_element.

Parameters
element_ptr
Returns
The pointer to the wlmtk_rectangle_t instance.

◆ wlmtk_rectangle_set_color()

void wlmtk_rectangle_set_color ( wlmtk_rectangle_t rectangle_ptr,
uint32_t  color 
)

Sets (or updates) the color of the rectangle.

Parameters
rectangle_ptr
color

◆ wlmtk_rectangle_set_size()

void wlmtk_rectangle_set_size ( wlmtk_rectangle_t rectangle_ptr,
int  width,
int  height 
)

Sets (or updates) the size of the rectangle.

Parameters
rectangle_ptr
width
height

Variable Documentation

◆ _wlmtk_rectangle_element_vmt

const wlmtk_element_vmt_t _wlmtk_rectangle_element_vmt
static
Initial value:
= {
}
static void _wlmtk_rectangle_get_dimensions(wlmtk_element_t *element_ptr, int *x1_ptr, int *y1_ptr, int *x2_ptr, int *y2_ptr)
Definition rectangle.c:243
static struct wlr_scene_node * _wlmtk_rectangle_element_create_scene_node(wlmtk_element_t *element_ptr, struct wlr_scene_tree *wlr_scene_tree_ptr)
Definition rectangle.c:190
static void _wlmtk_rectangle_element_destroy(wlmtk_element_t *element_ptr)
Definition rectangle.c:174
static bool _wlmtk_rectangle_element_pointer_motion(wlmtk_element_t *element_ptr, wlmtk_pointer_motion_event_t *motion_event_ptr)
Definition rectangle.c:217

Virtual method table of the rectangle, extending the element.

◆ wlmtk_rectangle_test_cases

const bs_test_case_t wlmtk_rectangle_test_cases[]
Initial value:
= {
{ 1, "create_destroy", test_create_destroy },
{ 1, "create_destroy_scene", test_create_destroy_scene },
{ 0, NULL, NULL }
}
static void test_create_destroy(bs_test_t *test_ptr)
Definition rectangle.c:292
static void test_create_destroy_scene(bs_test_t *test_ptr)
Definition rectangle.c:320

Unit tests.