wlmaker
Loading...
Searching...
No Matches
button.c File Reference
#include "button.h"
#include <libbase/libbase.h>
#include <linux/input-event-codes.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_cursor.h>
Include dependency graph for button.c:

Classes

struct  wlmaker_button_t
 

Functions

static wlmaker_button_tbutton_from_interactive (wlmaker_interactive_t *interactive_ptr)
 
static void button_press (wlmaker_button_t *button_ptr, bool pressed)
 
static void _button_enter (wlmaker_interactive_t *interactive_ptr)
 
static void _button_leave (wlmaker_interactive_t *interactive_ptr)
 
static void _button_motion (wlmaker_interactive_t *interactive_ptr, double x, double y)
 
static void _button_focus (wlmaker_interactive_t *interactive_ptr)
 
static void _button_button (wlmaker_interactive_t *interactive_ptr, double x, double y, struct wlr_pointer_button_event *wlr_pointer_button_event_ptr)
 
static void _button_destroy (wlmaker_interactive_t *interactive_ptr)
 
wlmaker_interactive_twlmaker_button_create (struct wlr_scene_buffer *wlr_scene_buffer_ptr, wlmaker_cursor_t *cursor_ptr, wlmaker_interactive_callback_t button_callback, void *button_callback_arg, struct wlr_buffer *button_released_ptr, struct wlr_buffer *button_pressed_ptr, struct wlr_buffer *button_blurred_ptr)
 
void wlmaker_button_set_textures (wlmaker_interactive_t *interactive_ptr, struct wlr_buffer *button_released_ptr, struct wlr_buffer *button_pressed_ptr, struct wlr_buffer *button_blurred_ptr)
 

Variables

static const wlmaker_interactive_impl_t wlmaker_interactive_button_impl
 

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

◆ _button_button()

void _button_button ( wlmaker_interactive_t * interactive_ptr,
double x,
double y,
struct wlr_pointer_button_event * wlr_pointer_button_event_ptr )
static

Interactive callback: Handle cursor button, ie. button press or release.

Parameters
interactive_ptr
x
y
wlr_pointer_button_event_ptr

◆ _button_destroy()

void _button_destroy ( wlmaker_interactive_t * interactive_ptr)
static

Destroys the button interactive.

Parameters
interactive_ptr

◆ _button_enter()

void _button_enter ( wlmaker_interactive_t * interactive_ptr)
static

Interactive callback: Cursor enters the button area.

Parameters
interactive_ptr

◆ _button_focus()

static void _button_focus ( wlmaker_interactive_t * interactive_ptr)
static

Interactive callback: Focus state changes.

Parameters
interactive_ptr

◆ _button_leave()

void _button_leave ( wlmaker_interactive_t * interactive_ptr)
static

Interactive callback: Cursor leaves the button area.

Parameters
interactive_ptr

◆ _button_motion()

void _button_motion ( wlmaker_interactive_t * interactive_ptr,
double x,
double y )
static

Interactive callback: Handle cursor motion.

Parameters
interactive_ptr
x
y

◆ button_from_interactive()

wlmaker_button_t * button_from_interactive ( wlmaker_interactive_t * interactive_ptr)
static

Cast (with assertion) |interactive_ptr| to the |wlmaker_button_t|.

Parameters
interactive_ptr

◆ button_press()

void button_press ( wlmaker_button_t * button_ptr,
bool pressed )
static

Changes the "pressed" state of this button, and updates the buffer texture.

Parameters
button_ptr
pressed

◆ wlmaker_button_create()

wlmaker_interactive_t * wlmaker_button_create ( struct wlr_scene_buffer * wlr_scene_buffer_ptr,
wlmaker_cursor_t * cursor_ptr,
wlmaker_interactive_callback_t button_callback,
void * button_callback_arg,
struct wlr_buffer * button_released_ptr,
struct wlr_buffer * button_pressed_ptr,
struct wlr_buffer * button_blurred_ptr )

Creates a button interactive.

Parameters
wlr_scene_buffer_ptrBuffer scene node to contain the button.
cursor_ptr
button_callbackWill be called if/when the button is clicked.
button_callback_argExtra arg to |button_callback|.
button_released_ptrWLR buffer, button texture in "released" state. The button will hold a consumer lock on it.
button_pressed_ptrWLR buffer, button texture in "pressed" state. The button will hold a consumer lock on it.
button_blurred_ptrWLR buffer, button texture in "blurred" state. The button will hold a consumer lock on it.
Returns
A pointer to the interactive. Must be destroyed via |_button_destroy|.

◆ wlmaker_button_set_textures()

void wlmaker_button_set_textures ( wlmaker_interactive_t * interactive_ptr,
struct wlr_buffer * button_released_ptr,
struct wlr_buffer * button_pressed_ptr,
struct wlr_buffer * button_blurred_ptr )

Sets (replaces) the textures for the button interactive.

Parameters
interactive_ptr
button_released_ptrWLR buffer, button texture in "released" state. The button will hold a consumer lock on it.
button_pressed_ptrWLR buffer, button texture in "pressed" state. The button will hold a consumer lock on it.
button_blurred_ptrWLR buffer, button texture in "blurred" state. The button will hold a consumer lock on it.

Variable Documentation

◆ wlmaker_interactive_button_impl

const wlmaker_interactive_impl_t wlmaker_interactive_button_impl
static
Initial value:
= {
.enter = _button_enter,
.leave = _button_leave,
.motion = _button_motion,
.focus = _button_focus,
.button = _button_button,
.destroy = _button_destroy
}
static void _button_destroy(wlmaker_interactive_t *interactive_ptr)
Definition button.c:333
static void _button_leave(wlmaker_interactive_t *interactive_ptr)
Definition button.c:230
static void _button_focus(wlmaker_interactive_t *interactive_ptr)
Definition button.c:262
static void _button_button(wlmaker_interactive_t *interactive_ptr, double x, double y, struct wlr_pointer_button_event *wlr_pointer_button_event_ptr)
Definition button.c:291
static void _button_enter(wlmaker_interactive_t *interactive_ptr)
Definition button.c:213
static void _button_motion(wlmaker_interactive_t *interactive_ptr, double x, double y)
Definition button.c:244

Implementation: callbacks for the interactive.