diff options
author | DS <vorunbekannt75@web.de> | 2019-11-07 20:11:01 +0100 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-11-07 20:11:01 +0100 |
commit | 5506e97ed897dde2d4820fe1b021a4622bae03b3 (patch) | |
tree | 85a029b7f9bb046bcf338abad3ea1e50362d6164 /src/gui/guiFormSpecMenu.h | |
parent | 15a030ec9f5d9016c287cf3964894683121e59fd (diff) | |
download | minetest-5506e97ed897dde2d4820fe1b021a4622bae03b3.tar.gz minetest-5506e97ed897dde2d4820fe1b021a4622bae03b3.tar.bz2 minetest-5506e97ed897dde2d4820fe1b021a4622bae03b3.zip |
Formspec: draw order and clipping for all elements (#8740)
Diffstat (limited to 'src/gui/guiFormSpecMenu.h')
-rw-r--r-- | src/gui/guiFormSpecMenu.h | 131 |
1 files changed, 23 insertions, 108 deletions
diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index 39af1e7c2..f15bba35a 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc., class InventoryManager; class ISimpleTextureSource; class Client; +class GUIScrollBar; typedef enum { f_Button, @@ -44,6 +45,8 @@ typedef enum { f_CheckBox, f_DropDown, f_ScrollBar, + f_Box, + f_ItemImage, f_Unknown } FormspecFieldType; @@ -101,11 +104,11 @@ class GUIFormSpecMenu : public GUIModalMenu ListDrawSpec(const InventoryLocation &a_inventoryloc, const std::string &a_listname, - v2s32 a_pos, v2s32 a_geom, s32 a_start_item_i, + IGUIElement *elem, v2s32 a_geom, s32 a_start_item_i, bool a_real_coordinates): inventoryloc(a_inventoryloc), listname(a_listname), - pos(a_pos), + e(elem), geom(a_geom), start_item_i(a_start_item_i), real_coordinates(a_real_coordinates) @@ -114,7 +117,7 @@ class GUIFormSpecMenu : public GUIModalMenu InventoryLocation inventoryloc; std::string listname; - v2s32 pos; + IGUIElement *e; v2s32 geom; s32 start_item_i; bool real_coordinates; @@ -135,84 +138,6 @@ class GUIFormSpecMenu : public GUIModalMenu std::string listname; }; - struct ImageDrawSpec - { - ImageDrawSpec(): - parent_button(NULL), - clip(false) - { - } - - ImageDrawSpec(const std::string &a_name, - const std::string &a_item_name, - gui::IGUIButton *a_parent_button, - const v2s32 &a_pos, const v2s32 &a_geom): - name(a_name), - item_name(a_item_name), - parent_button(a_parent_button), - pos(a_pos), - geom(a_geom), - scale(true), - clip(false) - { - } - - ImageDrawSpec(const std::string &a_name, - const std::string &a_item_name, - const v2s32 &a_pos, const v2s32 &a_geom): - name(a_name), - item_name(a_item_name), - parent_button(NULL), - pos(a_pos), - geom(a_geom), - scale(true), - clip(false) - { - } - - ImageDrawSpec(const std::string &a_name, - const v2s32 &a_pos, const v2s32 &a_geom, bool clip=false): - name(a_name), - parent_button(NULL), - pos(a_pos), - geom(a_geom), - scale(true), - clip(clip) - { - } - - ImageDrawSpec(const std::string &a_name, - const v2s32 &a_pos, const v2s32 &a_geom, const core::rect<s32> &middle, bool clip=false): - name(a_name), - parent_button(NULL), - pos(a_pos), - geom(a_geom), - middle(middle), - scale(true), - clip(clip) - { - } - - ImageDrawSpec(const std::string &a_name, - const v2s32 &a_pos): - name(a_name), - parent_button(NULL), - pos(a_pos), - scale(false), - clip(false) - { - } - - std::string name; - std::string item_name; - gui::IGUIButton *parent_button; - v2s32 pos; - v2s32 geom; - core::rect<s32> middle; - bool scale; - bool clip; - }; - struct FieldSpec { FieldSpec() = default; @@ -239,19 +164,6 @@ class GUIFormSpecMenu : public GUIModalMenu core::rect<s32> rect; }; - struct BoxDrawSpec - { - BoxDrawSpec(v2s32 a_pos, v2s32 a_geom, irr::video::SColor a_color): - pos(a_pos), - geom(a_geom), - color(a_color) - { - } - v2s32 pos; - v2s32 geom; - irr::video::SColor color; - }; - struct TooltipSpec { TooltipSpec() = default; @@ -397,10 +309,9 @@ protected: } std::wstring getLabelByID(s32 id); std::string getNameByID(s32 id); - v2s32 getElementBasePos(bool absolute, - const std::vector<std::string> *v_pos); - v2s32 getRealCoordinateBasePos(bool absolute, - const std::vector<std::string> &v_pos); + FormspecFieldType getTypeByID(s32 id); + v2s32 getElementBasePos(const std::vector<std::string> *v_pos); + 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; @@ -427,19 +338,15 @@ protected: std::vector<ListDrawSpec> m_inventorylists; std::vector<ListRingSpec> m_inventory_rings; - std::vector<ImageDrawSpec> m_backgrounds; - std::vector<ImageDrawSpec> m_images; - std::vector<ImageDrawSpec> m_itemimages; - std::vector<BoxDrawSpec> m_boxes; + std::vector<gui::IGUIElement *> m_backgrounds; std::unordered_map<std::string, bool> field_close_on_enter; std::vector<FieldSpec> m_fields; - std::vector<StaticTextSpec> m_static_texts; - std::vector<std::pair<FieldSpec,GUITable*> > m_tables; - std::vector<std::pair<FieldSpec,gui::IGUICheckBox*> > m_checkboxes; + std::vector<std::pair<FieldSpec, GUITable *>> m_tables; + std::vector<std::pair<FieldSpec, gui::IGUICheckBox *>> m_checkboxes; std::map<std::string, TooltipSpec> m_tooltips; - std::vector<std::pair<irr::core::rect<s32>, TooltipSpec>> m_tooltip_rects; - std::vector<std::pair<FieldSpec,gui::IGUIScrollBar*> > m_scrollbars; - std::vector<std::pair<FieldSpec, std::vector<std::string> > > m_dropdowns; + 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; ItemSpec *m_selected_item = nullptr; u16 m_selected_amount = 0; @@ -480,6 +387,7 @@ private: typedef struct { bool explicit_size; bool real_coordinates; + u8 simple_field_count; v2f invsize; v2s32 size; v2f32 offset; @@ -556,6 +464,13 @@ private: const irr::video::SColor &bgcolor); /** + * In formspec version < 2 the elements were not ordered properly. Some element + * types were drawn before others. + * This function sorts the elements in the old order for backwards compatibility. + */ + 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 |