all repos — fluxbox @ 6e8bf37cc84642815113dcc88fea9fe8c1b8aebc

custom fork of the fluxbox windowmanager

Rotate toolbar button on rotated toolbar

In 393ba45f91480bb10f510248837c6051b7ff6a03 added the possibility to
add custom buttons to the toolbar. However, if the toolbar is rotated
the buttons stays horizontal.
Update the button to rotate the text and update the width/height of the
button if rotated
Lajos Koszti ajnasz@ajnasz.hu
commit

6e8bf37cc84642815113dcc88fea9fe8c1b8aebc

parent

7cb7bfaa448003466315ccc21d08b71f5c77df70

2 files changed, 16 insertions(+), 2 deletions(-)

jump to
M src/ButtonTool.ccsrc/ButtonTool.cc

@@ -51,8 +51,15 @@ int bw = theme()->border().width();

btn.setBorderWidth(bw); if (FbTk::TextButton *txtBtn = dynamic_cast<FbTk::TextButton*>(&btn)) { bw += 2; // extra padding, seems somehow required... - resize(theme()->font().textWidth(txtBtn->text()) + 2*bw, - theme()->font().height() + 2*bw); + + unsigned int new_width = theme()->font().textWidth(txtBtn->text()) + 2*bw; + unsigned int new_height = theme()->font().height() + 2*bw; + + if (orientation() == FbTk::ROT0 || orientation() == FbTk::ROT180) { + resize(new_width, new_height); + } else { + resize(new_height, new_width); + } } }

@@ -93,3 +100,9 @@

btn.clear(); } +void ButtonTool::setOrientation(FbTk::Orientation orient) { + FbTk::Button &btn = static_cast<FbTk::Button &>(window()); + btn.setOrientation(orient); + ToolbarItem::setOrientation(orient); +} +
M src/ButtonTool.hhsrc/ButtonTool.hh

@@ -39,6 +39,7 @@ ButtonTool(FbTk::Button *button, ToolbarItem::Type type,

FbTk::ThemeProxy<ButtonTheme> &theme, FbTk::ImageControl &img_ctrl); virtual ~ButtonTool(); + void setOrientation(FbTk::Orientation orient); protected: void renderTheme(int alpha);