diff options
Diffstat (limited to 'src/gui/guiFormSpecMenu.h')
-rw-r--r-- | src/gui/guiFormSpecMenu.h | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index 184b26f3c..613acaa04 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventorymanager.h" #include "modalMenu.h" #include "guiInventoryList.h" +#include "guiScrollBar.h" #include "guiTable.h" #include "network/networkprotocol.h" #include "client/joystick_controller.h" @@ -37,8 +38,8 @@ with this program; if not, write to the Free Software Foundation, Inc., class InventoryManager; class ISimpleTextureSource; class Client; -class GUIScrollBar; class TexturePool; +class GUIScrollContainer; typedef enum { f_Button, @@ -167,6 +168,7 @@ public: { m_formspec_string = formspec_string; m_current_inventory_location = current_inventory_location; + m_is_form_regenerated = false; regenerateGui(m_screensize_old); } @@ -274,11 +276,13 @@ protected: v2s32 getRealCoordinateBasePos(const std::vector<std::string> &v_pos); v2s32 getRealCoordinateGeometry(const std::vector<std::string> &v_geom); - std::unordered_map<std::string, StyleSpec> theme_by_type; - std::unordered_map<std::string, StyleSpec> theme_by_name; + std::unordered_map<std::string, std::vector<StyleSpec>> theme_by_type; + std::unordered_map<std::string, std::vector<StyleSpec>> theme_by_name; std::unordered_set<std::string> property_warned; - StyleSpec getStyleForElement(const std::string &type, + StyleSpec getDefaultStyleForElement(const std::string &type, + const std::string &name="", const std::string &parent_type=""); + std::array<StyleSpec, StyleSpec::NUM_STATES> getStyleForElement(const std::string &type, const std::string &name="", const std::string &parent_type=""); v2s32 padding; @@ -296,10 +300,15 @@ protected: std::string m_formspec_prepend; InventoryLocation m_current_inventory_location; + // Default true because we can't control regeneration on resizing, but + // we can control cases when the formspec is shown intentionally. + bool m_is_form_regenerated = true; + std::vector<GUIInventoryList *> m_inventorylists; std::vector<ListRingSpec> m_inventory_rings; std::vector<gui::IGUIElement *> m_backgrounds; std::unordered_map<std::string, bool> field_close_on_enter; + std::unordered_map<std::string, bool> m_dropdown_index_event; std::vector<FieldSpec> m_fields; std::vector<std::pair<FieldSpec, GUITable *>> m_tables; std::vector<std::pair<FieldSpec, gui::IGUICheckBox *>> m_checkboxes; @@ -307,6 +316,8 @@ protected: std::vector<std::pair<gui::IGUIElement *, TooltipSpec>> m_tooltip_rects; std::vector<std::pair<FieldSpec, GUIScrollBar *>> m_scrollbars; std::vector<std::pair<FieldSpec, std::vector<std::string>>> m_dropdowns; + std::vector<gui::IGUIElement *> m_clickthrough_elements; + std::vector<std::pair<std::string, GUIScrollContainer *>> m_scroll_containers; GUIInventoryList::ItemSpec *m_selected_item = nullptr; u16 m_selected_amount = 0; @@ -333,13 +344,14 @@ protected: video::SColor m_default_tooltip_bgcolor; video::SColor m_default_tooltip_color; - private: IFormSource *m_form_src; TextDest *m_text_dst; + std::string m_last_formname; u16 m_formspec_version = 1; std::string m_focused_element = ""; JoystickController *m_joystick; + bool m_show_debug = false; typedef struct { bool explicit_size; @@ -352,9 +364,9 @@ private: core::rect<s32> rect; v2s32 basepos; v2u32 screensize; - std::string focused_fieldname; GUITable::TableOptions table_options; GUITable::TableColumns table_columns; + gui::IGUIElement *current_parent = nullptr; GUIInventoryList::Options inventorylist_options; @@ -387,6 +399,8 @@ private: void parseSize(parserData* data, const std::string &element); void parseContainer(parserData* data, const std::string &element); void parseContainerEnd(parserData* data); + void parseScrollContainer(parserData *data, const std::string &element); + void parseScrollContainerEnd(parserData *data); void parseList(parserData* data, const std::string &element); void parseListRing(parserData* data, const std::string &element); void parseCheckbox(parserData* data, const std::string &element); @@ -429,6 +443,7 @@ private: bool parseAnchorDirect(parserData *data, const std::string &element); void parseAnchor(parserData *data, const std::string &element); bool parseStyle(parserData *data, const std::string &element, bool style_type); + void parseSetFocus(const std::string &element); void tryClose(); @@ -442,30 +457,8 @@ private: */ void legacySortElements(core::list<IGUIElement *>::Iterator from); - /** - * check if event is part of a double click - * @param event event to evaluate - * @return true/false if a doubleclick was detected - */ - bool DoubleClickDetection(const SEvent event); - - struct clickpos - { - v2s32 pos; - s64 time; - }; - clickpos m_doubleclickdetect[2]; - int m_btn_height; gui::IGUIFont *m_font = nullptr; - - /* If true, remap a double-click (or double-tap) action to ESC. This is so - * that, for example, Android users can double-tap to close a formspec. - * - * This value can (currently) only be set by the class constructor - * and the default value for the setting is true. - */ - bool m_remap_dbl_click; }; class FormspecFormSource: public IFormSource |