mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Layout() always called when editor/viewer control changes size
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@145 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -10,6 +10,10 @@
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <wx/dcbuffer.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
DEFINE_EVENT_TYPE(EVENT_SIZE_CHANGE);
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardViewer
|
||||
|
||||
CardViewer::CardViewer(Window* parent, int id, long style)
|
||||
@@ -30,6 +34,16 @@ void CardViewer::onChange() {
|
||||
up_to_date = false;
|
||||
}
|
||||
|
||||
void CardViewer::onChangeSize() {
|
||||
wxSize ws = GetSize(), cs = GetClientSize();
|
||||
wxSize desired_cs = (wxSize)getRotation().getExternalSize() + ws - cs;
|
||||
if (desired_cs != cs) {
|
||||
wxCommandEvent ev(EVENT_SIZE_CHANGE, GetId());
|
||||
ProcessEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
DECLARE_DYNAMIC_ARG(bool, inOnPaint);
|
||||
IMPLEMENT_DYNAMIC_ARG(bool, inOnPaint, false);
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <render/card/viewer.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
/// Event that indicates the size of a CardViewer has changed
|
||||
DECLARE_EVENT_TYPE(EVENT_SIZE_CHANGE, <not used>)
|
||||
/// Handle EVENT_SIZE_CHANGE events
|
||||
#define EVT_SIZE_CHANGE(id, handler) EVT_COMMAND(id, EVENT_SIZE_CHANGE, handler)
|
||||
|
||||
// ----------------------------------------------------------------------------- : CardViewer
|
||||
|
||||
/// A control to view a single card
|
||||
@@ -28,6 +35,7 @@ class CardViewer : public wxControl, public DataViewer {
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
virtual void onChange();
|
||||
virtual void onChangeSize();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
@@ -196,19 +196,6 @@ bool CardsPanel::wantsToHandle(const Action&, bool undone) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CardsPanel::onAction(const Action& action, bool undone) {
|
||||
TYPE_CASE_(action, DisplayChangeAction) {
|
||||
// The style changed, maybe also the size of editor
|
||||
Layout();
|
||||
//if (current_panel) current_panel->Layout();
|
||||
//fixMinWindowSize();
|
||||
}
|
||||
}
|
||||
|
||||
void CardsPanel::onRenderSettingsChange() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Clipboard
|
||||
|
||||
bool CardsPanel::canCut() const { return focused_control(this) == ID_EDITOR ? editor->canCut() : card_list->canCut(); }
|
||||
|
||||
@@ -37,8 +37,6 @@ class CardsPanel : public SetWindowPanel {
|
||||
// --------------------------------------------------- : Actions
|
||||
|
||||
virtual bool wantsToHandle(const Action&, bool undone) const;
|
||||
virtual void onAction(const Action&, bool undone);
|
||||
virtual void onRenderSettingsChange();
|
||||
public:
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
|
||||
@@ -49,8 +49,6 @@ class SetWindowPanel : public wxPanel, public SetView {
|
||||
virtual bool wantsToHandle(const Action&, bool undone) const { return false; }
|
||||
/// Handle an action that changes the current set
|
||||
virtual void onAction(const Action&, bool undone) {}
|
||||
/// The settings for rendering cards have changed, refresh card viewers/editors
|
||||
virtual void onRenderSettingsChange() {}
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
virtual bool canPaste() const { return false; } ///< Is pasting possible?
|
||||
|
||||
@@ -53,15 +53,13 @@ void StylePanel::onChangeSet() {
|
||||
void StylePanel::onAction(const Action& action, bool undone) {
|
||||
TYPE_CASE_(action, ChangeSetStyleAction) {
|
||||
list->select(set->stylesheetFor(card)->name(), false);
|
||||
// updateSize();
|
||||
}
|
||||
TYPE_CASE(action, ChangeCardStyleAction) {
|
||||
if (action.card == card) {
|
||||
// preview->onAction(action, undone); // update the preview control before we determine our new size
|
||||
list->select(set->stylesheetFor(card)->name(), false);
|
||||
// updateSize();
|
||||
}
|
||||
}
|
||||
use_for_all->Enable(card && card->stylesheet);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Selection
|
||||
|
||||
+10
-9
@@ -14,6 +14,7 @@
|
||||
#include <gui/set/keywords_panel.hpp>
|
||||
#include <gui/set/stats_panel.hpp>
|
||||
#include <gui/control/card_list.hpp>
|
||||
#include <gui/control/card_viewer.hpp>
|
||||
#include <gui/control/gallery_list.hpp>
|
||||
#include <gui/about_window.hpp>
|
||||
#include <gui/update_checker.hpp>
|
||||
@@ -232,11 +233,12 @@ void SetWindow::onChangeSet() {
|
||||
}
|
||||
|
||||
void SetWindow::onAction(const Action& action, bool undone) {
|
||||
TYPE_CASE_(action, DisplayChangeAction) {
|
||||
/* TYPE_CASE_(action, DisplayChangeAction) {
|
||||
// The style changed, maybe also the size of card viewers
|
||||
if (current_panel) current_panel->Layout();
|
||||
fixMinWindowSize();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -244,14 +246,6 @@ void SetWindow::onCardSelect(CardSelectEvent& ev) {
|
||||
FOR_EACH(p, panels) {
|
||||
p->selectCard(ev.card);
|
||||
}
|
||||
fixMinWindowSize();
|
||||
}
|
||||
|
||||
void SetWindow::onRenderSettingsChange() {
|
||||
FOR_EACH(p, panels) {
|
||||
p->onRenderSettingsChange();
|
||||
}
|
||||
fixMinWindowSize();
|
||||
}
|
||||
|
||||
void SetWindow::fixMinWindowSize() {
|
||||
@@ -267,6 +261,12 @@ void SetWindow::fixMinWindowSize() {
|
||||
SetMinSize(minSize);
|
||||
}
|
||||
|
||||
void SetWindow::onSizeChange(wxCommandEvent&) {
|
||||
FOR_EACH(p, panels) {
|
||||
p->Layout();
|
||||
}
|
||||
fixMinWindowSize();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - close
|
||||
|
||||
@@ -603,4 +603,5 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
|
||||
EVT_CLOSE ( SetWindow::onClose)
|
||||
EVT_IDLE ( SetWindow::onIdle)
|
||||
EVT_CARD_SELECT (wxID_ANY, SetWindow::onCardSelect)
|
||||
EVT_SIZE_CHANGE (wxID_ANY, SetWindow::onSizeChange)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
@@ -76,10 +76,7 @@ class SetWindow : public wxFrame, public SetView {
|
||||
private:
|
||||
/// A different card has been selected
|
||||
void onCardSelect(CardSelectEvent&);
|
||||
|
||||
/// Render settings have changed (because of editing of preferences)
|
||||
void onRenderSettingsChange();
|
||||
|
||||
|
||||
// minSize = mainSizer->getMinWindowSize(this)
|
||||
// but wx made that private
|
||||
void fixMinWindowSize();
|
||||
@@ -149,6 +146,8 @@ class SetWindow : public wxFrame, public SetView {
|
||||
void onChildMenu (wxCommandEvent&);
|
||||
|
||||
void onIdle (wxIdleEvent&);
|
||||
|
||||
void onSizeChange (wxCommandEvent&);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -58,6 +58,7 @@ ValueViewer* DataViewer::focusedViewer() const { return nullptr; }
|
||||
Context& DataViewer::getContext() const { return set->getContext(); }
|
||||
|
||||
Rotation DataViewer::getRotation() const {
|
||||
if (!stylesheet) stylesheet = set->stylesheet;
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
|
||||
return Rotation(ss.card_angle(), stylesheet->getCardRect(), ss.card_zoom(), true);
|
||||
}
|
||||
@@ -71,6 +72,7 @@ void DataViewer::setCard(const CardP& card) {
|
||||
stylesheet = set->stylesheetFor(card);
|
||||
setStyles(stylesheet, stylesheet->card_style);
|
||||
setData(card->data);
|
||||
onChangeSize();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Viewers
|
||||
|
||||
@@ -73,14 +73,15 @@ class DataViewer : public SetView {
|
||||
|
||||
/// Notification that the total image has changed
|
||||
virtual void onChange() {}
|
||||
|
||||
/// Notification that the viewers are initialized
|
||||
virtual void onInit() {}
|
||||
/// Notification that the size of the viewer may have changed
|
||||
virtual void onChangeSize() {}
|
||||
|
||||
vector<ValueViewerP> viewers; ///< The viewers for the different values in the data
|
||||
CardP card; ///< The card that is currently displayed, if any
|
||||
public:
|
||||
StyleSheetP stylesheet; ///< Stylesheet being used
|
||||
mutable StyleSheetP stylesheet; ///< Stylesheet being used
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
Reference in New Issue
Block a user