Skip to content

Commit

Permalink
Fix tolua "virtuality" of gcn::Widget::setFont.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Feb 28, 2024
1 parent 34ec4cb commit 7a921e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/include/widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void setBackgroundColor(gcn::Widget *, const gcn::Color &);
void setBaseColor(gcn::Widget *, const gcn::Color &color);
void setDirty(gcn::Widget *, bool isDirty);
void setDisabledColor(gcn::Widget *, const gcn::Color &);
void setFont(gcn::Widget *widget, gcn::Font *font);
void setHotKey(gcn::Widget *, const char *key);
void scrollToBottom(gcn::ScrollArea *);
void scrollToTop(gcn::ScrollArea *);
Expand Down
2 changes: 1 addition & 1 deletion src/tolua/ui.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class Widget
tolua_outside virtual void setDisabledColor @ setDisabledColor(const Color color);

static void setGlobalFont(CFont *font);
void setFont(CFont *font);
tolua_outside virtual void setFont @ setFont(CFont *font);

virtual int getHotKey() const;
virtual void setHotKey(const int key);
Expand Down
13 changes: 13 additions & 0 deletions src/ui/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ void setBackgroundColor(gcn::Widget *widget, const gcn::Color &color)
}
}

void setFont(gcn::Widget *widget, gcn::Font *font)
{
// gcn::Widget::setFont is no longer virtual
// so dispatch manually :-/

if (auto w = dynamic_cast<ImageDropDownWidget *>(widget)) {
w->setFont(font);
} else if (auto w = dynamic_cast<gcn::DropDown *>(widget)) {
w->setFont(font);
} else {
widget->setFont(font);
}
}

static void MenuHandleMouseMove(const PixelPos &screenPos)
{
Expand Down

0 comments on commit 7a921e2

Please sign in to comment.