diff --git a/doc/themes.md b/doc/themes.md index 0ea2b1bc..30a1eb22 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -112,7 +112,7 @@ Theming of the frame. * _Height (pixels)_, Amount of pixels the titlebar should height. * _HeightAdapt (boolean)_, If true, Height is adapted to fit the Title font. -* _Pad (pixels t,d,l,r)_, How many pixels are left around a title text. +* _Pad (pixels t,b,l,r)_, How many pixels are left around a title text. * _PadAdapt (boolean), Set true to adjust vertical padding so that the font gets centered vertically, requires _HeightAdapt_ to be false. * _Focused (texture)_, Background texture for a focused titlebar. * _UnFocused (texture)_, Background texture for an unfocused titlebar. diff --git a/src/StatusWindow.cc b/src/StatusWindow.cc index 329684e7..391fdc0e 100644 --- a/src/StatusWindow.cc +++ b/src/StatusWindow.cc @@ -72,7 +72,9 @@ StatusWindow::draw(const std::string &text, bool do_center, Geometry *gm) Theme::TextDialogData *sd = _theme->getStatusData(); PFont *font = sd->getFont(); - width = font->getWidth(text) + 10; + width = font->getWidth(text) + + sd->getPad(PAD_LEFT) + + sd->getPad(PAD_RIGHT); width = width - (width % 10); height = font->getHeight() + sd->getPad(PAD_UP) @@ -99,7 +101,7 @@ StatusWindow::draw(const std::string &text, bool do_center, Geometry *gm) font->setColor(sd->getColor()); X11::clearWindow(_status_wo->getWindow()); font->draw(_status_wo, - (width - font->getWidth(text)) / 2, + sd->getPad(PAD_LEFT), sd->getPad(PAD_UP), text.c_str()); } diff --git a/src/tk/Theme.cc b/src/tk/Theme.cc index 1b4dfd2a..c6eace2c 100644 --- a/src/tk/Theme.cc +++ b/src/tk/Theme.cc @@ -53,19 +53,19 @@ static void parse_pad(const std::string& str, int *pad) static void calculate_pad_adapt(const int height_available, PFont* font, int& pad_up, int& pad_down) { - if (height_available == 0) { - pad_up = 0; - pad_down = 0; + float height = font->getHeight(); + if (height_available < font->getHeight()) { + // Keep user settings if we can't adjust height + return; + } + + float pad = height_available - height; + if (font->useAscentDescent()) { + pad_up = pad / (height / font->getAscent()); + pad_down = pad / (height / font->getDescent()); } else { - float height = font->getHeight(); - float pad = height_available - height; - if (font->useAscentDescent()) { - pad_up = pad / (height / font->getAscent()); - pad_down = pad / (height / font->getDescent()); - } else { - pad_up = pad / 2; - pad_down = pad / 2; - } + pad_up = pad / 2; + pad_down = pad / 2; } } @@ -701,7 +701,7 @@ Theme::PMenuData::load(CfgParser::Entry *section) if (pad_adapt) { PFont* font = _font[OBJECT_STATE_FOCUSED]; - calculate_pad_adapt(font->getHeight(), font, + calculate_pad_adapt(font->getHeight() + _pad[PAD_UP] + _pad[PAD_DOWN], font, _pad[PAD_UP], _pad[PAD_DOWN]); } @@ -858,7 +858,7 @@ Theme::TextDialogData::load(CfgParser::Entry *section) check(); if (pad_adapt) { - calculate_pad_adapt(_font->getHeight(), _font, + calculate_pad_adapt(_font->getHeight() + _pad[PAD_UP] + _pad[PAD_DOWN], _font, _pad[PAD_UP], _pad[PAD_DOWN]); }