wlmaker
Loading...
Searching...
No Matches
Macros | Functions | Variables
button.c File Reference
#include "button.h"
#include <linux/input-event-codes.h>
#include <math.h>
#include <string.h>
#include <wlr/types/wlr_scene.h>
#include "gfxbuf.h"
#include "input.h"
#include "util.h"
#include "libbase/libbase.h"
Include dependency graph for button.c:

Functions

static void _wlmtk_button_clicked (wlmtk_button_t *button_ptr)
 
static bool _wlmtk_button_element_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
 
static void _wlmtk_button_handle_pointer_enter (struct wl_listener *listener_ptr, void *data_ptr)
 
static void _wlmtk_button_handle_pointer_leave (struct wl_listener *listener_ptr, void *data_ptr)
 
static void apply_state (wlmtk_button_t *button_ptr)
 
bool wlmtk_button_init (wlmtk_button_t *button_ptr)
 
wlmtk_button_vmt_t wlmtk_button_extend (wlmtk_button_t *button_ptr, const wlmtk_button_vmt_t *button_vmt_ptr)
 
void wlmtk_button_fini (wlmtk_button_t *button_ptr)
 
void wlmtk_button_set (wlmtk_button_t *button_ptr, struct wlr_buffer *released_wlr_buffer_ptr, struct wlr_buffer *pressed_wlr_buffer_ptr)
 
static void test_create_destroy (bs_test_t *test_ptr)
 
static void test_press_release (bs_test_t *test_ptr)
 
static void test_press_release_outside (bs_test_t *test_ptr)
 
static void test_press_right (bs_test_t *test_ptr)
 
static void fake_button_clicked (wlmtk_button_t *button_ptr)
 

Variables

static const wlmtk_element_vmt_t button_element_vmt
 
static const wlmtk_button_vmt_t button_vmt
 
const bs_test_case_t wlmtk_button_test_cases []
 
static bool fake_button_got_clicked = false
 
static const wlmtk_button_vmt_t fake_button_vmt
 

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_button_clicked()

void _wlmtk_button_clicked ( wlmtk_button_t button_ptr)
static

Default implementation of wlmtk_button_vmt_t::clicked. Nothing.

◆ _wlmtk_button_element_pointer_button()

bool _wlmtk_button_element_pointer_button ( wlmtk_element_t element_ptr,
const wlmtk_button_event_t button_event_ptr 
)
static

◆ _wlmtk_button_handle_pointer_enter()

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

Pointer enters the area: We may need to update visualization.

◆ _wlmtk_button_handle_pointer_leave()

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

Pointer leaves the area: We may need to update visualization.

◆ apply_state()

void apply_state ( wlmtk_button_t button_ptr)
static

Sets the appropriate texture for the button.

◆ fake_button_clicked()

static void fake_button_clicked ( wlmtk_button_t button_ptr)
static

Fake 'clicked' handler.

◆ test_create_destroy()

void test_create_destroy ( bs_test_t *  test_ptr)
static

◆ test_press_release()

void test_press_release ( bs_test_t *  test_ptr)
static

Tests button pressing & releasing.

◆ test_press_release_outside()

void test_press_release_outside ( bs_test_t *  test_ptr)
static

Tests button when releasing outside the pointer focus.

◆ test_press_right()

void test_press_right ( bs_test_t *  test_ptr)
static

Tests button when releasing outside the pointer focus.

◆ wlmtk_button_extend()

wlmtk_button_vmt_t wlmtk_button_extend ( wlmtk_button_t button_ptr,
const wlmtk_button_vmt_t button_vmt_ptr 
)

Extends the button's virtual methods.

Parameters
button_ptr
button_vmt_ptr
Returns
The original virtual method table.

◆ wlmtk_button_fini()

void wlmtk_button_fini ( wlmtk_button_t button_ptr)

Cleans up the button.

Parameters
button_ptr

◆ wlmtk_button_init()

bool wlmtk_button_init ( wlmtk_button_t button_ptr)

Initializes the button.

Parameters
button_ptr
Returns
true on success.

◆ wlmtk_button_set()

void wlmtk_button_set ( wlmtk_button_t button_ptr,
struct wlr_buffer *  released_wlr_buffer_ptr,
struct wlr_buffer *  pressed_wlr_buffer_ptr 
)

Sets (or updates) the button textures.

Parameters
button_ptr
released_wlr_buffer_ptr
pressed_wlr_buffer_ptr

Variable Documentation

◆ button_element_vmt

const wlmtk_element_vmt_t button_element_vmt
static
Initial value:
= {
}
static bool _wlmtk_button_element_pointer_button(wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
Definition button.c:165

Virtual method table for the button's element super class.

◆ button_vmt

const wlmtk_button_vmt_t button_vmt
static
Initial value:
= {
}
static void _wlmtk_button_clicked(wlmtk_button_t *button_ptr)
Definition button.c:158

Virtual method table for the button.

◆ fake_button_got_clicked

bool fake_button_got_clicked = false
static

Test outcome: Whether 'clicked' was called.

◆ fake_button_vmt

const wlmtk_button_vmt_t fake_button_vmt
static
Initial value:
= {
.clicked = fake_button_clicked,
}
static void fake_button_clicked(wlmtk_button_t *button_ptr)
Definition button.c:256

Virtual method table of fake button.

◆ wlmtk_button_test_cases

const bs_test_case_t wlmtk_button_test_cases[]
Initial value:
= {
{ 1, "create_destroy", test_create_destroy },
{ 1, "press_release", test_press_release },
{ 1, "press_release_outside", test_press_release_outside },
{ 1, "press_right", test_press_right },
{ 0, NULL, NULL }
}
static void test_press_release(bs_test_t *test_ptr)
Definition button.c:277
static void test_create_destroy(bs_test_t *test_ptr)
Definition button.c:267
static void test_press_release_outside(bs_test_t *test_ptr)
Definition button.c:339
static void test_press_right(bs_test_t *test_ptr)
Definition button.c:391

Test case definition.