Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
touchscreeneditor.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2024 grorp, Gregor Parzefall <grorp@posteo.de>
4
5#pragma once
6
7#include "touchscreenlayout.h"
8#include "modalMenu.h"
9
10#include <memory>
11#include <unordered_map>
12
14namespace irr::gui
15{
16 class IGUIButton;
17 class IGUIImage;
18}
19
21{
22public:
23 GUITouchscreenLayout(gui::IGUIEnvironment* env,
24 gui::IGUIElement* parent, s32 id,
25 IMenuManager *menumgr, ISimpleTextureSource *tsrc);
27
28 void regenerateGui(v2u32 screensize);
29 void drawMenu();
30 bool OnEvent(const SEvent& event);
31
32protected:
33 std::wstring getLabelByID(s32 id) { return L""; }
34 std::string getNameByID(s32 id) { return ""; }
35
36private:
38
42
43 enum class Mode {
44 Default,
46 Add,
47 };
49
50 std::unordered_map<touch_gui_button_id, std::shared_ptr<gui::IGUIImage>> m_gui_images;
51 // unused if m_mode == Mode::Add
52 std::unordered_map<touch_gui_button_id, v2s32> m_gui_images_target_pos;
53 void clearGUIImages();
54 void regenerateGUIImagesRegular(v2u32 screensize);
55 void regenerateGUIImagesAddMode(v2u32 screensize);
57
58 // interaction state
59 bool m_mouse_down = false;
62
63 // dragging
65 std::vector<core::recti> m_error_rects;
66 void updateDragState(v2u32 screensize, v2s32 mouse_movement);
67
68 // add mode
70 std::vector<std::shared_ptr<gui::IGUIStaticText>> m_add_button_titles;
71
72 // Menu GUI elements
73 std::shared_ptr<gui::IGUIStaticText> m_gui_help_text;
74
75 std::shared_ptr<gui::IGUIButton> m_gui_add_btn;
76 std::shared_ptr<gui::IGUIButton> m_gui_reset_btn;
77 std::shared_ptr<gui::IGUIButton> m_gui_done_btn;
78
79 std::shared_ptr<gui::IGUIButton> m_gui_remove_btn;
80
81 void regenerateMenu(v2u32 screensize);
82};
Definition modalMenu.h:38
Definition touchscreeneditor.h:21
std::shared_ptr< gui::IGUIButton > m_gui_remove_btn
Definition touchscreeneditor.h:79
std::vector< std::shared_ptr< gui::IGUIStaticText > > m_add_button_titles
Definition touchscreeneditor.h:70
std::shared_ptr< gui::IGUIButton > m_gui_done_btn
Definition touchscreeneditor.h:77
ButtonLayout m_add_layout
Definition touchscreeneditor.h:69
void updateDragState(v2u32 screensize, v2s32 mouse_movement)
Definition touchscreeneditor.cpp:261
void drawMenu()
Definition touchscreeneditor.cpp:232
std::wstring getLabelByID(s32 id)
Definition touchscreeneditor.h:33
ISimpleTextureSource * m_tsrc
Definition touchscreeneditor.h:37
std::shared_ptr< gui::IGUIButton > m_gui_add_btn
Definition touchscreeneditor.h:75
v2s32 m_last_mouse_pos
Definition touchscreeneditor.h:60
~GUITouchscreenLayout()
Definition touchscreeneditor.cpp:43
Mode m_mode
Definition touchscreeneditor.h:48
void regenerateGui(v2u32 screensize)
Definition touchscreeneditor.cpp:48
void regenerateMenu(v2u32 screensize)
Definition touchscreeneditor.cpp:185
void regenerateGUIImagesRegular(v2u32 screensize)
Definition touchscreeneditor.cpp:84
std::shared_ptr< gui::IGUIStaticText > m_gui_help_text
Definition touchscreeneditor.h:73
std::shared_ptr< gui::IGUIButton > m_gui_reset_btn
Definition touchscreeneditor.h:76
GUITouchscreenLayout(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id, IMenuManager *menumgr, ISimpleTextureSource *tsrc)
Definition touchscreeneditor.cpp:19
ButtonLayout m_layout
Definition touchscreeneditor.h:39
Mode
Definition touchscreeneditor.h:43
std::vector< core::recti > m_error_rects
Definition touchscreeneditor.h:65
v2u32 m_last_screensize
Definition touchscreeneditor.h:40
touch_gui_button_id m_selected_btn
Definition touchscreeneditor.h:61
bool m_mouse_down
Definition touchscreeneditor.h:59
s32 m_button_size
Definition touchscreeneditor.h:41
std::string getNameByID(s32 id)
Definition touchscreeneditor.h:34
std::unordered_map< touch_gui_button_id, std::shared_ptr< gui::IGUIImage > > m_gui_images
Definition touchscreeneditor.h:50
void clearGUIImages()
Definition touchscreeneditor.cpp:75
bool OnEvent(const SEvent &event)
Definition touchscreeneditor.cpp:286
std::unordered_map< touch_gui_button_id, v2s32 > m_gui_images_target_pos
Definition touchscreeneditor.h:52
void regenerateGUIImagesAddMode(v2u32 screensize)
Definition touchscreeneditor.cpp:111
void interpolateGUIImages()
Definition touchscreeneditor.cpp:137
ButtonLayout m_last_good_layout
Definition touchscreeneditor.h:64
Definition modalMenu.h:27
Definition texturesource.h:25
core::vector2d< s32 > v2s32
Definition irr_v2d.h:13
core::vector2d< u32 > v2u32
Definition irr_v2d.h:14
Definition fontengine.h:17
Definition touchscreenlayout.h:73
touch_gui_button_id
Definition touchscreenlayout.h:24
@ touch_gui_button_id_END
Definition touchscreenlayout.h:52