From 00cca1284fb436afd43b0569d56302f7c78e3d8d Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sat, 24 Jan 2015 10:31:38 +0100 Subject: Fix text rendering in rotated TextButtons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A vertically rotated text should be checked against the height of the button, not the width of it. Fixes #1119 ("Toolbar cannot display full text of workspace/​clock/​window title.") --- src/FbTk/TextButton.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc index 98cd4ce..4d05ecd 100644 --- a/src/FbTk/TextButton.cc +++ b/src/FbTk/TextButton.cc @@ -23,7 +23,6 @@ #include "TextUtils.hh" #include "Font.hh" #include "GContext.hh" -#include namespace FbTk { @@ -123,21 +122,29 @@ void TextButton::drawText(int x_offset, int y_offset, FbDrawable *drawable) { if (drawable == 0) drawable = this; + const FbString& visual = text().visual(); unsigned int textlen = visual.size(); unsigned int button_width = width(); unsigned int button_height = height(); - const int max_width = static_cast(button_width) - x_offset - - m_left_padding - m_right_padding; + int padding = m_left_padding + m_right_padding; + + int n_pixels = static_cast(button_width) - x_offset; + if (m_orientation == ROT90 || m_orientation == ROT270) { + n_pixels = static_cast(button_height) - y_offset; + } + n_pixels -= padding; - if (max_width <= bevel()) { + // text is to small to render + if (n_pixels <= bevel()) { return; } + translateSize(m_orientation, button_width, button_height); // horizontal alignment, cut off text if needed - int align_x = FbTk::doAlignment(max_width, + int align_x = FbTk::doAlignment(n_pixels, bevel(), justify(), font(), visual.data(), visual.size(), textlen); // return new text len -- cgit v0.11.2