summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-16 18:34:54 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-16 18:34:54 +0200
commit93e22693b1fc378c87dd6bf749ac530c19dbc3c5 (patch)
tree97a929e3a6a07d7ca9b5c0249051ce2cf9913327 /plugingui
parent5156131e09669de6f9c2343ebe7dd1bf24bb024b (diff)
Fix bug of ScrollBar where the bar was not shown.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/scrollbar.cc2
-rw-r--r--plugingui/textedit.cc15
2 files changed, 5 insertions, 12 deletions
diff --git a/plugingui/scrollbar.cc b/plugingui/scrollbar.cc
index 32db4a4..d7edd8f 100644
--- a/plugingui/scrollbar.cc
+++ b/plugingui/scrollbar.cc
@@ -135,7 +135,7 @@ void ScrollBar::repaintEvent(RepaintEvent* repaintEvent)
int offset = width() + 2;
int y_val1 = (currentValue * h) / maxValue;
- int y_val2 = ((currentValue + rangeValue) * h) / maxValue;
+ int y_val2 = ((currentValue + rangeValue) * h) / maxValue - 1;
p.drawFilledRectangle(2, y_val1 + offset, width() - 1, y_val2 + offset);
}
diff --git a/plugingui/textedit.cc b/plugingui/textedit.cc
index c91b300..1a13530 100644
--- a/plugingui/textedit.cc
+++ b/plugingui/textedit.cc
@@ -79,17 +79,7 @@ void TextEdit::setText(const std::string& text)
_text = text;
preprocessText();
-
- int ran = height() / font.textHeight();
-
- DEBUG(textedit, "Setting range and max of scrollbar to '%d' and '%d'\n",
- ran, (int)preprocessedtext.size());
-
- scroll.setRange(ran);
- scroll.setMaximum(preprocessedtext.size());
-
redraw();
-
textChangedNotifier();
}
@@ -155,9 +145,12 @@ void TextEdit::preprocessText()
void TextEdit::repaintEvent(RepaintEvent* repaintEvent)
{
Painter p(*this);
-
p.clear();
+ // update values of scroll bar
+ scroll.setRange(height() / font.textHeight());
+ scroll.setMaximum(preprocessedtext.size());
+
int w = width();
int h = height();
if((w == 0) || (h == 0))