summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-13 21:03:14 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-13 21:03:14 +0100
commit37471a3486a566159bcf0c7ebd68f9064287d0fa (patch)
tree42cc7114a13ff564575bbdd5f9c920f190f079b4
parentb59d65d3c5606b33727cc445555704bb0e203b55 (diff)
Use new painter clear function.
-rw-r--r--plugingui/button.cc4
-rw-r--r--plugingui/checkbox.cc2
-rw-r--r--plugingui/combobox.cc26
-rw-r--r--plugingui/filebrowser.cc31
-rw-r--r--plugingui/knob.cc2
-rw-r--r--plugingui/lineedit.cc2
-rw-r--r--plugingui/listbox.cc23
-rw-r--r--plugingui/window.cc3
8 files changed, 70 insertions, 23 deletions
diff --git a/plugingui/button.cc b/plugingui/button.cc
index b65f318..85d5425 100644
--- a/plugingui/button.cc
+++ b/plugingui/button.cc
@@ -64,7 +64,9 @@ void GUI::Button::repaintEvent(GUI::RepaintEvent *e)
Painter p(this);
- float alpha = 0.8;
+ p.clear();
+
+ float alpha = 0.9;
if(hasKeyboardFocus()) {
p.setColour(Colour(0.6, alpha));
diff --git a/plugingui/checkbox.cc b/plugingui/checkbox.cc
index 5888d3c..da3ce4b 100644
--- a/plugingui/checkbox.cc
+++ b/plugingui/checkbox.cc
@@ -74,6 +74,8 @@ void GUI::CheckBox::repaintEvent(GUI::RepaintEvent *e)
Painter p(this);
+ p.clear();
+
float alpha = 0.8;
int box = width()<height()?width():height();
diff --git a/plugingui/combobox.cc b/plugingui/combobox.cc
index 20779e8..31c81c6 100644
--- a/plugingui/combobox.cc
+++ b/plugingui/combobox.cc
@@ -95,18 +95,30 @@ void GUI::ComboBox::registerValueChangedHandler(void (*handler)(void *),
void GUI::ComboBox::repaintEvent(GUI::RepaintEvent *e)
{
Painter p(this);
-
- int h = 16;
+
+ p.clear();
std::string _text = selectedName();
p.setColour(Colour(0, 0.4));
- p.drawFilledRectangle(3,3,width()-3,h-3);
+ p.drawFilledRectangle(3, 3, width() - 3, height() - 3);
+
+ p.setColour(Colour(1, 1, 1));
+ p.drawRectangle(0, 0, width() - 1, height() - 1);
+
+ p.setColour(Colour(0.6, 0.6, 0.6));
+ p.drawRectangle(2, 2, width() - 3, height() - 3);
+
+ p.setColour(Colour(1, 1, 1));
+ p.drawText(BORDER - 4, (height()+font.textHeight()) / 2 + 1, font, _text);
+
+ p.setColour(Colour(1, 1, 1, 0.8));
+ p.drawRectangle(width() - height() + 1, 1, width() - 2, height() - 2);
- p.setColour(Colour(1,1,1));
- p.drawRectangle(0,0,width()-1,h-1);
- p.drawRectangle(2,2,width()-3,h-3);
- p.drawText(BORDER - 4, h/2+5 + 1, font, _text);
+ int n = height();
+ p.setColour(Colour(1, 1, 1, 1));
+ p.drawLine(width() - n, 1, width() - 1 - n/2, n);
+ p.drawLine(width() - n + n/2, n, width() - 1, 1);
}
void GUI::ComboBox::scrollEvent(ScrollEvent *e)
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index 33ae366..afd6518 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -202,31 +202,36 @@ void GUI::FileBrowser::resize(size_t w, size_t h)
int brd = 5; // border
int btn_h = 18;
- lbl_path.move(0, offset);
- lineedit.move(60, offset);
-
- offset += btn_h;
-
- lbl_path.resize(60, btn_h);
- lineedit.resize(w - 60, btn_h);
-
#ifdef WIN32
+ offset += brd;
+
lbl_drive.move(0, offset);
drv.move(60, offset);
offset += btn_h;
lbl_drive.resize(60, btn_h);
- drv.resize(w - 60, btn_h);
+ drv.resize(w - 60 - brd, btn_h);
#endif
+ offset += brd;
+
+ lbl_path.move(0, offset);
+ lineedit.move(60, offset);
+
+ offset += btn_h;
+
+ lbl_path.resize(60, btn_h);
+ lineedit.resize(w - 60 - brd, btn_h);
+
+ offset += brd;
- listbox.move(brd, brd + offset);
- listbox.resize(w - 1 - 2*brd, h - btn_h - 3*brd - offset);
+ listbox.move(brd, offset);
+ listbox.resize(w - 1 - 2*brd, h - btn_h - 2*brd - offset);
btn_esc.move(brd, h - btn_h - brd);
- btn_esc.resize((w - 1 - 2*brd) / 2, btn_h);
+ btn_esc.resize((w - 1 - 2*brd) / 2 - brd / 2, btn_h);
- btn_sel.move(brd + w / 2, h - btn_h - brd);
+ btn_sel.move(brd + w / 2 - brd / 2, h - btn_h - brd);
btn_sel.resize((w - 1 - 2*brd) / 2, btn_h);
diff --git a/plugingui/knob.cc b/plugingui/knob.cc
index 1a0148f..4516990 100644
--- a/plugingui/knob.cc
+++ b/plugingui/knob.cc
@@ -147,6 +147,8 @@ void GUI::Knob::repaintEvent(GUI::RepaintEvent *e)
{
Painter p(this);
+ p.clear();
+
float alpha = 0.8;
p.setColour(Colour(0, 0));
diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc
index 17174b9..35056a3 100644
--- a/plugingui/lineedit.cc
+++ b/plugingui/lineedit.cc
@@ -133,6 +133,8 @@ void GUI::LineEdit::repaintEvent(GUI::RepaintEvent *e)
{
Painter p(this);
+ p.clear();
+
p.setColour(Colour(0, 0.4));
p.drawFilledRectangle(3,3,width()-3,height()-3);
diff --git a/plugingui/listbox.cc b/plugingui/listbox.cc
index 1ad5860..40f8a2a 100644
--- a/plugingui/listbox.cc
+++ b/plugingui/listbox.cc
@@ -138,6 +138,8 @@ void GUI::ListBox::repaintEvent(GUI::RepaintEvent *e)
{
GUI::Painter p(this);
+ p.clear();
+
p.setColour(Colour(0, 0.7));
p.drawFilledRectangle(0, 0, width() - 1, height() - 1);
@@ -149,7 +151,7 @@ void GUI::ListBox::repaintEvent(GUI::RepaintEvent *e)
for(int idx = skip; idx < (int)items.size(); idx++) {
struct item *i = &items[idx];
if(idx == selected) {
- p.setColour(Colour(1, 0.4));
+ p.setColour(Colour(0.6, 0.9));
p.drawFilledRectangle(1,
yoffset - (padding / 2),
width() - 1,
@@ -253,9 +255,9 @@ void GUI::ListBox::keyEvent(GUI::KeyEvent *e)
void GUI::ListBox::buttonEvent(ButtonEvent *e)
{
- if(e->direction == 1) {
if(e->x > (width() - btn_size) && e->y < (width() - 1)) {
if(e->y > 0 && e->y < btn_size) {
+ if(e->direction == -1) return;
scroll_offset--;
if(scroll_offset < 0) scroll_offset = 0;
repaintEvent(NULL);
@@ -263,6 +265,7 @@ void GUI::ListBox::buttonEvent(ButtonEvent *e)
}
if(e->y > (height() - btn_size) && e->y < (height() - 1)) {
+ if(e->direction == -1) return;
scroll_offset++;
if(scroll_offset > (items.size() - 1))
scroll_offset = (items.size() - 1);
@@ -271,6 +274,8 @@ void GUI::ListBox::buttonEvent(ButtonEvent *e)
}
}
+
+ if(e->direction == -1) {
int skip = scroll_offset;
size_t yoffset = padding / 2;
for(int idx = skip; idx < (int)items.size(); idx++) {
@@ -286,5 +291,19 @@ void GUI::ListBox::buttonEvent(ButtonEvent *e)
repaintEvent(NULL);
}
+ if(e->direction != -1) {
+ int skip = scroll_offset;
+ size_t yoffset = padding / 2;
+ for(int idx = skip; idx < (int)items.size(); idx++) {
+ yoffset += font.textHeight() + padding;
+ if(e->y < (int)yoffset - (padding / 2)) {
+ marked = idx;
+ break;
+ }
+ }
+
+ repaintEvent(NULL);
+ }
+
if(e->doubleclick && sel_handler) sel_handler(sel_ptr);
}
diff --git a/plugingui/window.cc b/plugingui/window.cc
index 1795d62..9e06502 100644
--- a/plugingui/window.cc
+++ b/plugingui/window.cc
@@ -82,6 +82,9 @@ void GUI::Window::setCaption(std::string caption)
void GUI::Window::repaintEvent(GUI::RepaintEvent *e)
{
Painter p(this);
+
+ p.clear();
+
p.drawImage(0, 0, (struct __img__*)&img_back);
}