Skip to content

Commit

Permalink
Use #if USING_TOLUAPP in widgets.h/cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed May 20, 2024
1 parent 24a001a commit 025e9a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/include/widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void initGuichan();
void freeGuichan();
void handleInput(const SDL_Event *event);

#if 1 // ToLua++
#if USING_TOLUAPP
void addActionListener(gcn::Widget *, gcn::ActionListener *);
void setBackgroundColor(gcn::Widget *, const gcn::Color &);
void setBaseColor(gcn::Widget *, const gcn::Color &color);
Expand Down Expand Up @@ -102,7 +102,8 @@ class ButtonWidget : public gcn::Button
public:
explicit ButtonWidget(const std::string &caption) : Button(caption)
{
::setHotKey(this, caption.c_str());
gcn::Key key = GetHotKey(caption);
setHotKey(key.getValue());
}
};

Expand Down
44 changes: 24 additions & 20 deletions src/ui/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ static std::stack<MenuScreen *> MenuStack;
-- Functions
----------------------------------------------------------------------------*/

#if USING_TOLUAPP

void addActionListener(gcn::Widget *widget, gcn::ActionListener *actionListener)
{
// gcn::Widget::addActionListener is no longer virtual
Expand Down Expand Up @@ -129,6 +131,28 @@ void setFont(gcn::Widget *widget, gcn::Font *font)
}
}

void setHotKey(gcn::Widget* widget, const char *keyStr)
{
if (widget && keyStr) {
gcn::Key key = GetHotKey(keyStr);
widget->setHotKey(key.getValue());
}
}

void scrollToBottom(gcn::ScrollArea *scrollArea)
{
Assert(scrollArea);
scrollArea->setVerticalScrollAmount(scrollArea->getVerticalMaxScroll());
}

void scrollToTop(gcn::ScrollArea *scrollArea)
{
Assert(scrollArea);
scrollArea->setVerticalScrollAmount(0);
}

#endif

static void MenuHandleMouseMove(const PixelPos &screenPos)
{
PixelPos pos(screenPos);
Expand Down Expand Up @@ -224,26 +248,6 @@ void DrawGuichanWidgets()
}
}

void setHotKey(gcn::Widget* widget, const char *keyStr)
{
if (widget && keyStr) {
gcn::Key key = GetHotKey(keyStr);
widget->setHotKey(key.getValue());
}
}

void scrollToBottom(gcn::ScrollArea *scrollArea)
{
Assert(scrollArea);
scrollArea->setVerticalScrollAmount(scrollArea->getVerticalMaxScroll());
}

void scrollToTop(gcn::ScrollArea *scrollArea)
{
Assert(scrollArea);
scrollArea->setVerticalScrollAmount(0);
}

/*----------------------------------------------------------------------------
-- LuaActionListener
----------------------------------------------------------------------------*/
Expand Down

0 comments on commit 025e9a5

Please sign in to comment.