/
FavouritesBrowser.h
87 lines (69 loc) · 2.02 KB
/
FavouritesBrowser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#pragma once
#include "imodule.h"
#include "icommandsystem.h"
#include "idecltypes.h"
#include <wx/listctrl.h>
#include <wx/imaglist.h>
#include <wx/toolbar.h>
#include <sigc++/connection.h>
#include "wxutil/menu/PopupMenu.h"
namespace ui
{
class FavouritesBrowser :
public RegisterableModule
{
private:
// Holds the data used to construct the wxListItem
struct FavouriteItem
{
decl::Type type;
std::string fullPath;
};
wxFrame* _tempParent;
wxWindow* _mainWidget;
wxListView* _listView;
std::unique_ptr<wxImageList> _iconList;
struct FavouriteCategory
{
decl::Type type;
std::string displayName;
std::string iconName;
int iconIndex;
wxToolBarToolBase* checkButton;
};
// Maps decl type to icon index
std::list<FavouriteCategory> _categories;
std::list<sigc::connection> changedConnections;
std::list<FavouriteItem> _listItems;
wxCheckBox* _showFullPath;
bool _updateNeeded;
wxutil::PopupMenuPtr _popupMenu;
public:
FavouritesBrowser();
const std::string& getName() const override;
const StringSet& getDependencies() const override;
void initialiseModule(const IApplicationContext& ctx) override;
void shutdownModule() override;
private:
void construct();
wxToolBar* createLeftToolBar();
wxToolBar* createRightToolBar();
void onMainFrameConstructed();
void onFavouritesChanged();
void reloadFavourites();
void setupCategories();
void constructPopupMenu();
void clearItems();
void onRemoveFromFavourite();
void togglePage(const cmd::ArgumentList& args);
void onCategoryToggled(wxCommandEvent& ev);
void onShowFullPathToggled(wxCommandEvent& ev);
void onListCtrlPaint(wxPaintEvent& ev);
void onContextMenu(wxContextMenuEvent& ev);
void onItemActivated(wxListEvent& ev);
// Returns the list of all selected item indices
std::vector<long> getSelectedItems();
void onApplyToSelection();
bool testSingleTextureSelected();
};
}