aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLajos Koszti <ajnasz@ajnasz.hu>2017-08-16 09:42:37 (GMT)
committerLajos Koszti <ajnasz@ajnasz.hu>2017-11-19 19:15:10 (GMT)
commit6e8bf37cc84642815113dcc88fea9fe8c1b8aebc (patch)
tree455181145cafdca752edb3b495d0b142eae8e328
parent7cb7bfaa448003466315ccc21d08b71f5c77df70 (diff)
downloadfluxbox-6e8bf37cc84642815113dcc88fea9fe8c1b8aebc.zip
fluxbox-6e8bf37cc84642815113dcc88fea9fe8c1b8aebc.tar.bz2
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
-rw-r--r--src/ButtonTool.cc17
-rw-r--r--src/ButtonTool.hh1
2 files changed, 16 insertions, 2 deletions
diff --git a/src/ButtonTool.cc b/src/ButtonTool.cc
index 746549f..5f9aec1 100644
--- a/src/ButtonTool.cc
+++ b/src/ButtonTool.cc
@@ -51,8 +51,15 @@ void ButtonTool::updateSizing() {
51 btn.setBorderWidth(bw); 51 btn.setBorderWidth(bw);
52 if (FbTk::TextButton *txtBtn = dynamic_cast<FbTk::TextButton*>(&btn)) { 52 if (FbTk::TextButton *txtBtn = dynamic_cast<FbTk::TextButton*>(&btn)) {
53 bw += 2; // extra padding, seems somehow required... 53 bw += 2; // extra padding, seems somehow required...
54 resize(theme()->font().textWidth(txtBtn->text()) + 2*bw, 54
55 theme()->font().height() + 2*bw); 55 unsigned int new_width = theme()->font().textWidth(txtBtn->text()) + 2*bw;
56 unsigned int new_height = theme()->font().height() + 2*bw;
57
58 if (orientation() == FbTk::ROT0 || orientation() == FbTk::ROT180) {
59 resize(new_width, new_height);
60 } else {
61 resize(new_height, new_width);
62 }
56 } 63 }
57} 64}
58 65
@@ -93,3 +100,9 @@ void ButtonTool::renderTheme(int alpha) {
93 btn.clear(); 100 btn.clear();
94} 101}
95 102
103void ButtonTool::setOrientation(FbTk::Orientation orient) {
104 FbTk::Button &btn = static_cast<FbTk::Button &>(window());
105 btn.setOrientation(orient);
106 ToolbarItem::setOrientation(orient);
107}
108
diff --git a/src/ButtonTool.hh b/src/ButtonTool.hh
index ec74618..e5e5026 100644
--- a/src/ButtonTool.hh
+++ b/src/ButtonTool.hh
@@ -39,6 +39,7 @@ public:
39 FbTk::ThemeProxy<ButtonTheme> &theme, 39 FbTk::ThemeProxy<ButtonTheme> &theme,
40 FbTk::ImageControl &img_ctrl); 40 FbTk::ImageControl &img_ctrl);
41 virtual ~ButtonTool(); 41 virtual ~ButtonTool();
42 void setOrientation(FbTk::Orientation orient);
42 43
43protected: 44protected:
44 void renderTheme(int alpha); 45 void renderTheme(int alpha);