Middle Europe Productions Library  alpha 1.3.3
Public Member Functions | List of all members
MEP::Button Class Reference

MEP::Button provides a basic implementation of an object with the ability of display it on a screen. More...

#include <Button.h>

Inheritance diagram for MEP::Button:
MEP::AnimationObject MEP::Animation MEP::Object MEP::Sprite MEPtools::AnimationDelay MEP::Drawable MEP::Following

Public Member Functions

 Button (const Object &x, unsigned int active_breakpoint, sf::Vector2f pos={ 0, 0 }, sf::Vector2f scale={ 1, 1 })
 
 Button (const float frameRate, const Object &x, unsigned int active_breakpoint, sf::Vector2f pos={ 0, 0 }, sf::Vector2f scale={ 1, 1 })
 
void update (sf::Time &currentTime) override
 
bool isTansparent (unsigned int x, unsigned int y) override
 
void changeStatus (const ButtonStatus &status)
 
const ButtonStatusgetStatus () const
 
bool handleEvent (sf::Event &event, sf::Vector2i &pos)
 
bool mousePress (sf::Vector2i &pos)
 
bool mouseRelease (sf::Vector2i &pos)
 
bool mouseActivity (const sf::Vector2i &pos)
 
void forceRelease ()
 
bool forceReleased ()
 
void forcePress ()
 
bool forcePressed ()
 
void block ()
 
void release ()
 
bool isBlocked () const
 
- Public Member Functions inherited from MEP::AnimationObject
 AnimationObject (const float frameRate, const Object &x, sf::Vector2f pos={ 0.f, 0.f }, sf::Vector2f scale={ 1.f, 1.f })
 
void onResize () override
 
virtual const sf::Vector2u & getSize () const
 
void setScale (const sf::Vector2f scale) override
 
void setScale (const Following &x) override
 
void runForward (sf::Time &currentTime)
 
void runBackward (sf::Time &currentTime)
 
bool draw (sf::RenderWindow &window) override
 
void entryUpdate (sf::Time &currentTime, bool low=false) override
 
void exitUpdate (sf::Time &currentTime, bool low=false) override
 
bool isActive () const override
 
const AnimationObjectgetAnimationObject ()
 
virtual void debugOutput (std::ostream &out) const
 
virtual ~AnimationObject ()=default
 
- Public Member Functions inherited from MEP::Animation
 Animation ()=default
 
 Animation (const AnimationInit initType, const float frameRate)
 
 Animation (const AnimationInit initType, const sf::Time towait)
 
 Animation (const Animation &x)
 
virtual void run (const Direction direc, sf::Time currentTime=sf::Time::Zero)
 
void changeStatus ()
 
bool getStatus () const
 
void changeTag (MEP::U_int32 tag)
 
sf::Time getToWait () const
 
AnimationInit getInit () const
 
const DirectiongetDirection () const
 
void setDirection (MEP::Direction dir)
 
virtual bool reset ()
 
- Public Member Functions inherited from MEPtools::AnimationDelay
void setDelay (const sf::Time &delay, bool permaDelay=false)
 
void setEntryDelay (const sf::Time &delay)
 
void setExitDelay (const sf::Time &delay)
 
void setLowEntryDelay (const sf::Time &delay)
 
void setLowExitDelay (const sf::Time &delay)
 
void setGeneralDelay (const sf::Time &delay, bool permaDelay=false)
 
void resetDelay ()
 
- Public Member Functions inherited from MEP::Object
 Object ()=delete
 
 Object (const Object &x)
 
 Object (const U_int32 ID, const std::string &path, const std::string &filename, bool transparencyM=false)
 
 Object (const U_int32 ID, const std::string &path, const std::string &filename, unsigned int frames, bool transparencyM=false)
 
 Object (const U_int32 ID, std::list< sf::Image > &images, const std::string &filename, bool transparencyM=false)
 
unsigned long getNufTextures () const
 
bool draw (sf::RenderWindow &window) override
 
void update (sf::Time &) override
 
void entryUpdate (sf::Time &currentTime, bool low=false) override
 
void exitUpdate (sf::Time &currentTime, bool low=false) override
 
ObjectgetObjectPoint ()
 
ObjectgetObjectRef ()
 
const U_int32getID () const
 
const std::string & getName () const
 
bool isActive () const
 
const ObjectTypegetType () const
 
unsigned int nufC () const
 
bool operator== (const std::string &x) const
 
bool operator== (const Object &x) const
 
 ~Object () override
 
- Public Member Functions inherited from MEP::Drawable
void _link (std::shared_ptr< bool > _li)
 
std::shared_ptr< bool > _linkAddr ()
 
const std::shared_ptr< bool > _linkAddr () const
 
bool _isLinked () const
 
U_int32 getDrawTag () const
 
void setDrawTag (const U_int32 tag)
 
bool addDrawTag (const U_int32 tag)
 
bool removeDrawTag (const U_int32 tag)
 
 Drawable ()=default
 
virtual ~Drawable ()
 
- Public Member Functions inherited from MEP::Sprite
 Sprite (const FollowType &followType, sf::Vector2f pos={ 0.f, 0.f }, sf::Vector2f scale={ 1.f, 1.f })
 
 Sprite (sf::Vector2f pos={ 0.f, 0.f }, sf::Vector2f scale={ 1.f, 1.f })
 
Spriteoperator<< (const Sprite &x)
 
sf::Sprite & getSprite ()
 
void updateSprite (sf::Texture &texture)
 
virtual void updateSprite ()
 
void setPosition (const sf::Vector2f pos) override
 
void setPosition (const Following &x) override
 
void setColor (const sf::Color &color) override
 
void setRect (const sf::IntRect &rect)
 
void addMethodRect (std::function< sf::IntRect()> method)
 
void updateRect ()
 
const sf::IntRect & getRect () const
 
const sf::Color & getColor () const override
 
- Public Member Functions inherited from MEP::Following
 Following (const FollowType &followType, sf::Vector2f pos={ 0.f, 0.f }, sf::Vector2f posFixed={ 0.f, 0.f }, sf::Vector2f scale={ 1.f, 1.f }, sf::Vector2f scaleFixed={ 1.f, 1.f })
 
 Following (sf::Vector2f pos={ 0.f, 0.f }, sf::Vector2f posFixed={ 0.f, 0.f }, sf::Vector2f scale={ 1.f, 1.f }, sf::Vector2f scaleFixed={ 1.f, 1.f })
 
 Following (const Following &x)
 
void updatePosition ()
 
void addMethodPos (std::function< sf::Vector2f()> method)
 
void updateScale ()
 
void addMethodScale (std::function< sf::Vector2f()> method)
 
Followingoperator<< (const Following &x)
 
void setFollow (const AnimationPosition &base, const FollowType type, MEP::U_int32 group=-1)
 
void setFollow (const AnimationColor &base, MEP::U_int32 toFollow=MEP::ColorChannel::ALL, MEP::U_int32 group=-1)
 
void muteFollowGroup (MEP::U_int32 group)
 
void unMuteFollowGroup (MEP::U_int32 group)
 
void fullMuteFollow ()
 
void fullUnMuteFollow ()
 
virtual void movePosition (const sf::Vector2f pos)
 
sf::Vector2f getPosition () const
 
sf::Vector2f getScale () const
 
sf::Vector2f getOriginPosition () const
 
sf::Vector2f getOriginScale () const
 
bool isFollowerActive () const
 
void followingDebug (std::ostream &out, const char *skipLines="") const
 
void clearFollow ()
 

Additional Inherited Members

- Public Types inherited from MEP::Animation
enum  AnimationInit { AnimationInit::NotInit = 0, AnimationInit::ObjectAnimation = 1, AnimationInit::PositionAnimation = 2 }
 
- Public Types inherited from MEP::Object
enum  ObjectType { ObjectType::NotInit, ObjectType::Single, ObjectType::Multi }
 
- Public Types inherited from MEP::Following
enum  FollowType {
  FollowType::NotInit = 0, FollowType::Objects = 1, FollowType::X_Scale = 2, FollowType::Y_Scale = 3,
  FollowType::X_Pos = 4, FollowType::Y_Pos = 5, FollowType::Color = 6
}
 
- Protected Types inherited from MEPtools::AnimationDelay
enum  State {
  State::Entry, State::Exit, State::Base, State::LowExit,
  State::LowEntry
}
 
- Protected Member Functions inherited from MEP::AnimationObject
void init ()
 
bool correctObject (const Object &x)
 
void updateSize ()
 
- Protected Member Functions inherited from MEP::Animation
void animationDebug (std::ostream &out) const
 
- Protected Member Functions inherited from MEPtools::AnimationDelay
const sf::Time & delay () const
 
bool updateDelay (const sf::Time &currentTime)
 
void newCycle ()
 
void changeState (State newState)
 
- Protected Member Functions inherited from MEP::Object
void deleteObject ()
 
- Protected Member Functions inherited from MEP::Drawable
void notify ()
 
void drawTagDebug (std::ostream &out) const
 
- Protected Attributes inherited from MEP::AnimationObject
std::list< sf::Texture * >::iterator currentFrame
 
unsigned int index_currentFrame = 0
 
const AnimationObjecttoFollowOBJ = nullptr
 
sf::Vector2u fixSize
 
- Protected Attributes inherited from MEP::Animation
MEP::U_int32 m_tag = AdditionalTag::AdditionalTagDisabled
 
AnimationInit isInit = AnimationInit::NotInit
 
sf::Time updateTime = sf::Time::Zero
 
sf::Time toWait = sf::Time::Zero
 
bool isRunning = false
 
Direction direction = Direction::Backwards
 
- Protected Attributes inherited from MEPtools::AnimationDelay
State state = State::Base
 
- Protected Attributes inherited from MEP::Object
bool transparency = false
 
bool ** table = nullptr
 
sf::Vector2u m_size = {0, 0}
 
std::list< sf::Texture * > * texture
 
ObjectType m_type = Object::ObjectType::NotInit
 
- Protected Attributes inherited from MEP::Sprite
sf::Sprite currentSprite
 
- Protected Attributes inherited from MEP::Following
std::function< sf::Vector2f()> calc_position = [this]()->sf::Vector2f { return m_pos; }
 
std::function< sf::Vector2f()> calc_scale = [this]()->sf::Vector2f { return m_scale; }
 
MEPtools::GroupManager< Follow, std::unique_ptr< Follow >, std::list< std::unique_ptr< Follow > > > followingListv2
 
sf::Vector2f m_pos = {0.f, 0.f}
 
sf::Vector2f m_posMove = { 0.f, 0.f }
 
sf::Vector2f m_posFixed = { 0.f, 0.f }
 
sf::Vector2f m_scale = { 1.f, 1.f }
 
sf::Vector2f m_scaleFixed = { 1.f, 1.f }
 
sf::Color m_color
 
sf::Color m_colorFixed
 

Detailed Description

MEP::Button provides a basic implementation of an object with the ability of display it on a screen.

Constructor & Destructor Documentation

◆ Button() [1/2]

MEP::Button::Button ( const Object x,
unsigned int  active_breakpoint,
sf::Vector2f  pos = { 0, 0 },
sf::Vector2f  scale = { 1, 1 } 
)
inline

Constructor of a Button

Parameters
[in]x: MEP::Object
[in]active_breakpoint: State in which button is fully activeated (mouse is pointing).
[in]pos: position of a button.
[in]scale: scale of a button

◆ Button() [2/2]

MEP::Button::Button ( const float  frameRate,
const Object x,
unsigned int  active_breakpoint,
sf::Vector2f  pos = { 0, 0 },
sf::Vector2f  scale = { 1, 1 } 
)
inline

Constructor of a Button

Parameters
[in]x: frame rate of an animation.
[in]x: MEP::Object
[in]active_breakpoint: State in which button is fully activeated (mouse is pointing).
[in]pos: position of a button.
[in]scale: scale of a button

Member Function Documentation

◆ block()

void MEP::Button::block ( )
inline

Block any activity in the button.

◆ changeStatus()

void MEP::Button::changeStatus ( const ButtonStatus status)
inline

Changes the status of a button.

Parameters
[in]status: A MEP::Button::ButtonStatus object

◆ forcePress()

void MEP::Button::forcePress ( )
inline

Forces to press the button. Not ignoring the animation.

◆ forcePressed()

bool MEP::Button::forcePressed ( )
inline

Forces the button to be pressed. Ignores the animation.

Returns
: True - Button was pressed, False - animation is active.

◆ forceRelease()

void MEP::Button::forceRelease ( )
inline

Forces to releases the button.

◆ forceReleased()

bool MEP::Button::forceReleased ( )
inline

Forces the button to be released. Ignores the animation.

Returns
: True - Button was released, False - animation is active.

◆ getStatus()

const ButtonStatus& MEP::Button::getStatus ( ) const
inline

Outputs current status of a button.

Returns
Current status

◆ handleEvent()

bool MEP::Button::handleEvent ( sf::Event &  event,
sf::Vector2i &  pos 
)
inline

Automatically handles the events.
This method is not recommended because of the complexity.
(When executed automatically checks all of the events. Mouse activity, movement etc.)

◆ isBlocked()

bool MEP::Button::isBlocked ( ) const
inline

Checks the activity of the button.

◆ isTansparent()

bool MEP::Button::isTansparent ( unsigned int  x,
unsigned int  y 
)
inlineoverridevirtual

Checks if a given position is Transparent. MEP::Objects of a button needs to have transparency initialized.

Returns
true - position is transparent, false - there is a pixel witout alpha channel > 200

Reimplemented from MEP::AnimationObject.

◆ mouseActivity()

bool MEP::Button::mouseActivity ( const sf::Vector2i &  pos)
inline

Inform the button that the statue of .

Returns
: True - there was an activity on a Button, False - otherwise.

◆ mousePress()

bool MEP::Button::mousePress ( sf::Vector2i &  pos)
inline

Delivers an information that there is a possible press event tied with the button. True - if button is pressed, False - otherwise.

◆ mouseRelease()

bool MEP::Button::mouseRelease ( sf::Vector2i &  pos)
inline

Delivers an information that there is a possible release event tied with the button. True - if button is released, False - otherwise.

◆ release()

void MEP::Button::release ( )
inline

Unlocks activity among the button.

◆ update()

void MEP::Button::update ( sf::Time &  currentTime)
inlineoverridevirtual

Override of a MEP::Drawable update.

Reimplemented from MEP::AnimationObject.