commit ceef6a046d1701d81790d7618c06013f83c82546
parent 031c627cf21bca2a1c3758c07ccb18427e34c6a4
Author: cfillion <cfillion@users.noreply.github.com>
Date: Mon, 23 May 2016 16:03:51 -0400
browser: restore actions button
Diffstat:
4 files changed, 42 insertions(+), 15 deletions(-)
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -60,12 +60,14 @@ Browser::Browser(ReaPack *reapack)
void Browser::onInit()
{
- m_apply = getControl(IDAPPLY);
+ m_applyBtn = getControl(IDAPPLY);
m_filterHandle = getControl(IDC_FILTER);
m_tabs = getControl(IDC_TABS);
- m_display = getControl(IDC_DISPLAY);
+ m_displayBtn = getControl(IDC_DISPLAY);
+ m_actionsBtn = getControl(IDC_ACTIONS);
- disable(m_apply);
+ disable(m_applyBtn);
+ disable(m_actionsBtn);
SendMessage(m_tabs, CB_ADDSTRING, 0, (LPARAM)AUTO_STR("All"));
SendMessage(m_tabs, CB_ADDSTRING, 0, (LPARAM)AUTO_STR("Queued"));
@@ -85,6 +87,7 @@ void Browser::onInit()
});
m_list->onActivate([=] { history(m_list->itemUnderMouse()); });
+ m_list->onSelect([=] { setEnabled(m_list->hasSelection(), m_actionsBtn); });
m_list->sortByColumn(1);
updateDisplayLabel();
@@ -121,6 +124,9 @@ void Browser::onCommand(const int id, const int event)
m_list->unselectAll();
SetFocus(m_list->handle());
break;
+ case IDC_ACTIONS:
+ actionsButton();
+ break;
case ACTION_LATEST:
installLatest(m_currentIndex);
break;
@@ -197,9 +203,16 @@ void Browser::onContextMenu(HWND target, const int x, const int y)
SetFocus(m_list->handle());
m_currentIndex = m_list->itemUnderMouse();
- const Entry *entry = getEntry(m_currentIndex);
Menu menu;
+ fillMenu(menu);
+ menu.show(x, y, handle());
+}
+
+void Browser::fillMenu(Menu &menu)
+{
+ const Entry *entry = getEntry(m_currentIndex);
+
if(m_list->selectionSize() > 1) {
menu.addAction(AUTO_STR("&Install/update selection"), ACTION_LATEST_ALL);
@@ -212,7 +225,6 @@ void Browser::onContextMenu(HWND target, const int x, const int y)
if(!entry) {
menu.addAction(AUTO_STR("&Select all"), IDC_SELECT);
menu.addAction(AUTO_STR("&Unselect all"), IDC_UNSELECT);
- menu.show(x, y, handle());
return;
}
@@ -300,8 +312,6 @@ void Browser::onContextMenu(HWND target, const int x, const int y)
auto_snprintf(aboutLabel, auto_size(aboutLabel),
AUTO_STR("&About %s..."), name.c_str());
menu.addAction(aboutLabel, ACTION_ABOUT);
-
- menu.show(x, y, handle());
}
void Browser::updateDisplayLabel()
@@ -314,13 +324,13 @@ void Browser::updateDisplayLabel()
if(m_entries.size() != 1)
btnLabel << AUTO_STR('s');
- SetWindowText(m_display, btnLabel.str().c_str());
+ SetWindowText(m_displayBtn, btnLabel.str().c_str());
}
void Browser::displayButton()
{
RECT rect;
- GetWindowRect(m_display, &rect);
+ GetWindowRect(m_displayBtn, &rect);
static map<const auto_char *, Package::Type> types = {
{AUTO_STR("&Scripts"), Package::ScriptType},
@@ -345,6 +355,18 @@ void Browser::displayButton()
menu.show(rect.left, rect.bottom - 1, handle());
}
+void Browser::actionsButton()
+{
+ RECT rect;
+ GetWindowRect(m_actionsBtn, &rect);
+
+ m_currentIndex = m_list->currentIndex();
+
+ Menu menu;
+ fillMenu(menu);
+ menu.show(rect.left, rect.bottom - 1, handle());
+}
+
bool Browser::isFiltered(Package::Type type) const
{
switch(type) {
@@ -508,7 +530,7 @@ void Browser::transferActions()
}
if(m_actions.empty())
- disable(m_apply);
+ disable(m_applyBtn);
}
auto Browser::makeEntry(const Package *pkg, const Registry::Entry ®Entry)
@@ -831,9 +853,9 @@ void Browser::updateAction(const int index)
m_list->replaceRow(index, makeRow(*entry));
if(m_actions.empty())
- disable(m_apply);
+ disable(m_applyBtn);
else
- enable(m_apply);
+ enable(m_applyBtn);
}
void Browser::selectionDo(const function<void (int)> &func)
@@ -910,7 +932,7 @@ bool Browser::apply()
}
m_actions.clear();
- disable(m_apply);
+ disable(m_applyBtn);
if(!tx->runTasks()) {
// this is an asynchronous transaction
diff --git a/src/browser.hpp b/src/browser.hpp
@@ -108,6 +108,8 @@ private:
Entry *getEntry(int);
void updateDisplayLabel();
void displayButton();
+ void actionsButton();
+ void fillMenu(Menu &);
bool isFiltered(Package::Type) const;
void toggleFiltered(Package::Type);
void setTarget(const int index, const Version *, bool toggle = true);
@@ -143,9 +145,10 @@ private:
HWND m_filterHandle;
HWND m_tabs;
- HWND m_display;
+ HWND m_displayBtn;
+ HWND m_actionsBtn;
ListView *m_list;
- HWND m_apply;
+ HWND m_applyBtn;
};
#endif
diff --git a/src/resource.hpp b/src/resource.hpp
@@ -63,5 +63,6 @@
#define IDC_SELECT 226
#define IDC_UNSELECT 227
#define IDC_OPTIONS 228
+#define IDC_ACTIONS 229
#endif
diff --git a/src/resource.rc b/src/resource.rc
@@ -93,6 +93,7 @@ BEGIN
WS_BORDER | WS_TABSTOP, 5, 22, 490, 204
PUSHBUTTON "&Select all", IDC_SELECT, 5, 230, 50, 14
PUSHBUTTON "&Unselect all", IDC_UNSELECT, 58, 230, 50, 14
+ PUSHBUTTON "&Actions...", IDC_ACTIONS, 111, 230, 45, 14
DEFPUSHBUTTON "&OK", IDOK, 369, 230, 40, 14
PUSHBUTTON "&Cancel", IDCANCEL, 412, 230, 40, 14
PUSHBUTTON "&Apply", IDAPPLY, 455, 230, 40, 14