commit 77d39b49fa820008dee793a6715a7add31e29bd0
parent f4a67a3cb9d2a2009c0ddd7217ae9f9819d2bc49
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 29 Dec 2015 17:22:14 -0500
mockup for the remote configuration dialog
Diffstat:
13 files changed, 275 insertions(+), 19 deletions(-)
diff --git a/src/dialog.cpp b/src/dialog.cpp
@@ -137,6 +137,11 @@ void Dialog::center()
SetWindowPos(m_handle, HWND_TOP, left, top, 0, 0, SWP_NOSIZE);
}
+void Dialog::setFocus()
+{
+ SetFocus(m_handle);
+}
+
void Dialog::setEnabled(const bool enabled)
{
EnableWindow(m_handle, enabled);
@@ -147,10 +152,6 @@ HWND Dialog::getItem(const int idc)
return GetDlgItem(m_handle, idc);
}
-void Dialog::onInit()
-{
-}
-
void Dialog::onShow()
{
}
diff --git a/src/dialog.hpp b/src/dialog.hpp
@@ -65,6 +65,7 @@ public:
void hide();
void close(const INT_PTR = 0);
void center();
+ void setFocus();
protected:
Dialog(const int templateId);
@@ -72,7 +73,7 @@ protected:
HWND getItem(const int idc);
- virtual void onInit();
+ virtual void onInit() = 0;
virtual void onShow();
virtual void onHide();
virtual void onTimer();
diff --git a/src/listview.cpp b/src/listview.cpp
@@ -0,0 +1,61 @@
+/* ReaPack: Package manager for REAPER
+ * Copyright (C) 2015 Christian Fillion
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "listview.hpp"
+
+using namespace std;
+
+ListView::ListView(const Columns &columns, HWND handle)
+ : m_handle(handle), m_columnSize(0), m_rowSize(0)
+{
+ for(const Column &col : columns)
+ addColumn(col.first, col.second);
+}
+
+void ListView::addColumn(const auto_char *text, const int width)
+{
+ LVCOLUMN col = {0};
+
+ col.mask |= LVCF_WIDTH;
+ col.cx = width;
+
+ col.mask |= LVCF_TEXT;
+ col.pszText = const_cast<auto_char *>(text);
+
+ ListView_InsertColumn(m_handle, m_columnSize++, &col);
+}
+
+void ListView::addRow(const Row &content)
+{
+ LVITEM item = {0};
+ item.iItem = m_rowSize++;
+
+ ListView_InsertItem(m_handle, &item);
+
+ const size_t contentSize = min(m_columnSize, content.size());
+
+ for(size_t i = 0; i < contentSize; i++)
+ ListView_SetItemText(m_handle, item.iItem, i, content[i]);
+}
+
+void ListView::clear()
+{
+ for(size_t i = 0; i < m_rowSize; i++)
+ ListView_DeleteItem(m_handle, 0);
+
+ m_rowSize = 0;
+}
diff --git a/src/listview.hpp b/src/listview.hpp
@@ -0,0 +1,50 @@
+/* ReaPack: Package manager for REAPER
+ * Copyright (C) 2015 Christian Fillion
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef REAPACK_LISTVIEW_HPP
+#define REAPACK_LISTVIEW_HPP
+
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <swell/swell.h>
+#endif
+
+#include <vector>
+
+#include "encoding.hpp"
+
+class ListView {
+public:
+ typedef std::pair<const auto_char *, const int> Column;
+ typedef std::vector<const Column> Columns;
+ typedef std::vector<const auto_char *> Row;
+
+ ListView(const Columns &, HWND handle);
+
+ void addRow(const Row &);
+ void clear();
+
+private:
+ void addColumn(const auto_char *text, const int width);
+
+ HWND m_handle;
+ size_t m_columnSize;
+ size_t m_rowSize;
+};
+
+#endif
diff --git a/src/main.cpp b/src/main.cpp
@@ -42,6 +42,9 @@ static void menuHook(const char *name, HMENU handle, int f)
menu.addAction("Import remote repository...",
NamedCommandLookup("_REAPACK_IMPORT"));
+
+ menu.addAction("Manage remotes...",
+ NamedCommandLookup("_REAPACK_MANAGE"));
}
extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(
@@ -66,6 +69,9 @@ extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(
reapack.setupAction("REAPACK_IMPORT",
bind(&ReaPack::importRemote, reapack));
+ reapack.setupAction("REAPACK_MANAGE",
+ bind(&ReaPack::manageRemotes, reapack));
+
rec->Register("hookcommand", (void *)commandHook);
rec->Register("hookcustommenu", (void *)menuHook);
diff --git a/src/manager.cpp b/src/manager.cpp
@@ -0,0 +1,64 @@
+/* ReaPack: Package manager for REAPER
+ * Copyright (C) 2015 Christian Fillion
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "manager.hpp"
+
+#include "encoding.hpp"
+#include "resource.hpp"
+
+const auto_char *NAME = AUTO_STR("Name");
+const auto_char *URL = AUTO_STR("URL");
+
+Manager::Manager()
+ : Dialog(IDD_CONFIG_DIALOG), m_list(0)
+{
+}
+
+Manager::~Manager()
+{
+ delete m_list;
+}
+
+void Manager::onInit()
+{
+ m_list = new ListView({
+ {AUTO_STR("Name"), 130},
+ {AUTO_STR("URL"), 350},
+ }, getItem(IDC_LIST));
+}
+
+void Manager::onCommand(WPARAM wParam, LPARAM)
+{
+ switch(LOWORD(wParam)) {
+ case IDOK:
+ apply();
+ case IDCANCEL:
+ hide();
+ break;
+ }
+}
+
+void Manager::refresh()
+{
+ m_list->clear();
+ m_list->addRow({"Hello", "http://hello.com/index.xml"});
+ m_list->addRow({"World", "http://world.com/index.xml"});
+}
+
+void Manager::apply()
+{
+}
diff --git a/src/manager.hpp b/src/manager.hpp
@@ -0,0 +1,42 @@
+/* ReaPack: Package manager for REAPER
+ * Copyright (C) 2015 Christian Fillion
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef REAPACK_MANAGER_HPP
+#define REAPACK_MANAGER_HPP
+
+#include "dialog.hpp"
+
+#include "listview.hpp"
+
+class Manager : public Dialog {
+public:
+ Manager();
+ ~Manager();
+
+ void refresh();
+
+protected:
+ void onInit() override;
+ void onCommand(WPARAM, LPARAM) override;
+
+private:
+ void apply();
+
+ ListView *m_list;
+};
+
+#endif
diff --git a/src/progress.cpp b/src/progress.cpp
@@ -57,9 +57,7 @@ void Progress::onInit()
void Progress::onCommand(WPARAM wParam, LPARAM)
{
- const int commandId = LOWORD(wParam);
-
- switch(commandId) {
+ switch(LOWORD(wParam)) {
case IDCANCEL:
if(m_transaction)
m_transaction->cancel();
diff --git a/src/reapack.cpp b/src/reapack.cpp
@@ -18,6 +18,7 @@
#include "reapack.hpp"
#include "config.hpp"
+#include "manager.hpp"
#include "progress.hpp"
#include "report.hpp"
#include "transaction.hpp"
@@ -45,6 +46,7 @@ void ReaPack::init(REAPER_PLUGIN_HINSTANCE instance, reaper_plugin_info_t *rec)
m_config->read(m_resourcePath + "reapack.ini");
m_progress = Dialog::Create<Progress>(m_instance, m_mainWindow);
+ m_manager = Dialog::Create<Manager>(m_instance, m_mainWindow);
}
void ReaPack::cleanup()
@@ -152,6 +154,16 @@ void ReaPack::importRemote()
t->fetch(remote);
}
+void ReaPack::manageRemotes()
+{
+ m_manager->refresh();
+
+ if(m_manager->isVisible())
+ m_manager->setFocus();
+ else
+ m_manager->show();
+}
+
Transaction *ReaPack::createTransaction()
{
if(m_transaction)
diff --git a/src/reapack.hpp b/src/reapack.hpp
@@ -28,8 +28,9 @@
typedef std::function<void()> ActionCallback;
class Config;
-class Transaction;
+class Manager;
class Progress;
+class Transaction;
class ReaPack {
public:
@@ -47,6 +48,7 @@ public:
void synchronize();
void importRemote();
+ void manageRemotes();
private:
Transaction *createTransaction();
@@ -56,6 +58,7 @@ private:
Config *m_config;
Transaction *m_transaction;
Progress *m_progress;
+ Manager *m_manager;
REAPER_PLUGIN_HINSTANCE m_instance;
reaper_plugin_info_t *m_rec;
diff --git a/src/report.cpp b/src/report.cpp
@@ -63,9 +63,7 @@ void Report::onInit()
void Report::onCommand(WPARAM wParam, LPARAM)
{
- const int commandId = LOWORD(wParam);
-
- switch(commandId) {
+ switch(LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
close();
diff --git a/src/resource.hpp b/src/resource.hpp
@@ -20,15 +20,23 @@
#ifndef _WIN32
#define PROGRESS_CLASS "msctls_progress32"
+#define WC_LISTVIEW "SysListView32"
#else
#include <commctrl.h>
#endif
+#define DIALOG_STYLE \
+ DS_MODALFRAME | DS_SHELLFONT | WS_POPUP | WS_SYSMENU | WS_CAPTION
+#define DIALOG_FONT 8, "MS Shell Dlg"
+
#define IDD_PROGRESS_DIALOG 100
-#define IDD_REPORT_DIALOG 101
+#define IDD_REPORT_DIALOG 101
+#define IDD_CONFIG_DIALOG 102
-#define IDC_LABEL 200
+#define IDC_LABEL 200
#define IDC_PROGRESS 201
-#define IDC_REPORT 202
+#define IDC_REPORT 202
+#define IDC_LIST 203
+#define IDC_IMPORT 204
#endif
diff --git a/src/resource.rc b/src/resource.rc
@@ -5,8 +5,8 @@
#endif
IDD_PROGRESS_DIALOG DIALOGEX 0, 0, 260, 80
-STYLE DS_MODALFRAME | DS_SHELLFONT | WS_POPUP | WS_SYSMENU | WS_CAPTION
-FONT 8, "MS Shell Dlg"
+STYLE DIALOG_STYLE
+FONT DIALOG_FONT
BEGIN
LTEXT "File Name", IDC_LABEL, 5, 5, 250, 30
CONTROL "", IDC_PROGRESS, PROGRESS_CLASS, 0x0, 5, 40, 250, 11
@@ -14,12 +14,24 @@ BEGIN
END
IDD_REPORT_DIALOG DIALOGEX 0, 0, 260, 240
-STYLE DS_MODALFRAME | DS_SHELLFONT | WS_POPUP | WS_SYSMENU | WS_CAPTION
+STYLE DIALOG_STYLE
+FONT DIALOG_FONT
CAPTION "ReaPack"
-FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Synchronization complete!", IDC_LABEL, 5, 5, 250, 10
EDITTEXT IDC_REPORT, 6, 18, 248, 195, WS_VSCROLL | ES_MULTILINE |
ES_READONLY | NOT WS_TABSTOP
DEFPUSHBUTTON "OK", IDOK, 105, 220, 50, 14
END
+
+IDD_CONFIG_DIALOG DIALOGEX 0, 0, 300, 180
+STYLE DIALOG_STYLE
+FONT DIALOG_FONT
+CAPTION "ReaPack Configuration"
+BEGIN
+ LTEXT "Enabled remotes:", IDC_LABEL, 5, 5, 290, 10
+ CONTROL "", IDC_LIST, WC_LISTVIEW, LVS_REPORT | WS_BORDER, 5, 18, 290, 130
+ PUSHBUTTON "Import", IDC_IMPORT, 5, 160, 40, 14
+ DEFPUSHBUTTON "OK", IDOK, 210, 160, 40, 14
+ PUSHBUTTON "Cancel", IDCANCEL, 254, 160, 40, 14
+END