Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions metadata/decoration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
<_long>Sets the font color to use for the title bars.</_long>
<default>#ffffffff</default>
</option>
<option name="font_scale" type="double">
<_short>Font scale</_short>
<_long>Sets the font scale to use for the title bars.</_long>
<default>0.8</default>
<max>1.0</max>
<min>0.1</min>
</option>
<option name="title_height" type="int">
<_short>Title bar height</_short>
<_long>Sets the height of the title bars in pixels.</_long>
Expand All @@ -33,6 +40,18 @@
<_long>Sets the order of the window buttons.</_long>
<default>minimize maximize close</default>
</option>
<option name="button_scale" type="double">
<_short>Buttons scale</_short>
<_long>Sets the scale for window buttons.</_long>
<default>0.7</default>
<max>1.0</max>
<min>0.1</min>
</option>
<option name="button_padding" type="int">
<_short>Buttons padding</_short>
<_long>Sets the vertical padding for window buttons.</_long>
<default>4</default>
</option>
<!-- Colors -->
<option name="active_color" type="color">
<_short>Color when window is active</_short>
Expand Down
17 changes: 8 additions & 9 deletions plugins/decor/deco-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <wayfire/util.hpp>
#include <sstream>

#define BUTTON_HEIGHT_PC 0.7

namespace wf
{
namespace decor
Expand Down Expand Up @@ -64,9 +62,10 @@ decoration_layout_t::decoration_layout_t(const decoration_theme_t& th,
* overly huge button. 70% of the titlebar height
* is a decent size. (Equals 21 px by default)
*/
button_width(titlebar_size * BUTTON_HEIGHT_PC),
button_height(titlebar_size * BUTTON_HEIGHT_PC),
button_padding((titlebar_size - button_height) / 2),
button_width(titlebar_size * th.get_button_scale()),
button_height(titlebar_size * th.get_button_scale()),
button_padding_width(th.get_button_padding()),
button_padding_height((titlebar_size - button_height) / 2),
theme(th),
damage_callback(callback)
{}
Expand Down Expand Up @@ -94,10 +93,10 @@ wf::geometry_t decoration_layout_t::create_buttons(int width, int)
}
}

int per_button = 2 * button_padding + button_width;
int per_button = 2 * button_padding_width + button_width;
wf::geometry_t button_geometry = {
width - border_size + button_padding, /* 1 more padding initially */
button_padding + border_size,
width - border_size + button_padding_width, /* 1 more padding initially */
button_padding_height + border_size,
button_width,
button_height,
};
Expand All @@ -110,7 +109,7 @@ wf::geometry_t decoration_layout_t::create_buttons(int width, int)
this->layout_areas.back()->as_button().set_button_type(type);
}

int total_width = -button_padding + buttons.size() * per_button;
int total_width = -button_padding_width + buttons.size() * per_button;

return {
button_geometry.x, border_size,
Expand Down
3 changes: 2 additions & 1 deletion plugins/decor/deco-layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ class decoration_layout_t
const int border_size;
const int button_width;
const int button_height;
const int button_padding;
const int button_padding_width;
const int button_padding_height;
const decoration_theme_t& theme;

std::function<void(wlr_box)> damage_callback;
Expand Down
15 changes: 13 additions & 2 deletions plugins/decor/deco-theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ int decoration_theme_t::get_border_size() const
return border_size;
}

/** @return The scale factor for buttons */
double decoration_theme_t::get_button_scale() const
{
return button_scale;
}

/** @return The vertical padding for buttons */
int decoration_theme_t::get_button_padding() const
{
return button_padding;
}

/** @return The available border for resizing */
void decoration_theme_t::set_buttons(button_type_t flags)
{
Expand Down Expand Up @@ -62,8 +74,7 @@ cairo_surface_t*decoration_theme_t::render_text(std::string text,
wf::color_t color = font_color;
auto cr = cairo_create(surface);

const float font_scale = 0.8;
const float font_size = height * font_scale;
const float font_size = height * font_scale;

PangoFontDescription *font_desc;
PangoLayout *layout;
Expand Down
7 changes: 7 additions & 0 deletions plugins/decor/deco-theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class decoration_theme_t
int get_title_height() const;
/** @return The available border for resizing */
int get_border_size() const;
/** @return The scale factor for buttons */
double get_button_scale() const;
/** @return The vertical padding for buttons */
int get_button_padding() const;
/** Set the flags for buttons */
void set_buttons(button_type_t flags);
button_type_t button_flags;
Expand Down Expand Up @@ -69,6 +73,9 @@ class decoration_theme_t
wf::option_wrapper_t<wf::color_t> font_color{"decoration/font_color"};
wf::option_wrapper_t<int> title_height{"decoration/title_height"};
wf::option_wrapper_t<int> border_size{"decoration/border_size"};
wf::option_wrapper_t<double> font_scale{"decoration/font_scale"};
wf::option_wrapper_t<double> button_scale{"decoration/button_scale"};
wf::option_wrapper_t<int> button_padding{"decoration/button_padding"};
wf::option_wrapper_t<wf::color_t> active_color{"decoration/active_color"};
wf::option_wrapper_t<wf::color_t> inactive_color{"decoration/inactive_color"};
};
Expand Down
Loading