prevent dropdown from closing when moving to parent or child

This commit is contained in:
GenevensiS
2026-04-09 19:30:17 +02:00
parent a99c603ffb
commit 4d1c7aae96
20 changed files with 65 additions and 38 deletions
+2 -2
View File
@@ -61,7 +61,7 @@ IMPLEMENT_REFLECTION(WrappedCards) {
}
wxDataFormat CardsDataObject::format = _("application/x-mse-cards");
wxDataFormat CardsDataObject::format(wxString("application/x-mse-cards"));
CardsDataObject::CardsDataObject(const SetP& set, const String id, const vector<CardP>& cards) {
// set the stylesheet, so when deserializing we know whos style options we are reading
@@ -121,7 +121,7 @@ IMPLEMENT_REFLECTION(WrappedKeyword) {
}
wxDataFormat KeywordDataObject::format = _("application/x-mse-keyword");
wxDataFormat KeywordDataObject::format(wxString("application/x-mse-keyword"));
KeywordDataObject::KeywordDataObject(const SetP& set, const KeywordP& keyword) {
WrappedKeyword data = { set->game.get(), set->game->name(), keyword };
+1 -1
View File
@@ -19,7 +19,7 @@ template <typename T> inline T sqr(T x) { return x * x; }
void linear_blend(Image& img1, const Image& img2, double x1,double y1, double x2,double y2) {
int width = img1.GetWidth(), height = img1.GetHeight();
if (img2.GetWidth() != width || img2.GetHeight() != height) {
throw Error(_ERROR_("images used for blending must have the same size"));
throw Error(_ERROR_1_("blending different sizes", "linear_blend"));
}
const int fixed = 1<<16; // fixed point multiplier
+1 -1
View File
@@ -439,7 +439,7 @@ void combine_image_do(Image& a, Image b) {
void combine_image(Image& a, const Image& b, ImageCombine combine) {
// Images must have same size
if (a.GetWidth() != b.GetWidth() || a.GetHeight() != b.GetHeight()) {
throw Error(_ERROR_("images used for combine blending must have the same size"));
throw Error(_ERROR_1_("blending different sizes", "combine_blend"));
}
// Copy alpha channel?
if (b.HasAlpha()) {
+15 -3
View File
@@ -471,9 +471,13 @@ void DropDownList::onMotion(wxMouseEvent& ev) {
}
void DropDownList::onMouseLeave(wxMouseEvent& ev) {
if (close_on_mouse_out) {
wxSize cs = GetClientSize();
if (ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y) {
if (close_on_mouse_out) {
wxPoint screen_pos = ClientToScreen(ev.GetPosition());
bool in_parent = parent_menu ? parent_menu->isInRect(screen_pos) : false;
bool in_child = open_sub_menu ? open_sub_menu->isInRect(screen_pos) : false;
wxSize cs = GetClientSize();
bool in_self = !(ev.GetX() < 0 || ev.GetY() < 0 || ev.GetX() >= cs.x || ev.GetY() >= cs.y);
if (!(in_parent || in_child || in_self)) {
hide(false); // outside box; hide it
ev.Skip();
return;
@@ -481,6 +485,14 @@ void DropDownList::onMouseLeave(wxMouseEvent& ev) {
}
}
bool DropDownList::isInRect(wxPoint screen_pos) {
wxRect rect = GetRect();
if (screen_pos.x < rect.x || screen_pos.y < rect.y || screen_pos.x > rect.x+rect.width || screen_pos.y > rect.y+rect.height) {
return false;
}
return true;
}
void DropDownList::onMouseWheel(wxMouseEvent& ev) {
scrollTo(visible_start - item_size.height * ev.GetWheelRotation() / ev.GetWheelDelta());
}
+5 -2
View File
@@ -116,9 +116,12 @@ private:
void onMouseLeave(wxMouseEvent&);
void onMouseWheel(wxMouseEvent& ev);
void onScroll(wxScrollWinEvent&);
// --------------------------------------------------- : Privates
/// Is the given screen coordinate inside this menu's rect?
bool isInRect(wxPoint screen_pos);
/// Return the y coordinate of an item (in scrolled coordinates)
int itemPosition(size_t item) const;
+12 -6
View File
@@ -81,22 +81,28 @@ SCRIPT_FUNCTION(set_metadata) {
SCRIPT_FUNCTION(width_of) {
SCRIPT_PARAM(Set*, set);
SCRIPT_PARAM(GeneratedImageP, input);
Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get()));
SCRIPT_PARAM(CardP, card);
SCRIPT_PARAM(GeneratedImageP, input);
StyleSheet* stylesheet = card && card->stylesheet ? card->stylesheet.get() : set->stylesheet.get();
Image image = input->generate(GeneratedImage::Options(0, 0, stylesheet));
SCRIPT_RETURN(image.GetWidth());
}
SCRIPT_FUNCTION(height_of) {
SCRIPT_PARAM(Set*, set);
SCRIPT_PARAM(GeneratedImageP, input);
Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get()));
SCRIPT_PARAM(CardP, card);
SCRIPT_PARAM(GeneratedImageP, input);
StyleSheet* stylesheet = card && card->stylesheet ? card->stylesheet.get() : set->stylesheet.get();
Image image = input->generate(GeneratedImage::Options(0, 0, stylesheet));
SCRIPT_RETURN(image.GetHeight());
}
SCRIPT_FUNCTION(dimensions_of) {
SCRIPT_PARAM(Set*, set);
SCRIPT_PARAM(GeneratedImageP, input);
Image image = input->generate(GeneratedImage::Options(0, 0, set->stylesheet.get()));
SCRIPT_PARAM(CardP, card);
SCRIPT_PARAM(GeneratedImageP, input);
StyleSheet* stylesheet = card && card->stylesheet ? card->stylesheet.get() : set->stylesheet.get();
Image image = input->generate(GeneratedImage::Options(0, 0, stylesheet));
ScriptCustomCollectionP ret(new ScriptCustomCollection());
ret->value.push_back(to_script(image.GetWidth()));
ret->value.push_back(to_script(image.GetHeight()));