wlmaker
Loading...
Searching...
No Matches
Classes | Macros | Functions | Variables
titlebar_title.c File Reference
#include "titlebar_title.h"
#include <cairo.h>
#include <libbase/libbase.h>
#include <linux/input-event-codes.h>
#include <stdint.h>
#include <stdlib.h>
#include <wayland-server-protocol.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/version.h>
#include "buffer.h"
#include "gfxbuf.h"
#include "input.h"
#include "menu.h"
#include "primitives.h"
#include "window.h"
Include dependency graph for titlebar_title.c:

Classes

struct  _wlmtk_titlebar_title_t
 

Functions

static void _wlmtk_titlebar_title_element_destroy (wlmtk_element_t *element_ptr)
 
static bool _wlmtk_titlebar_title_element_pointer_button (wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
 
static bool _wlmtk_titlebar_title_element_pointer_axis (wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
 
static void title_set_activated (wlmtk_titlebar_title_t *titlebar_title_ptr, bool activated)
 
struct wlr_buffer * title_create_buffer (bs_gfxbuf_t *gfxbuf_ptr, unsigned position, unsigned width, uint32_t text_color, const char *title_ptr, const wlmtk_titlebar_style_t *style_ptr)
 
wlmtk_titlebar_title_twlmtk_titlebar_title_create (wlmtk_window_t *window_ptr)
 
void wlmtk_titlebar_title_destroy (wlmtk_titlebar_title_t *titlebar_title_ptr)
 
bool wlmtk_titlebar_title_redraw (wlmtk_titlebar_title_t *titlebar_title_ptr, bs_gfxbuf_t *focussed_gfxbuf_ptr, bs_gfxbuf_t *blurred_gfxbuf_ptr, int position, int width, bool activated, const char *title_ptr, const wlmtk_titlebar_style_t *style_ptr)
 
void wlmtk_titlebar_title_set_activated (wlmtk_titlebar_title_t *titlebar_title_ptr, bool activated)
 
wlmtk_element_twlmtk_titlebar_title_element (wlmtk_titlebar_title_t *titlebar_title_ptr)
 
static void test_title (bs_test_t *test_ptr)
 
static void test_shade (bs_test_t *test_ptr)
 

Variables

static const wlmtk_element_vmt_t titlebar_title_element_vmt
 
const bs_test_case_t wlmtk_titlebar_title_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_titlebar_title_element_destroy()

void _wlmtk_titlebar_title_element_destroy ( wlmtk_element_t element_ptr)
static

Dtor.

◆ _wlmtk_titlebar_title_element_pointer_axis()

bool _wlmtk_titlebar_title_element_pointer_axis ( wlmtk_element_t element_ptr,
struct wlr_pointer_axis_event *  wlr_pointer_axis_event_ptr 
)
static

Handles pointer axis events: Scroll wheel up will shade, down will unshade.

Parameters
element_ptr
wlr_pointer_axis_event_ptr
Returns
true, if the axis event was consumed. That is the case if it's source is a scroll wheel, and the orientation is vertical.

◆ _wlmtk_titlebar_title_element_pointer_button()

bool _wlmtk_titlebar_title_element_pointer_button ( wlmtk_element_t element_ptr,
const wlmtk_button_event_t button_event_ptr 
)
static

◆ test_shade()

void test_shade ( bs_test_t *  test_ptr)
static

Tests that axis actions trigger 'shade'.

◆ test_title()

void test_title ( bs_test_t *  test_ptr)
static

Tests title drawing.

◆ title_create_buffer()

struct wlr_buffer * title_create_buffer ( bs_gfxbuf_t *  gfxbuf_ptr,
unsigned  position,
unsigned  width,
uint32_t  text_color,
const char *  title_ptr,
const wlmtk_titlebar_style_t style_ptr 
)

Creates a WLR buffer with the title's texture, as specified.

Parameters
gfxbuf_ptr
position
width
text_color
title_ptr
style_ptr
Returns
A pointer to a struct wlr_buffer with the texture.

◆ title_set_activated()

void title_set_activated ( wlmtk_titlebar_title_t titlebar_title_ptr,
bool  activated 
)
static

Sets whether the title is drawn focussed (activated) or blurred.

Parameters
titlebar_title_ptr
activated

◆ wlmtk_titlebar_title_create()

wlmtk_titlebar_title_t * wlmtk_titlebar_title_create ( wlmtk_window_t window_ptr)

Creates a title bar title.

Parameters
window_ptr
Returns
Title handle.

◆ wlmtk_titlebar_title_destroy()

void wlmtk_titlebar_title_destroy ( wlmtk_titlebar_title_t titlebar_title_ptr)

Destroys the titlebar title.

Parameters
titlebar_title_ptr

◆ wlmtk_titlebar_title_element()

wlmtk_element_t * wlmtk_titlebar_title_element ( wlmtk_titlebar_title_t titlebar_title_ptr)

Returns the superclass wlmtk_element_t for the titlebar title.

Parameters
titlebar_title_ptr
Returns
Pointer to the super element.

◆ wlmtk_titlebar_title_redraw()

bool wlmtk_titlebar_title_redraw ( wlmtk_titlebar_title_t titlebar_title_ptr,
bs_gfxbuf_t *  focussed_gfxbuf_ptr,
bs_gfxbuf_t *  blurred_gfxbuf_ptr,
int  position,
int  width,
bool  activated,
const char *  title_ptr,
const wlmtk_titlebar_style_t style_ptr 
)

Redraws the title section of the title bar.

Parameters
titlebar_title_ptr
focussed_gfxbuf_ptrTitlebar background when focussed.
blurred_gfxbuf_ptrTitlebar background when blurred.
positionPosition of title telative to titlebar.
widthWidth of title.
activatedWhether the title bar should start focussed.
title_ptrTitle, or NULL.
style_ptr
Returns
true on success.

◆ wlmtk_titlebar_title_set_activated()

void wlmtk_titlebar_title_set_activated ( wlmtk_titlebar_title_t titlebar_title_ptr,
bool  activated 
)

Sets activation status of the titlebar's title.

Parameters
titlebar_title_ptr
activated

Variable Documentation

◆ titlebar_title_element_vmt

const wlmtk_element_vmt_t titlebar_title_element_vmt
static
Initial value:
= {
}
static bool _wlmtk_titlebar_title_element_pointer_axis(wlmtk_element_t *element_ptr, struct wlr_pointer_axis_event *wlr_pointer_axis_event_ptr)
Definition titlebar_title.c:218
static void _wlmtk_titlebar_title_element_destroy(wlmtk_element_t *element_ptr)
Definition titlebar_title.c:176
static bool _wlmtk_titlebar_title_element_pointer_button(wlmtk_element_t *element_ptr, const wlmtk_button_event_t *button_event_ptr)
Definition titlebar_title.c:186

Extension to the superclass elment's virtual method table.

◆ wlmtk_titlebar_title_test_cases

const bs_test_case_t wlmtk_titlebar_title_test_cases[]
Initial value:
= {
{ 0, "title", test_title },
{ 1, "shade", test_shade },
{ 0, NULL, NULL }
}
static void test_title(bs_test_t *test_ptr)
Definition titlebar_title.c:330
static void test_shade(bs_test_t *test_ptr)
Definition titlebar_title.c:427

Unit test cases.