-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathdeco-theme.hpp
75 lines (68 loc) · 2.37 KB
/
deco-theme.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#include <wayfire/render-manager.hpp>
#include "deco-button.hpp"
namespace wf
{
namespace decor
{
/**
* A class which manages the outlook of decorations.
* It is responsible for determining the background colors, sizes, etc.
*/
class decoration_theme_t
{
public:
/** Create a new theme with the default parameters */
decoration_theme_t();
/** @return The available height for displaying the title */
int get_title_height() const;
/** @return The available border for resizing */
int get_border_size() const;
/** Set the flags for buttons */
void set_buttons(button_type_t flags);
button_type_t button_flags;
/**
* Fill the given rectangle with the background color(s).
*
* @param fb The target framebuffer, must have been bound already.
* @param rectangle The rectangle to redraw.
* @param scissor The GL scissor rectangle to use.
* @param active Whether to use active or inactive colors
*/
void render_background(const wf::render_target_t& fb, wf::geometry_t rectangle,
const wf::geometry_t& scissor, bool active) const;
/**
* Render the given text on a cairo_surface_t with the given size.
* The caller is responsible for freeing the memory afterwards.
*/
cairo_surface_t *render_text(std::string text, int width, int height) const;
struct button_state_t
{
/** Button width */
double width;
/** Button height */
double height;
/** Button outline size */
double border;
/** Progress of button hover, in range [-1, 1].
* Negative numbers are usually used for pressed state. */
double hover_progress;
};
/**
* Get the icon for the given button.
* The caller is responsible for freeing the memory afterwards.
*
* @param button The button type.
* @param state The button state.
*/
cairo_surface_t *get_button_surface(button_type_t button,
const button_state_t& state) const;
private:
wf::option_wrapper_t<std::string> font{"decoration/font"};
wf::option_wrapper_t<int> title_height{"decoration/title_height"};
wf::option_wrapper_t<int> border_size{"decoration/border_size"};
wf::option_wrapper_t<wf::color_t> active_color{"decoration/active_color"};
wf::option_wrapper_t<wf::color_t> inactive_color{"decoration/inactive_color"};
};
}
}