wlmaker
Loading...
Searching...
No Matches
decorations.c File Reference
#include "decorations.h"
#include <limits.h>
#include <math.h>
#include <stdint.h>
#include <libbase/libbase.h>
#include "toolkit/toolkit.h"
Include dependency graph for decorations.c:

Functions

static cairo_surface_t * create_background (unsigned width, unsigned height, const wlmtk_style_fill_t *fill_ptr)
 
void wlmaker_decorations_draw_tile (cairo_t *cairo_ptr, const wlmtk_style_fill_t *fill_ptr, bool pressed)
 
bool wlmaker_decorations_draw_tile_icon (cairo_t *cairo_ptr, const char *icon_path_ptr)
 
void wlmaker_decorations_draw_iconified (cairo_t *cairo_ptr, const wlmtk_style_fill_t *fill_ptr, uint32_t font_color, const char *title_ptr)
 
bool wlmaker_decorations_draw_clip (cairo_t *cairo_ptr, const wlmtk_style_fill_t *fill_ptr, bool pressed)
 
bool wlmaker_decorations_draw_clip_button_next (cairo_t *cairo_ptr, const wlmtk_style_fill_t *fill_ptr, bool pressed)
 
bool wlmaker_decorations_draw_clip_button_prev (cairo_t *cairo_ptr, const wlmtk_style_fill_t *fill_ptr, bool pressed)
 
static void test_tile (bs_test_t *test_ptr)
 
static void test_iconified (bs_test_t *test_ptr)
 
static void test_clip (bs_test_t *test_ptr)
 
static void test_clip_button_next (bs_test_t *test_ptr)
 
static void test_clip_button_prev (bs_test_t *test_ptr)
 

Variables

const uint32_t wlmaker_decorations_tile_size = 64
 
const uint32_t wlmaker_decorations_tile_margin = 2
 
const uint32_t wlmaker_decorations_clip_button_size = 22
 
const char * lookup_paths []
 
const bs_test_case_t wlmaker_decorations_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

◆ create_background()

static cairo_surface_t * create_background ( unsigned width,
unsigned height,
const wlmtk_style_fill_t * fill_ptr )
static

Creates background cairo surface with given |width| x |height| and |fill|.

Parameters
width
height
fill_ptr
Returns
Cairo surface.

◆ test_clip()

void test_clip ( bs_test_t * test_ptr)
static

Verifies the clip tile (excluding the buttons) is drawn as expected.

◆ test_clip_button_next()

void test_clip_button_next ( bs_test_t * test_ptr)
static

Verifies the clip's "next" button is drawn as expected.

◆ test_clip_button_prev()

void test_clip_button_prev ( bs_test_t * test_ptr)
static

Verifies the clip's "prev" button is drawn as expected.

◆ test_iconified()

void test_iconified ( bs_test_t * test_ptr)
static

Verifies the title text is drawn as expected.

◆ test_tile()

void test_tile ( bs_test_t * test_ptr)
static

Verifies the title text is drawn as expected.

◆ wlmaker_decorations_draw_clip()

bool wlmaker_decorations_draw_clip ( cairo_t * cairo_ptr,
const wlmtk_style_fill_t * fill_ptr,
bool pressed )

Draws the clip's tile into |cairo_ptr|.

This includes the tile with the diagonal bezel edges facing the triangle buttons, but excludes the triangle buttons. Excludes the text.

Parameters
cairo_ptr
fill_ptr
pressed
Returns
true, iff the clip was drawn.

◆ wlmaker_decorations_draw_clip_button_next()

bool wlmaker_decorations_draw_clip_button_next ( cairo_t * cairo_ptr,
const wlmtk_style_fill_t * fill_ptr,
bool pressed )

Draws the north-eastern clip button ("next") onto |cairo_ptr|.

Parameters
cairo_ptr
fill_ptr
pressed
Returns
true, iff the button was drawn.

◆ wlmaker_decorations_draw_clip_button_prev()

bool wlmaker_decorations_draw_clip_button_prev ( cairo_t * cairo_ptr,
const wlmtk_style_fill_t * fill_ptr,
bool pressed )

Draws the south-western clip button ("prev") onto |cairo_ptr|.

Parameters
cairo_ptr
fill_ptr
pressed
Returns
true, iff the button was drawn.

◆ wlmaker_decorations_draw_iconified()

void wlmaker_decorations_draw_iconified ( cairo_t * cairo_ptr,
const wlmtk_style_fill_t * fill_ptr,
uint32_t font_color,
const char * title_ptr )

Draws the title of an iconified on to cairo_ptr.

Parameters
cairo_ptr
fill_ptr
font_color
title_ptr

◆ wlmaker_decorations_draw_tile()

void wlmaker_decorations_draw_tile ( cairo_t * cairo_ptr,
const wlmtk_style_fill_t * fill_ptr,
bool pressed )

Draws a tile into the cairo_t.

Parameters
cairo_ptr
fill_ptr
pressed

◆ wlmaker_decorations_draw_tile_icon()

bool wlmaker_decorations_draw_tile_icon ( cairo_t * cairo_ptr,
const char * icon_path_ptr )

Loads an icon and draws it onto the pre-drawn tile at |cairo_ptr|.

Parameters
cairo_ptr
icon_path_ptr
Returns
true if the icon was loaded (and then drawn) successfully.

Variable Documentation

◆ lookup_paths

const char* lookup_paths[]
Initial value:
= {
"/usr/share/icons/wlmaker",
"/usr/local/share/icons/wlmaker",
NULL
}

Lookup paths for icons.

◆ wlmaker_decorations_clip_button_size

const uint32_t wlmaker_decorations_clip_button_size = 22

Size of the clip button (length of the catheti)

◆ wlmaker_decorations_test_cases

const bs_test_case_t wlmaker_decorations_test_cases[]
Initial value:
= {
{ 1, "tile", test_tile },
{ 1, "iconified", test_iconified },
{ 1, "clip", test_clip },
{ 1, "clip_button_next", test_clip_button_next },
{ 1, "clip_button_prev", test_clip_button_prev },
{ 0, NULL, NULL }
}
static void test_clip_button_prev(bs_test_t *test_ptr)
Definition decorations.c:567
static void test_tile(bs_test_t *test_ptr)
Definition decorations.c:478
static void test_clip(bs_test_t *test_ptr)
Definition decorations.c:518
static void test_clip_button_next(bs_test_t *test_ptr)
Definition decorations.c:539
static void test_iconified(bs_test_t *test_ptr)
Definition decorations.c:498

Unit tests.

◆ wlmaker_decorations_tile_margin

const uint32_t wlmaker_decorations_tile_margin = 2

Hardcoded: Margin of the tile, defining the width of the bezel.

◆ wlmaker_decorations_tile_size

const uint32_t wlmaker_decorations_tile_size = 64

Hardcoded: Default size of tiles.