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 IGUIImage;
17}
18
20{
21public:
22 GUITouchscreenLayout(gui::IGUIEnvironment* env,
23 gui::IGUIElement* parent, s32 id,
24 IMenuManager *menumgr, ISimpleTextureSource *tsrc);
26
27 void regenerateGui(v2u32 screensize);
28 void drawMenu();
29 bool OnEvent(const SEvent& event);
30
31protected:
32 std::wstring getLabelByID(s32 id) { return L""; }
33 std::string getNameByID(s32 id) { return ""; }
34
35private:
37
41
42 enum class Mode {
43 Default,
45 Add,
46 };
48
49 std::unordered_map<touch_gui_button_id, std::shared_ptr<gui::IGUIImage>> m_gui_images;
50 // unused if m_mode == Mode::Add
51 std::unordered_map<touch_gui_button_id, v2s32> m_gui_images_target_pos;
52 void clearGUIImages();
53 void regenerateGUIImagesRegular(v2u32 screensize);
54 void regenerateGUIImagesAddMode(v2u32 screensize);
56
57 // interaction state
58 bool m_mouse_down = false;
61
62 // dragging
64 std::vector<core::recti> m_error_rects;
65 void updateDragState(v2u32 screensize, v2s32 mouse_movement);
66
67 // add mode
69 std::vector<std::shared_ptr<gui::IGUIStaticText>> m_add_button_titles;
70
71 // Menu GUI elements
72 std::shared_ptr<gui::IGUIStaticText> m_gui_help_text;
73
74 std::shared_ptr<gui::IGUIButton> m_gui_add_btn;
75 std::shared_ptr<gui::IGUIButton> m_gui_reset_btn;
76 std::shared_ptr<gui::IGUIButton> m_gui_done_btn;
77
78 std::shared_ptr<gui::IGUIButton> m_gui_remove_btn;
79
80 void regenerateMenu(v2u32 screensize);
81};
Definition modalMenu.h:36
Definition touchscreeneditor.h:20
std::shared_ptr< gui::IGUIButton > m_gui_remove_btn
Definition touchscreeneditor.h:78
std::vector< std::shared_ptr< gui::IGUIStaticText > > m_add_button_titles
Definition touchscreeneditor.h:69
std::shared_ptr< gui::IGUIButton > m_gui_done_btn
Definition touchscreeneditor.h:76
ButtonLayout m_add_layout
Definition touchscreeneditor.h:68
void updateDragState(v2u32 screensize, v2s32 mouse_movement)
Definition touchscreeneditor.cpp:264
void drawMenu()
Definition touchscreeneditor.cpp:235
std::wstring getLabelByID(s32 id)
Definition touchscreeneditor.h:32
ISimpleTextureSource * m_tsrc
Definition touchscreeneditor.h:36
std::shared_ptr< gui::IGUIButton > m_gui_add_btn
Definition touchscreeneditor.h:74
v2s32 m_last_mouse_pos
Definition touchscreeneditor.h:59
~GUITouchscreenLayout()
Definition touchscreeneditor.cpp:46
Mode m_mode
Definition touchscreeneditor.h:47
void regenerateGui(v2u32 screensize)
Definition touchscreeneditor.cpp:51
void regenerateMenu(v2u32 screensize)
Definition touchscreeneditor.cpp:188
void regenerateGUIImagesRegular(v2u32 screensize)
Definition touchscreeneditor.cpp:87
std::shared_ptr< gui::IGUIStaticText > m_gui_help_text
Definition touchscreeneditor.h:72
std::shared_ptr< gui::IGUIButton > m_gui_reset_btn
Definition touchscreeneditor.h:75
GUITouchscreenLayout(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id, IMenuManager *menumgr, ISimpleTextureSource *tsrc)
Definition touchscreeneditor.cpp:19
ButtonLayout m_layout
Definition touchscreeneditor.h:38
Mode
Definition touchscreeneditor.h:42
std::vector< core::recti > m_error_rects
Definition touchscreeneditor.h:64
v2u32 m_last_screensize
Definition touchscreeneditor.h:39
touch_gui_button_id m_selected_btn
Definition touchscreeneditor.h:60
bool m_mouse_down
Definition touchscreeneditor.h:58
s32 m_button_size
Definition touchscreeneditor.h:40
std::string getNameByID(s32 id)
Definition touchscreeneditor.h:33
std::unordered_map< touch_gui_button_id, std::shared_ptr< gui::IGUIImage > > m_gui_images
Definition touchscreeneditor.h:49
void clearGUIImages()
Definition touchscreeneditor.cpp:78
bool OnEvent(const SEvent &event)
Definition touchscreeneditor.cpp:289
std::unordered_map< touch_gui_button_id, v2s32 > m_gui_images_target_pos
Definition touchscreeneditor.h:51
void regenerateGUIImagesAddMode(v2u32 screensize)
Definition touchscreeneditor.cpp:114
void interpolateGUIImages()
Definition touchscreeneditor.cpp:140
ButtonLayout m_last_good_layout
Definition touchscreeneditor.h:63
Definition modalMenu.h:25
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:14
Definition touchscreenlayout.h:73
touch_gui_button_id
Definition touchscreenlayout.h:24
@ touch_gui_button_id_END
Definition touchscreenlayout.h:52