summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-10 13:41:10 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-10 13:41:10 +0100
commit275780d3edd1772537822b607cc60875cc9f98f6 (patch)
tree51717c424ccabd1b9c18b48e9c2e53374748e6fd /plugingui
parent96c3915adeb68d1dd913d38431540eb52d43ff74 (diff)
Add cancel button to filebrowser.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/filebrowser.cc26
-rw-r--r--plugingui/filebrowser.h3
2 files changed, 22 insertions, 7 deletions
diff --git a/plugingui/filebrowser.cc b/plugingui/filebrowser.cc
index 127c7f2..36df6ac 100644
--- a/plugingui/filebrowser.cc
+++ b/plugingui/filebrowser.cc
@@ -45,7 +45,13 @@ struct GUI::FileBrowser::private_data {
void *ptr;
};
-void changeDir(void *ptr)
+static void cancel(void *ptr)
+{
+ GUI::FileBrowser *fp = (GUI::FileBrowser *)ptr;
+ fp->hide();
+}
+
+static void changeDir(void *ptr)
{
struct GUI::FileBrowser::private_data *prv =
(struct GUI::FileBrowser::private_data *)ptr;
@@ -110,9 +116,13 @@ GUI::FileBrowser::FileBrowser(GUI::Widget *parent)
prv->listbox = listbox;
listbox->registerDblClickHandler(changeDir, prv);
- btn = new GUI::Button(this);
- btn->setText("Select");
- btn->registerClickHandler(changeDir, prv);
+ btn_sel = new GUI::Button(this);
+ btn_sel->setText("Select");
+ btn_sel->registerClickHandler(changeDir, prv);
+
+ btn_esc = new GUI::Button(this);
+ btn_esc->setText("Cancel");
+ btn_esc->registerClickHandler(cancel, this);
changeDir(prv);
@@ -139,8 +149,12 @@ void GUI::FileBrowser::resize(size_t w, size_t h)
listbox->move(brd, brd);
listbox->resize(w - 1 - 2*brd, h - btn_h - 3*brd);
- btn->move(brd, h - btn_h - brd);
- btn->resize(w - 1 - 2*brd, btn_h);
+
+ btn_esc->move(brd, h - btn_h - brd);
+ btn_esc->resize((w - 1 - 2*brd) / 2, btn_h);
+
+ btn_sel->move(brd + w / 2, h - btn_h - brd);
+ btn_sel->resize((w - 1 - 2*brd) / 2, btn_h);
}
diff --git a/plugingui/filebrowser.h b/plugingui/filebrowser.h
index e745e7e..011c9d7 100644
--- a/plugingui/filebrowser.h
+++ b/plugingui/filebrowser.h
@@ -56,7 +56,8 @@ private:
struct private_data *prv;
GUI::ListBox *listbox;
- GUI::Button *btn;
+ GUI::Button *btn_sel;
+ GUI::Button *btn_esc;
};
};