25 #include <fifechan/sdl/sdlinput.hpp> 26 #include <fifechan/key.hpp> 27 #include <fifechan/focushandler.hpp> 28 #include <fifechan.hpp> 58 m_fcn_gui(new
fcn::Gui()),
60 m_fcn_topcontainer(new
fcn::Container()),
62 m_input(new
fcn::SDLInput()),
67 m_logic_executed(false),
68 m_enabled_console(true),
92 std::vector<GuiFont*>::iterator i =
m_fonts.begin();
101 FL_WARN(
_log,
"FifechanManager, FifechanGUI->getInput == 0 ... discarding events!");
109 case SDL_MOUSEBUTTONDOWN:
111 case SDL_MOUSEBUTTONUP:
132 case SDL_MOUSEMOTION:
162 case SDL_WINDOWEVENT:
212 if( backend ==
"SDL" ) {
216 else if (backend ==
"OpenGL") {
235 std::string fontpath = path;
236 std::string fontglyphs = glyphs;
237 int32_t fontsize = size;
246 if(fontglyphs ==
"") {
252 if( bfs::extension(fontpath) ==
".ttf" || bfs::extension(fontpath) ==
".ttc" ) {
264 std::vector<GuiFont*>::iterator i =
m_fonts.begin();
276 std::vector<GuiFont*>::iterator it =
m_fonts.begin();
306 if(fcnevt.getType() == fcn::KeyEvent::Pressed)
308 else if(fcnevt.getType() == fcn::KeyEvent::Released)
311 FL_WARN(
_log,
LMsg(
"FifechanManager::translateKeyEvent() - ") <<
"Unknown event type: " << fcnevt.getType());
321 int32_t keyval = fcnevt.getKey().getValue();
324 keyevt.
setKey(
Key(static_cast<Key::KeyType>(keyval)));
335 mouseevt.
setX(fcnevt.getX());
336 mouseevt.
setY(fcnevt.getY());
338 switch(fcnevt.getType()) {
339 case fcn::MouseEvent::Pressed:
342 case fcn::MouseEvent::Released:
345 case fcn::MouseEvent::Moved:
348 case fcn::MouseEvent::Clicked:
351 case fcn::MouseEvent::Entered:
354 case fcn::MouseEvent::Exited:
357 case fcn::MouseEvent::Dragged:
360 case fcn::MouseEvent::WheelMovedDown:
363 case fcn::MouseEvent::WheelMovedUp:
370 switch(fcnevt.getButton()) {
371 case fcn::MouseInput::Left:
374 case fcn::MouseInput::Right:
377 case fcn::MouseInput::Middle:
380 case fcn::MouseInput::X1:
383 case fcn::MouseInput::X2:
407 case fcn::Key::LeftAlt:
410 case fcn::Key::RightAlt:
413 case fcn::Key::LeftShift:
416 case fcn::Key::RightShift:
419 case fcn::Key::LeftControl:
422 case fcn::Key::RightControl:
425 case fcn::Key::Backspace:
428 case fcn::Key::Pause:
431 case fcn::Key::Space:
434 case fcn::Key::Escape:
437 case fcn::Key::Delete:
440 case fcn::Key::Insert:
449 case fcn::Key::PageUp:
452 case fcn::Key::PrintScreen:
455 case fcn::Key::PageDown:
503 case fcn::Key::NumLock:
506 case fcn::Key::CapsLock:
509 case fcn::Key::ScrollLock:
512 case fcn::Key::LeftSuper:
515 case fcn::Key::RightSuper:
518 case fcn::Key::AltGr:
530 case fcn::Key::Right:
533 case fcn::Key::Enter:
539 if (value >= 1 && value <= 26) {
541 value = value - 1 +
'a';
542 }
else if (value >=
'A' && value <=
'Z') {
543 value = value -
'A' +
'a';
#define FL_WARN(logger, msg)
KeyEvent translateKeyEvent(const fcn::KeyEvent &evt)
void add(fcn::Widget *widget)
Adds a new widget.
virtual void turn()
Performs the GUI logic and draws the GUI accordingly.
fcn::FocusHandler * m_focushandler
void setKey(const Key &key)
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
virtual void setControlPressed(bool pressed)
Sets control to pressed.
FifechanManager()
Constructor.
virtual void setShiftPressed(bool pressed)
Sets shift to pressed.
void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Resizes the top container.
GuiFont * setDefaultFont(const std::string &path, uint32_t size, const std::string &glyphs)
Set the global font properties.
virtual ~FifechanManager()
Destructor.
static Logger _log(LM_AUDIO)
virtual bool onSdlEvent(SDL_Event &evt)
Called when an SDL event is received from SDL.
virtual void setControlPressed(bool pressed)
Sets control to pressed.
bool isConsoleEnabled() const
Checks if the console is enabled, or not.
virtual void setAltPressed(bool pressed)
Sets alt to pressed.
GuiFont * createFont(const std::string &path="", uint32_t size=0, const std::string &glyphs="")
Gets font with given properties.
virtual void setShiftPressed(bool pressed)
Sets shift to pressed.
bool isTabbingEnabled() const
Checks if tabbing is enabled.
virtual void setMetaPressed(bool pressed)
Sets meta to pressed.
fcn::Container * m_fcn_topcontainer
GuiImageLoader * m_imgloader
SDL True Type Font implementation of Font.
std::vector< GuiFont * > m_fonts
void remove(fcn::Widget *widget)
Removes a widget.
std::set< fcn::Widget * > m_widgets
void releaseFont(GuiFont *font)
Releases given font.
void setNumericPad(bool ispad)
void setButton(MouseButtonType type)
virtual void setMetaPressed(bool pressed)
Sets meta to pressed.
fcn::Graphics * m_gui_graphics
void setType(KeyEventType type)
void init(const std::string &backend, int32_t screenWidth, int32_t screenHeight)
Inits the Fifechan GUI Manager.
Pure abstract Font interface.
Overrides Fifechan Graphics to enable usage of normal fife images & related facilities.
void setConsoleEnabled(bool console)
Enables the console, or not.
Imagefont that is able to read glyphs from single image sheet, see e.g.
MouseEvent translateMouseEvent(const fcn::MouseEvent &evt)
static int32_t convertFifechanKeyToFifeKey(int32_t value)
void setType(MouseEventType type)
void reLayout()
Layouts the console to match e.g.
virtual void setAltPressed(bool pressed)
Sets alt to pressed.
fcn::Gui * getFifechanGUI() const
Gets the member pointer to the Fifechan GUI.
void setTabbingEnabled(bool tabbing)
Sets tabbing enabled, or not.
Overrides Fifechan Graphics to enable usage of normal fife images & related facilities.