MyGUI_ImageBox.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_IMAGE_BOX_H_
#define MYGUI_IMAGE_BOX_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Widget.h"
#include "MyGUI_ResourceImageSet.h"
#include "MyGUI_ImageInfo.h"
namespace MyGUI
{
class MYGUI_EXPORT ImageBox : public Widget, public MemberObsolete<ImageBox>
{
MYGUI_RTTI_DERIVED(ImageBox)
public:
//------------------------------------------------------------------------------//
// The simple interface
//------------------------------------------------------------------------------//
/* Set texture and size of image _tile
@param _texture file name or texture name
@param _coord - part of texture where we take tiles
@param _tile size
*/
void setImageInfo(std::string_view _texture, const IntCoord& _coord, const IntSize& _tile);
/* Set texture
@param _texture file name or texture name
*/
void setImageTexture(std::string_view _texture);
void setImageRect(const IntRect& _rect);
void setImageCoord(const IntCoord& _coord);
void setImageTile(const IntSize& _tile);
void setImageIndex(size_t _index);
size_t getImageIndex() const;
IntSize getImageSize() const;
//------------------------------------------------------------------------------//
// The expanded interface
//------------------------------------------------------------------------------//
size_t getItemCount() const;
void setItemSelect(size_t _index);
size_t getItemSelect() const;
void resetItemSelect();
void insertItem(size_t _index, const IntCoord& _item);
void addItem(const IntCoord& _item);
void setItem(size_t _index, const IntCoord& _item);
void deleteItem(size_t _index);
void deleteAllItems();
// работа с фреймами анимированных индексов
void addItemFrame(size_t _index, const IntCoord& _item);
void insertItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item);
void addItemFrameDuplicate(size_t _index, size_t _indexSourceFrame);
void insertItemFrameDuplicate(size_t _index, size_t _indexFrame, size_t _indexSourceFrame);
void setItemFrame(size_t _index, size_t _indexFrame, const IntCoord& _item);
void deleteItemFrame(size_t _index, size_t _indexFrame);
void deleteAllItemFrames(size_t _index);
void setItemFrameRate(size_t _index, float _rate);
float getItemFrameRate(size_t _index) const;
//------------------------------------------------------------------------------//
// The interface with support of resources
//------------------------------------------------------------------------------//
bool setItemResource(std::string_view _name);
void setItemGroup(std::string_view _group);
void setItemName(std::string_view _name);
void setItemResourcePtr(ResourceImageSetPtr _resource);
void setItemResourceInfo(const ImageIndexInfo& _info);
ResourceImageSetPtr getItemResource() const;
void setItemResourceInfo(ResourceImageSetPtr _resource, std::string_view _group, std::string_view _name);
protected:
void shutdownOverride() override;
void setPropertyOverride(std::string_view _key, std::string_view _value) override;
private:
void frameEntered(float _frame);
void recalcIndexes();
void updateSelectIndex(size_t _index);
void frameAdvise(bool _advise);
void _setUVSet(const FloatRect& _rect);
private:
// кусок в текстуре наших картинок
IntRect mRectImage;
// размер одной картинки
IntSize mSizeTile;
// размер текстуры
IntSize mSizeTexture;
// текущая картинка
size_t mIndexSelect{ITEM_NONE};
VectorImages mItems;
bool mFrameAdvise{false};
float mCurrentTime{0};
size_t mCurrentFrame{0};
ResourceImageSetPtr mResource{nullptr};
std::string mItemName;
std::string mItemGroup;
std::string mCurrentTextureName;
};
} // namespace MyGUI
#endif // MYGUI_IMAGE_BOX_H_
MyGUI_ImageInfo.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
MyGUI_ResourceImageSet.h
MyGUI_Widget.h
MyGUI::ImageBox
widget description should be here.
Definition MyGUI_ImageBox.h:22
MyGUI::ImageBox::setItemGroup
void setItemGroup(std::string_view _group)
Definition MyGUI_ImageBox.cpp:407
MyGUI::ImageBox::setItemFrame
void setItemFrame(size_t _index, size_t _indexFrame, const IntCoord &_item)
Definition MyGUI_ImageBox.cpp:309
MyGUI::ImageBox::getImageSize
IntSize getImageSize() const
Definition MyGUI_ImageBox.cpp:472
MyGUI::ImageBox::setItemFrameRate
void setItemFrameRate(size_t _index, float _rate)
Definition MyGUI_ImageBox.cpp:258
MyGUI::ImageBox::setImageTexture
void setImageTexture(std::string_view _texture)
Definition MyGUI_ImageBox.cpp:83
MyGUI::ImageBox::insertItemFrame
void insertItemFrame(size_t _index, size_t _indexFrame, const IntCoord &_item)
Definition MyGUI_ImageBox.cpp:281
MyGUI::ImageBox::shutdownOverride
void shutdownOverride() override
Definition MyGUI_ImageBox.cpp:21
MyGUI::ImageBox::deleteAllItemFrames
void deleteAllItemFrames(size_t _index)
Definition MyGUI_ImageBox.cpp:244
MyGUI::ImageBox::setItemResource
bool setItemResource(std::string_view _name)
Definition MyGUI_ImageBox.cpp:355
MyGUI::ImageBox::resetItemSelect
void resetItemSelect()
Reset item selection.
Definition MyGUI_ImageBox.cpp:538
MyGUI::ImageBox::setPropertyOverride
void setPropertyOverride(std::string_view _key, std::string_view _value) override
Definition MyGUI_ImageBox.cpp:489
MyGUI::ImageBox::setItemSelect
void setItemSelect(size_t _index)
Select specified _index.
Definition MyGUI_ImageBox.cpp:477
MyGUI::ImageBox::setItemName
void setItemName(std::string_view _name)
Definition MyGUI_ImageBox.cpp:419
MyGUI::ImageBox::setImageIndex
void setImageIndex(size_t _index)
Definition MyGUI_ImageBox.cpp:462
MyGUI::ImageBox::setItemResourcePtr
void setItemResourcePtr(ResourceImageSetPtr _resource)
Definition MyGUI_ImageBox.cpp:362
MyGUI::ImageBox::setImageInfo
void setImageInfo(std::string_view _texture, const IntCoord &_coord, const IntSize &_tile)
Definition MyGUI_ImageBox.cpp:28
MyGUI::ImageBox::setItemResourceInfo
void setItemResourceInfo(const ImageIndexInfo &_info)
Definition MyGUI_ImageBox.cpp:331
MyGUI::ImageBox::getItemResource
ResourceImageSetPtr getItemResource() const
Definition MyGUI_ImageBox.cpp:548
MyGUI::ImageBox::insertItem
void insertItem(size_t _index, const IntCoord &_item)
Insert an item into a list at a specified position.
Definition MyGUI_ImageBox.cpp:194
MyGUI::ImageBox::insertItemFrameDuplicate
void insertItemFrameDuplicate(size_t _index, size_t _indexFrame, size_t _indexSourceFrame)
Definition MyGUI_ImageBox.cpp:295
MyGUI::ImageBox::deleteItemFrame
void deleteItemFrame(size_t _index, size_t _indexFrame)
Definition MyGUI_ImageBox.cpp:319
MyGUI::ImageBox::getItemCount
size_t getItemCount() const
Get number of items.
Definition MyGUI_ImageBox.cpp:528
MyGUI::ImageBox::getItemFrameRate
float getItemFrameRate(size_t _index) const
Definition MyGUI_ImageBox.cpp:265
MyGUI::ImageBox::addItemFrameDuplicate
void addItemFrameDuplicate(size_t _index, size_t _indexSourceFrame)
Definition MyGUI_ImageBox.cpp:272
MyGUI::ImageBox::deleteAllItems
void deleteAllItems()
Delete all items.
Definition MyGUI_ImageBox.cpp:188
MyGUI::ImageBox::setImageCoord
void setImageCoord(const IntCoord &_coord)
Definition MyGUI_ImageBox.cpp:58
MyGUI::ImageBox::addItemFrame
void addItemFrame(size_t _index, const IntCoord &_item)
Definition MyGUI_ImageBox.cpp:251
MyGUI::ImageBox::setImageRect
void setImageRect(const IntRect &_rect)
Definition MyGUI_ImageBox.cpp:68
MyGUI::ImageBox::setImageTile
void setImageTile(const IntSize &_tile)
Definition MyGUI_ImageBox.cpp:43
MyGUI::ImageBox::getItemSelect
size_t getItemSelect() const
Get index of selected item (ITEM_NONE if none selected).
Definition MyGUI_ImageBox.cpp:533
MyGUI::ImageBox::deleteItem
void deleteItem(size_t _index)
Delete item at a specified position.
Definition MyGUI_ImageBox.cpp:173
MyGUI::ImageBox::addItem
void addItem(const IntCoord &_item)
Add an item to the end of a list.
Definition MyGUI_ImageBox.cpp:543
MyGUI::ImageBox::setItem
void setItem(size_t _index, const IntCoord &_item)
Replace an item at a specified position.
Definition MyGUI_ImageBox.cpp:208
MyGUI::ImageBox::getImageIndex
size_t getImageIndex() const
Definition MyGUI_ImageBox.cpp:467
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::IntRect
types::TRect< int > IntRect
Definition MyGUI_Types.h:33
MyGUI::ResourceImageSetPtr
ResourceImageSet * ResourceImageSetPtr
Definition MyGUI_ResourceImageSet.h:24
MyGUI::FloatRect
types::TRect< float > FloatRect
Definition MyGUI_Types.h:34
MyGUI::ITEM_NONE
constexpr size_t ITEM_NONE
Definition MyGUI_Macros.h:19
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::IntSize
types::TSize< int > IntSize
Definition MyGUI_Types.h:30
MyGUI::VectorImages
std::vector< ImageItem > VectorImages
Definition MyGUI_ImageInfo.h:22
MyGUI::ImageIndexInfo
Definition MyGUI_ImageInfo.h:25