mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Added method descriptions
This commit is contained in:
parent
6012e0cb45
commit
5bd044521a
@ -17,8 +17,6 @@
|
||||
#include "../windows/CMessage.h"
|
||||
#include "../CMT.h"
|
||||
|
||||
#include <SDL_pixels.h>
|
||||
|
||||
CIntObject::CIntObject(int used_, Point pos_):
|
||||
parent_m(nullptr),
|
||||
parent(parent_m),
|
||||
@ -102,12 +100,12 @@ void CIntObject::deactivate()
|
||||
elem->deactivate();
|
||||
}
|
||||
|
||||
void CIntObject::printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color kolor, SDL_Surface * dst)
|
||||
void CIntObject::printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, const SDL_Color & kolor, SDL_Surface * dst)
|
||||
{
|
||||
graphics->fonts[font]->renderTextCenter(dst, text, kolor, pos.topLeft() + p);
|
||||
}
|
||||
|
||||
void CIntObject::printAtMiddleWBLoc( const std::string & text, const Point &p, EFonts font, int charpr, SDL_Color kolor, SDL_Surface * dst)
|
||||
void CIntObject::printAtMiddleWBLoc( const std::string & text, const Point &p, EFonts font, int charpr, const SDL_Color & kolor, SDL_Surface * dst)
|
||||
{
|
||||
graphics->fonts[font]->renderTextLinesCenter(dst, CMessage::breakText(text, charpr, font), kolor, pos.topLeft() + p);
|
||||
}
|
||||
@ -310,6 +308,3 @@ void WindowBase::close()
|
||||
logGlobal->error("Only top interface must be closed");
|
||||
GH.windows().popWindows(1);
|
||||
}
|
||||
|
||||
IStatusBar::~IStatusBar()
|
||||
{}
|
||||
|
@ -114,8 +114,8 @@ public:
|
||||
|
||||
/// functions for printing text.
|
||||
/// Deprecated. Use CLabel where possible instead
|
||||
void printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, SDL_Color color, SDL_Surface * dst);
|
||||
void printAtMiddleWBLoc(const std::string & text, const Point &p, EFonts font, int charsPerLine, SDL_Color color, SDL_Surface * dst);
|
||||
void printAtMiddleLoc(const std::string & text, const Point &p, EFonts font, const SDL_Color & color, SDL_Surface * dst);
|
||||
void printAtMiddleWBLoc(const std::string & text, const Point &p, EFonts font, int charsPerLine, const SDL_Color & color, SDL_Surface * dst);
|
||||
};
|
||||
|
||||
/// Class for binding keys to left mouse button clicks
|
||||
@ -143,7 +143,7 @@ protected:
|
||||
class IStatusBar
|
||||
{
|
||||
public:
|
||||
virtual ~IStatusBar();
|
||||
virtual ~IStatusBar() = default;
|
||||
|
||||
/// set current text for the status bar
|
||||
virtual void write(const std::string & text) = 0;
|
||||
|
@ -17,11 +17,12 @@ class AEventsReceiver;
|
||||
enum class MouseButton;
|
||||
enum class EShortcut;
|
||||
|
||||
/// Class that receives events from event producers and dispatches it to UI elements that are interested in this event
|
||||
class EventDispatcher
|
||||
{
|
||||
using CIntObjectList = std::list<AEventsReceiver *>;
|
||||
|
||||
//active GUI elements (listening for events
|
||||
/// list of UI elements that are interested in particular event
|
||||
CIntObjectList lclickable;
|
||||
CIntObjectList rclickable;
|
||||
CIntObjectList mclickable;
|
||||
@ -43,22 +44,30 @@ class EventDispatcher
|
||||
void processLists(ui16 activityFlag, std::function<void(CIntObjectList *)> cb);
|
||||
|
||||
public:
|
||||
/// allows to interrupt event handling and abort any subsequent event processing
|
||||
void allowEventHandling(bool enable);
|
||||
|
||||
/// add specified UI element as interested. Uses unnamed enum from AEventsReceiver for activity flags
|
||||
void handleElementActivate(AEventsReceiver * elem, ui16 activityFlag);
|
||||
|
||||
/// removes specified UI element as interested for specified activities
|
||||
void handleElementDeActivate(AEventsReceiver * elem, ui16 activityFlag);
|
||||
|
||||
/// Regular timer event
|
||||
void dispatchTimer(uint32_t msPassed);
|
||||
|
||||
/// Shortcut events (e.g. keyboard keys)
|
||||
void dispatchShortcutPressed(const std::vector<EShortcut> & shortcuts);
|
||||
void dispatchShortcutReleased(const std::vector<EShortcut> & shortcuts);
|
||||
|
||||
/// Mouse events
|
||||
void dispatchMouseButtonPressed(const MouseButton & button, const Point & position);
|
||||
void dispatchMouseButtonReleased(const MouseButton & button, const Point & position);
|
||||
void dispatchMouseScrolled(const Point & distance, const Point & position);
|
||||
void dispatchMouseDoubleClick(const Point & position);
|
||||
void dispatchMouseMoved(const Point & position);
|
||||
|
||||
/// Text input events
|
||||
void dispatchTextInput(const std::string & text);
|
||||
void dispatchTextEditing(const std::string & text);
|
||||
};
|
||||
|
@ -18,21 +18,26 @@ enum class MouseButton;
|
||||
enum class EShortcut;
|
||||
using boost::logic::tribool;
|
||||
|
||||
/// Class that is capable of subscribing and receiving input events
|
||||
/// Acts as base class for all UI elements
|
||||
class AEventsReceiver
|
||||
{
|
||||
friend class EventDispatcher;
|
||||
|
||||
ui16 activeState;
|
||||
bool hoveredState;
|
||||
bool strongInterestState;
|
||||
std::map<MouseButton, bool> currentMouseState;
|
||||
|
||||
bool hoveredState; //for determining if object is hovered
|
||||
bool strongInterestState; //if true - report all mouse movements, if not - only when hovered
|
||||
|
||||
void click(MouseButton btn, tribool down, bool previousState);
|
||||
protected:
|
||||
|
||||
/// If set, UI element will receive all mouse movement events, even those outside this element
|
||||
void setMoveEventStrongInterest(bool on);
|
||||
|
||||
/// Activates particular events for this UI element. Uses unnamed enum from this class
|
||||
void activateEvents(ui16 what);
|
||||
/// Deactivates particular events for this UI element. Uses unnamed enum from this class
|
||||
void deactivateEvents(ui16 what);
|
||||
|
||||
virtual void clickLeft(tribool down, bool previousState) {}
|
||||
@ -58,11 +63,18 @@ public:
|
||||
AEventsReceiver();
|
||||
virtual ~AEventsReceiver() = default;
|
||||
|
||||
// These are the arguments that can be used to determine what kind of input the CIntObject will receive
|
||||
/// These are the arguments that can be used to determine what kind of input UI element will receive
|
||||
enum {LCLICK=1, RCLICK=2, HOVER=4, MOVE=8, KEYBOARD=16, TIME=32, GENERAL=64, WHEEL=128, DOUBLECLICK=256, TEXTINPUT=512, MCLICK=1024, ALL=0xffff};
|
||||
|
||||
/// Returns true if element is currently hovered by mouse
|
||||
bool isHovered() const;
|
||||
|
||||
/// Returns true if element is currently active and may receive events
|
||||
bool isActive() const;
|
||||
|
||||
/// Returns true if particular event(s) is active for this element
|
||||
bool isActive(int flags) const;
|
||||
|
||||
/// Returns true if particular mouse button was pressed when inside this element
|
||||
bool isMouseButtonPressed(MouseButton btn) const;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user