mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Multiple choice box kept open until mouse out
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@505 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -227,13 +227,14 @@ void DropDownChoiceList::onShow() {
|
||||
generateThumbnailImages();
|
||||
}
|
||||
|
||||
void DropDownChoiceList::select(size_t item) {
|
||||
bool DropDownChoiceList::select(size_t item) {
|
||||
if (isFieldDefault(item)) {
|
||||
dynamic_cast<ChoiceValueEditor&>(cve).change( Defaultable<String>() );
|
||||
} else {
|
||||
ChoiceField::ChoiceP choice = getChoice(item);
|
||||
dynamic_cast<ChoiceValueEditor&>(cve).change( field().choices->choiceName(choice->first_id) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t DropDownChoiceList::selection() const {
|
||||
@@ -278,8 +279,6 @@ ChoiceValueEditor::~ChoiceValueEditor() {
|
||||
}
|
||||
|
||||
bool ChoiceValueEditor::onLeftDown(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
//HACK TODO REMOVEME
|
||||
//thumbnail_thread.abortAll();
|
||||
return drop_down->onMouseInParent(ev, style().popup_style == POPUP_DROPDOWN_IN_PLACE && !nativeLook());
|
||||
}
|
||||
bool ChoiceValueEditor::onChar(wxKeyEvent& ev) {
|
||||
|
||||
@@ -95,7 +95,7 @@ class DropDownChoiceList : public DropDownChoiceListBase {
|
||||
|
||||
protected:
|
||||
virtual void onShow();
|
||||
virtual void select(size_t item);
|
||||
virtual bool select(size_t item);
|
||||
virtual size_t selection() const;
|
||||
virtual DropDownList* createSubMenu(ChoiceField::ChoiceP group) const;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ class DropDownColorList : public DropDownList {
|
||||
virtual String itemText(size_t item) const;
|
||||
virtual void drawIcon(DC& dc, int x, int y, size_t item, bool selected) const;
|
||||
|
||||
virtual void select(size_t item);
|
||||
virtual bool select(size_t item);
|
||||
virtual size_t selection() const;
|
||||
|
||||
private:
|
||||
@@ -112,7 +112,7 @@ size_t DropDownColorList::selection() const {
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
void DropDownColorList::select(size_t item) {
|
||||
bool DropDownColorList::select(size_t item) {
|
||||
if (isDefault(item)) {
|
||||
cve.change( Defaultable<Color>());
|
||||
} else if (isCustom(item)) {
|
||||
@@ -120,6 +120,7 @@ void DropDownColorList::select(size_t item) {
|
||||
} else {
|
||||
cve.change(field().choices[item - hasDefault()]->color);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ColorValueEditor
|
||||
|
||||
@@ -19,20 +19,26 @@ class DropDownMultipleChoiceList : public DropDownChoiceListBase {
|
||||
DropDownMultipleChoiceList(Window* parent, bool is_submenu, ValueViewer& cve, ChoiceField::ChoiceP group);
|
||||
|
||||
protected:
|
||||
virtual void select(size_t item);
|
||||
virtual void onShow();
|
||||
virtual bool select(size_t item);
|
||||
virtual size_t selection() const;
|
||||
virtual DropDownList* createSubMenu(ChoiceField::ChoiceP group) const;
|
||||
virtual void drawIcon(DC& dc, int x, int y, size_t item, bool selected) const;
|
||||
|
||||
virtual void onMotion(wxMouseEvent&);
|
||||
private:
|
||||
bool kept_open; ///< Was the list kept open after selecting a choice, if so, be eager to close it
|
||||
};
|
||||
|
||||
DropDownMultipleChoiceList::DropDownMultipleChoiceList
|
||||
(Window* parent, bool is_submenu, ValueViewer& cve, ChoiceField::ChoiceP group)
|
||||
: DropDownChoiceListBase(parent, is_submenu, cve, group)
|
||||
, kept_open(false)
|
||||
{
|
||||
icon_size.width += 16;
|
||||
}
|
||||
|
||||
void DropDownMultipleChoiceList::select(size_t item) {
|
||||
bool DropDownMultipleChoiceList::select(size_t item) {
|
||||
MultipleChoiceValueEditor& mcve = dynamic_cast<MultipleChoiceValueEditor&>(cve);
|
||||
if (isFieldDefault(item)) {
|
||||
mcve.toggleDefault();
|
||||
@@ -40,6 +46,10 @@ void DropDownMultipleChoiceList::select(size_t item) {
|
||||
ChoiceField::ChoiceP choice = getChoice(item);
|
||||
mcve.toggle(choice->first_id);
|
||||
}
|
||||
// keep the box open
|
||||
DropDownChoiceListBase::onShow(); // update 'enabled'
|
||||
kept_open = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, bool selected) const {
|
||||
@@ -67,17 +77,31 @@ void DropDownMultipleChoiceList::drawIcon(DC& dc, int x, int y, size_t item, boo
|
||||
DropDownChoiceListBase::drawIcon(dc, x + 16, y, item, selected);
|
||||
}
|
||||
|
||||
size_t DropDownMultipleChoiceList::selection() const {
|
||||
void DropDownMultipleChoiceList::onShow() {
|
||||
DropDownChoiceListBase::onShow();
|
||||
// we need thumbnail images soon
|
||||
const_cast<DropDownMultipleChoiceList*>(this)->generateThumbnailImages();
|
||||
// we don't know the selection
|
||||
return NO_SELECTION;
|
||||
kept_open = false;
|
||||
}
|
||||
|
||||
size_t DropDownMultipleChoiceList::selection() const {
|
||||
return NO_SELECTION; // we don't know the selection
|
||||
}
|
||||
|
||||
DropDownList* DropDownMultipleChoiceList::createSubMenu(ChoiceField::ChoiceP group) const {
|
||||
return new DropDownMultipleChoiceList(const_cast<DropDownMultipleChoiceList*>(this), true, cve, group);
|
||||
}
|
||||
|
||||
void DropDownMultipleChoiceList::onMotion(wxMouseEvent& ev) {
|
||||
if (kept_open) {
|
||||
wxSize cs = GetClientSize();
|
||||
if (ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y) {
|
||||
hide(false); // outside box; hide it
|
||||
}
|
||||
}
|
||||
DropDownChoiceListBase::onMotion(ev);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : MultipleChoiceValueEditor
|
||||
|
||||
IMPLEMENT_VALUE_EDITOR(MultipleChoice) {}
|
||||
|
||||
Reference in New Issue
Block a user