Merge pull request #1 from haganbmj/style_filtering

feat: game/stylesheet filtering
This commit is contained in:
Brendan Hagan
2022-06-20 20:57:49 -04:00
committed by GitHub
11 changed files with 291 additions and 117 deletions
+10
View File
@@ -0,0 +1,10 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.cpp]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
+12 -1
View File
@@ -1,6 +1,17 @@
Magic Set Editor changelog, for the details see `git log`
==============================================================================
FORK: Changes isolated to this fork
------------------------------------------------------------------------------
Features:
* Independently control Export Zoom setting in Preferences Window.
* Center the loaded image by default in the Image Slice Window.
* Add Button to Center the loaded image in the Image Slice Window.
* Add "Created At", "Last Modified At", "Has Notes" columns to card list.
* Add filter box to Game and Stylesheet selection.
------------------------------------------------------------------------------
HEAD: new items added as changes are made
------------------------------------------------------------------------------
+1 -1
View File
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13)
project(magicseteditor VERSION 2.1.3)
project(magicseteditor VERSION 2.2.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
+6
View File
@@ -212,6 +212,10 @@ help:
website:
about:
# New Set Window
search game list control: Filter the game list. Use - to exclude games. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
search stylesheet list control: Filter the stylesheet list. Use - to exclude styles. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
# Cards panel
collapse notes: Hide the card notes box
expand notes: Show the card notes box
@@ -461,6 +465,8 @@ label:
# New set window
game type: &Game type:
style type: &Card style:
search game list : Filter Games
search stylesheet list: Filter Stylesheets
stylesheet not found :
The set you are trying to open uses the stylesheet "%s".
+40 -11
View File
@@ -13,6 +13,12 @@
#include <script/profiler.hpp>
#include <gui/util.hpp>
bool PackageData::contains(QuickFilterPart const& query) const {
if (query.match(_("full_name"), package->full_name)) return true;
if (query.match(_("short_name"), package->short_name)) return true;
return false;
}
// ----------------------------------------------------------------------------- : PackageList
PackageList::PackageList(Window* parent, int id, int direction, bool always_focused)
@@ -23,29 +29,29 @@ PackageList::PackageList(Window* parent, int id, int direction, bool always_focu
}
size_t PackageList::itemCount() const {
return packages.size();
return filtered_packages.size();
}
void PackageList::drawItem(DC& dc, int x, int y, size_t item) {
dc.SetClippingRegion(x+1, y+2, item_size.x-2, item_size.y-2);
PackageData& d = packages.at(item);
PackageDataP& d = filtered_packages.at(item);
RealRect rect(RealPoint(x,y),item_size);
RealPoint pos;
int w, h;
// draw image
if (d.image.Ok()) {
dc.DrawBitmap(d.image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d.image.GetWidth())), y + 3, true);
if (d->image.Ok()) {
dc.DrawBitmap(d->image, x + int(align_delta_x(ALIGN_CENTER, item_size.x, d->image.GetWidth())), y + 3, true);
}
// draw short name
dc.SetFont(wxFont(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_("Arial")));
dc.GetTextExtent(capitalize(d.package->short_name), &w, &h);
dc.GetTextExtent(capitalize(d->package->short_name), &w, &h);
pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
dc.DrawText(capitalize(d.package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110);
dc.DrawText(capitalize(d->package->short_name), max(x+1,(int)pos.x), (int)pos.y + 110);
// draw name
dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
dc.GetTextExtent(d.package->full_name, &w, &h);
dc.GetTextExtent(d->package->full_name, &w, &h);
RealPoint text_pos = align_in_rect(ALIGN_CENTER, RealSize(w,h), rect);
dc.DrawText(d.package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130);
dc.DrawText(d->package->full_name, max(x+1,(int)text_pos.x), (int)text_pos.y + 130);
dc.DestroyClippingRegion();
}
@@ -62,6 +68,9 @@ struct PackageList::ComparePackagePosHint {
void PackageList::showData(const String& pattern) {
// clear
packages.clear();
filtered_packages.clear();
filter.reset();
// find matching packages
vector<PackagedP> matching;
{
@@ -82,19 +91,23 @@ void PackageList::showData(const String& pattern) {
}
// sort list
sort(packages.begin(), packages.end(), ComparePackagePosHint());
// update list
applyFilter();
update();
}
void PackageList::clear() {
packages.clear();
filtered_packages.clear();
filter.reset();
update();
}
void PackageList::select(const String& name, bool send_event) {
for (vector<PackageData>::const_iterator it = packages.begin() ; it != packages.end() ; ++it) {
if (it->package->name() == name) {
subcolumns[0].selection = it - packages.begin();
for (vector<PackageDataP>::const_iterator it = filtered_packages.begin() ; it != filtered_packages.end() ; ++it) {
if (it->get()->package->name() == name) {
subcolumns[0].selection = it - filtered_packages.begin();
update();
if (send_event) {
sendEvent(EVENT_GALLERY_SELECT);
@@ -110,3 +123,19 @@ void PackageList::select(const String& name, bool send_event) {
int PackageList::requiredWidth() const {
return (item_size.x + SPACING) * (int)itemCount();
}
void PackageList::setFilter(const PackageDataFilterP& filter) {
this->filter = filter;
applyFilter();
update();
}
void PackageList::applyFilter() {
this->filtered_packages.clear();
FOR_EACH(p, packages) {
if (!filter || filter->keep(p)) {
filtered_packages.push_back(make_intrusive<PackageData>(p));
}
}
}
+24 -12
View File
@@ -11,8 +11,25 @@
#include <util/prec.hpp>
#include <util/error.hpp>
#include <gui/control/gallery_list.hpp>
#include <data/filter.hpp>
DECLARE_POINTER_TYPE(Packaged);
DECLARE_POINTER_TYPE(PackageData);
// Information about a package
class PackageData : public IntrusivePtrVirtualBase, public IntrusiveFromThis<PackageData> {
public:
PackageData() {};
PackageData(const PackagedP& package, const Bitmap& image) : package(package), image(image) {};
PackagedP package;
Bitmap image;
bool contains(QuickFilterPart const& query) const;
DECLARE_REFLECTION();
};
typedef intrusive_ptr<Filter<PackageData>> PackageDataFilterP;
// ----------------------------------------------------------------------------- : PackageList
@@ -38,7 +55,7 @@ public:
* Throws if the selection is not of type T */
template <typename T>
intrusive_ptr<T> getSelection(bool load_fully = true) const {
intrusive_ptr<T> ret = dynamic_pointer_cast<T>(packages.at(getSelectionId()).package);
intrusive_ptr<T> ret = dynamic_pointer_cast<T>(filtered_packages.at(getSelectionId())->package);
if (!ret) throw InternalError(_("PackageList: Selected package has the wrong type"));
if (load_fully) ret->loadFully();
return ret;
@@ -50,6 +67,8 @@ public:
/// Required width to show all items
int requiredWidth() const;
using GalleryList::column_count;
void setFilter(const PackageDataFilterP& filter);
protected:
/// Draw an item
@@ -58,18 +77,11 @@ protected:
size_t itemCount() const override;
private:
// The default icon to use
// wxIcon default_icon;
// Information about a package
struct PackageData {
PackageData() {}
PackageData(const PackagedP& package, const Bitmap& image) : package(package), image(image) {}
PackagedP package;
Bitmap image;
};
void applyFilter();
struct ComparePackagePosHint;
/// The displayed packages
vector<PackageData> packages;
vector<PackageDataP> filtered_packages;
PackageDataFilterP filter;
};
+73 -13
View File
@@ -26,7 +26,7 @@ SetP new_set_window(Window* parent) {
}
NewSetWindow::NewSetWindow(Window* parent)
: wxDialog(parent, wxID_ANY, _TITLE_("new set"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
: wxDialog(parent, wxID_ANY, _TITLE_("new set"), wxDefaultPosition, wxSize(830,360), wxDEFAULT_DIALOG_STYLE)
{
wxBusyCursor wait;
// init controls
@@ -34,11 +34,26 @@ NewSetWindow::NewSetWindow(Window* parent)
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST, wxHORIZONTAL, false);
wxStaticText* game_text = new wxStaticText(this, ID_GAME_LIST, _LABEL_("game type"));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
game_filter = new FilterCtrl(this, ID_GAME_FILTER, _LABEL_("search game list"), _HELP_("search game list control"));
game_filter->setFilter(game_filter_value);
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
stylesheet_filter->setFilter(stylesheet_filter_value);
// init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(game_text, 0, wxALL, 4);
wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
s2->Add(game_text, 0, wxALL & ~wxLEFT, 4);
s2->AddStretchSpacer();
s2->Add(game_filter, 1, wxALIGN_RIGHT, 4);
s->Add(s2, wxSizerFlags().Expand().Border(wxALL, 6));
s->Add(game_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
s->Add(stylesheet_text, 0, wxALL, 4);
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
s3->Add(stylesheet_text, 0, wxALL & ~wxLEFT, 4);
s3->AddStretchSpacer();
s3->Add(stylesheet_filter, 1, wxALIGN_RIGHT, 4);
s->Add(s3, wxSizerFlags().Expand().Border(wxALL, 6));
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this);
@@ -46,7 +61,7 @@ NewSetWindow::NewSetWindow(Window* parent)
// Resize
Layout();
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
SetSize(630,min_size.y);
SetSize(830, min_size.y);
// init lists
game_list->showData<Game>();
try {
@@ -69,7 +84,7 @@ void NewSetWindow::onGameSelect(wxCommandEvent&) {
// resize (yuck)
Layout();
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
SetSize(630,min_size.y);
SetSize(830,min_size.y);
}
void NewSetWindow::onStyleSheetSelect(wxCommandEvent&) {
@@ -80,10 +95,33 @@ void NewSetWindow::onStyleSheetSelect(wxCommandEvent&) {
settings.gameSettingsFor(*game).default_stylesheet = stylesheet->name();
UpdateWindowUI(wxUPDATE_UI_RECURSE);
}
void NewSetWindow::onStyleSheetActivate(wxCommandEvent&) {
done();
}
void NewSetWindow::onGameFilterUpdate(wxCommandEvent&) {
if (game_list->hasSelection()) {
GameP existingGameSelection = game_list->getSelection<Game>(false);
game_list->setFilter(game_filter->getFilter<PackageData>());
game_list->select(existingGameSelection->name());
}
else {
game_list->setFilter(game_filter->getFilter<PackageData>());
}
}
void NewSetWindow::onStylesheetFilterUpdate(wxCommandEvent&) {
if (stylesheet_list->hasSelection()) {
StyleSheetP existingStylesheetSelection = stylesheet_list->getSelection<StyleSheet>(false);
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
stylesheet_list->select(existingStylesheetSelection->name());
}
else {
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
}
}
void NewSetWindow::OnOK(wxCommandEvent&) {
done();
}
@@ -117,9 +155,11 @@ void NewSetWindow::onIdle(wxIdleEvent& ev) {
}
BEGIN_EVENT_TABLE(NewSetWindow, wxDialog)
EVT_GALLERY_SELECT (ID_GAME_LIST, NewSetWindow::onGameSelect)
EVT_GALLERY_SELECT (ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetSelect)
EVT_GALLERY_SELECT(ID_GAME_LIST, NewSetWindow::onGameSelect)
EVT_GALLERY_SELECT(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetSelect)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, NewSetWindow::onStyleSheetActivate)
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, NewSetWindow::onStylesheetFilterUpdate)
EVT_COMMAND_RANGE(ID_GAME_FILTER, ID_GAME_FILTER, wxEVT_COMMAND_TEXT_UPDATED, NewSetWindow::onGameFilterUpdate)
EVT_BUTTON (wxID_OK, NewSetWindow::OnOK)
EVT_UPDATE_UI (wxID_ANY, NewSetWindow::onUpdateUI)
EVT_IDLE ( NewSetWindow::onIdle)
@@ -135,18 +175,26 @@ StyleSheetP select_stylesheet(const Game& game, const String& failed_name) {
}
SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game, const String& failed_name)
: wxDialog(parent, wxID_ANY, _TITLE_("select stylesheet"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
: wxDialog(parent, wxID_ANY, _TITLE_("select stylesheet"), wxDefaultPosition, wxSize(830,320), wxDEFAULT_DIALOG_STYLE)
, game(game)
{
wxBusyCursor wait;
// init controls
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST);
wxStaticText* description = new wxStaticText(this, ID_GAME_LIST, _LABEL_1_("stylesheet not found", failed_name));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
stylesheet_filter->setFilter(stylesheet_filter_value);
// init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(description, 0, wxALL, 4);
s->Add(stylesheet_text, 0, wxALL, 4);
s->Add(description, 0, wxALL, 4);
wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
s2->Add(stylesheet_text, 0, wxALL & ~wxLEFT, 4);
s2->AddStretchSpacer();
s2->Add(stylesheet_filter, 1, wxALIGN_RIGHT, 4);
s->Add(s2, wxSizerFlags().Expand().Border(wxALL, 6));
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this);
@@ -157,7 +205,7 @@ SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game,
// Resize
Layout();
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
SetSize(630,min_size.y);
SetSize(830,min_size.y);
UpdateWindowUI(wxUPDATE_UI_RECURSE);
}
@@ -167,6 +215,17 @@ void SelectStyleSheetWindow::onStyleSheetSelect(wxCommandEvent&) {
}
void SelectStyleSheetWindow::onStyleSheetActivate(wxCommandEvent&) {
done();
}
void SelectStyleSheetWindow::onStylesheetFilterUpdate(wxCommandEvent&) {
if (stylesheet_list->hasSelection()) {
StyleSheetP existingStylesheetSelection = stylesheet_list->getSelection<StyleSheet>(false);
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
stylesheet_list->select(existingStylesheetSelection->name());
}
else {
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
}
}
void SelectStyleSheetWindow::OnOK(wxCommandEvent&) {
@@ -198,7 +257,8 @@ void SelectStyleSheetWindow::onIdle(wxIdleEvent& ev) {
BEGIN_EVENT_TABLE(SelectStyleSheetWindow, wxDialog)
EVT_GALLERY_SELECT (ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetSelect)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetActivate)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetActivate)
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, SelectStyleSheetWindow::onStylesheetFilterUpdate)
EVT_BUTTON (wxID_OK, SelectStyleSheetWindow::OnOK)
EVT_UPDATE_UI (wxID_ANY, SelectStyleSheetWindow::onUpdateUI)
EVT_IDLE ( SelectStyleSheetWindow::onIdle)
+15 -2
View File
@@ -9,6 +9,7 @@
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/control/filter_ctrl.hpp>
class PackageList;
class Game;
@@ -34,6 +35,12 @@ private:
// gui items
PackageList* game_list, *stylesheet_list;
FilterCtrl* game_filter;
String game_filter_value;
FilterCtrl* stylesheet_filter;
String stylesheet_filter_value;
// --------------------------------------------------- : events
@@ -41,6 +48,8 @@ private:
void onStyleSheetSelect (wxCommandEvent&);
void onStyleSheetActivate(wxCommandEvent&);
void onStylesheetFilterUpdate(wxCommandEvent&);
void onGameFilterUpdate(wxCommandEvent&);
virtual void OnOK(wxCommandEvent&);
@@ -72,12 +81,16 @@ private:
const Game& game;
// gui items
PackageList* stylesheet_list;
PackageList* stylesheet_list;
FilterCtrl* stylesheet_filter;
String stylesheet_filter_value;
// --------------------------------------------------- : events
void onStyleSheetSelect (wxCommandEvent&);
void onStyleSheetActivate(wxCommandEvent&);
void onStyleSheetActivate(wxCommandEvent&);
void onStylesheetFilterUpdate(wxCommandEvent&);
virtual void OnOK(wxCommandEvent&);
+34 -11
View File
@@ -35,17 +35,25 @@ void StylePanel::initControls() {
list = new PackageList (this, wxID_ANY);
use_for_all = new wxButton (this, ID_STYLE_USE_FOR_ALL, _BUTTON_("use for all cards"));
use_custom_options = new wxCheckBox(this, ID_STYLE_USE_CUSTOM, _BUTTON_("use custom styling options"));
editor = new StylingEditor(this, ID_EDITOR, wxNO_BORDER);
editor = new StylingEditor(this, ID_EDITOR, wxNO_BORDER);
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
stylesheet_filter->setFilter(stylesheet_filter_value);
// init sizer
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
s->Add(preview, 0, wxRIGHT, 2);
wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
s2->Add(use_for_all, 0, wxRIGHT | wxBOTTOM | wxALIGN_RIGHT, 4);
wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("styling options"));
s3->Add(use_custom_options, 0, wxEXPAND | wxALL, 4);
s3->Add(editor, 2, wxEXPAND, 0);
s2->Add(s3, 1, wxEXPAND | wxALL, 2);
s2->Add(list, 0, wxEXPAND | wxBOTTOM, 4);
wxSizer* s3 = new wxBoxSizer(wxHORIZONTAL);
s3->Add(stylesheet_filter, 0, wxBOTTOM | wxALIGN_LEFT, 4);
s3->AddStretchSpacer();
s3->Add(use_for_all, 0, wxBOTTOM | wxALIGN_RIGHT, 4);
s2->Add(s3, wxSizerFlags().Expand().Border(wxALL, 6));
wxSizer* s4 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("styling options"));
s4->Add(use_custom_options, 0, wxEXPAND | wxALL, 4);
s4->Add(editor, 2, wxEXPAND, 0);
s2->Add(s4, 1, wxEXPAND | wxALL, 2);
s->Add(s2, 1, wxEXPAND, 8);
s->SetSizeHints(this);
SetSizer(s);
@@ -62,7 +70,7 @@ void StylePanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
}
void StylePanel::updateListSize() {
if (!isInitialized()) return;
if (!isInitialized() || list_size_already_initialized) return;
// how many columns fit?
size_t fit_columns = (size_t)((GetSize().y - 400) / 152);
// we only need enough columns to show all items
@@ -73,8 +81,11 @@ void StylePanel::updateListSize() {
if (column_count != list->column_count) {
list->column_count = column_count;
static_cast<SetWindow*>(GetParent())->fixMinWindowSize();
}
}
}
list_size_already_initialized = true;
}
bool StylePanel::Layout() {
updateListSize();
return SetWindowPanel::Layout();
@@ -125,6 +136,17 @@ void StylePanel::onAction(const Action& action, bool undone) {
use_for_all->Enable(card && card->stylesheet);
use_custom_options->Enable((bool)card);
use_custom_options->SetValue(card ? card->has_styling : false);
}
void StylePanel::onStylesheetFilterUpdate(wxCommandEvent&) {
if (list->hasSelection()) {
StyleSheetP existingStylesheetSelection = list->getSelection<StyleSheet>(false);
list->setFilter(stylesheet_filter->getFilter<PackageData>());
list->select(existingStylesheetSelection->name());
}
else {
list->setFilter(stylesheet_filter->getFilter<PackageData>());
}
}
// ----------------------------------------------------------------------------- : Selection
@@ -186,7 +208,8 @@ void StylePanel::onUseCustom(wxCommandEvent&) {
}
BEGIN_EVENT_TABLE(StylePanel, wxPanel)
EVT_GALLERY_SELECT(wxID_ANY, StylePanel::onStyleSelect)
EVT_GALLERY_SELECT(wxID_ANY, StylePanel::onStyleSelect)
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, StylePanel::onStylesheetFilterUpdate)
EVT_BUTTON (ID_STYLE_USE_FOR_ALL, StylePanel::onUseForAll)
EVT_CHECKBOX (ID_STYLE_USE_CUSTOM, StylePanel::onUseCustom)
END_EVENT_TABLE()
+72 -66
View File
@@ -1,66 +1,72 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#pragma once
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/set/panel.hpp>
class CardViewer;
class PackageList;
class StylingEditor;
// ----------------------------------------------------------------------------- : StylePanel
/// A panel showing a list of stylesheets, and an editor for styling
class StylePanel : public SetWindowPanel {
public:
StylePanel(Window* parent, int id);
void onChangeSet() override;
void onAction(const Action&, bool undone) override;
// --------------------------------------------------- : UI
void initUI(wxToolBar*, wxMenuBar*) override;
// --------------------------------------------------- : Clipboard
bool canCut() const override;
bool canCopy() const override;
bool canPaste() const override;
bool canSelectAll() const override;
void doCut() override;
void doCopy() override;
void doPaste() override;
void doSelectAll() override;
// --------------------------------------------------- : Selection
void selectCard(const CardP& card) override;
private:
DECLARE_EVENT_TABLE();
CardViewer* preview; ///< Card preview
PackageList* list; ///< List of stylesheets
StylingEditor* editor; ///< Editor for styling information
wxButton* use_for_all;
wxCheckBox* use_custom_options;
CardP card; ///< Card we are working on
void onStyleSelect(wxCommandEvent&);
void onUseForAll(wxCommandEvent&);
void onUseCustom(wxCommandEvent&);
/// Determine the best size for the list of stylesheets based on available space
void updateListSize();
bool Layout() override;
/// Actual intialization of the controls
void initControls();
};
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) Twan van Laarhoven and the other MSE developers |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#pragma once
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/set/panel.hpp>
#include <gui/control/filter_ctrl.hpp>
class CardViewer;
class PackageList;
class StylingEditor;
// ----------------------------------------------------------------------------- : StylePanel
/// A panel showing a list of stylesheets, and an editor for styling
class StylePanel : public SetWindowPanel {
public:
StylePanel(Window* parent, int id);
void onChangeSet() override;
void onAction(const Action&, bool undone) override;
// --------------------------------------------------- : UI
void initUI(wxToolBar*, wxMenuBar*) override;
// --------------------------------------------------- : Clipboard
bool canCut() const override;
bool canCopy() const override;
bool canPaste() const override;
bool canSelectAll() const override;
void doCut() override;
void doCopy() override;
void doPaste() override;
void doSelectAll() override;
// --------------------------------------------------- : Selection
void selectCard(const CardP& card) override;
private:
DECLARE_EVENT_TABLE();
CardViewer* preview; ///< Card preview
PackageList* list; ///< List of stylesheets
StylingEditor* editor; ///< Editor for styling information
wxButton* use_for_all;
wxCheckBox* use_custom_options;
FilterCtrl* stylesheet_filter;
String stylesheet_filter_value;
CardP card; ///< Card we are working on
bool list_size_already_initialized = false;
void onStyleSelect(wxCommandEvent&);
void onUseForAll(wxCommandEvent&);
void onUseCustom(wxCommandEvent&);
void onStylesheetFilterUpdate(wxCommandEvent&);
/// Determine the best size for the list of stylesheets based on available space
void updateListSize();
bool Layout() override;
/// Actual intialization of the controls
void initControls();
};
+4
View File
@@ -227,6 +227,10 @@ enum ControlID {
ID_CONTROL_MIN = 1000,
ID_CONTROL_MAX = 1999,
// New Set Window
ID_STYLESHEET_FILTER,
ID_GAME_FILTER,
// Controls
ID_VIEWER = 1001,
ID_EDITOR,