BasicWidget2D class reference


Widget interface, medium level used by basic widgets. Implements several functions from the Widget2D base class.

Functions documentation

BasicWidget2D(Window* parent, const Widget2DProps& props);

Default constructor.


Copy constructor.


virtual ~BasicWidget2D();

Destructor.


friend void swap(BasicWidget2D& first, BasicWidget2D& second) noexcept;

Swaps data between objects.


virtual void Render() override = 0;

Renders the widget. The function must be implemented in an inheriting class.


void SetPosition(Point<int> newPosition) override;

Sets the widget in a specific position.


void ChangePosition(Point<int> positionChange) override;

Changes the position of the widget relative to the current one.


void Resize(Dimension<size_t> newSize);

Sets the new widget size.


void ChangeSize(Dimension<size_t> sizeChange);

Changes the size of the widget.


void SetRotation(float newAngle);

Sets the new widget rotation.


void ChangeRotation(float angleChange);

Changes the rotation of the widget.


void SetScale(Scale<float> newScale);

Sets the new widget scale.


void ChangeScale(Scale<float> scaleChange);

Changes the scale of the widget.


void SetVisibility(bool mode) override;

Sets the visibility of the widget.


bool GetVisibility() const override;

Returns the visibility of the widget.


void SetFlags(int newFlags) override;

Sets the widget flags.


void EnableWidget() override;

Activates the widget's operation by registering for specific events to the parent window.


void DisableWidget() override;

Deactivates the widget by unregistering from the parent window. Note - re-registration may change the z-order of the widget on rendering stack.


virtual void BindBuffers() = 0;

This function should bind the filled-in data arrays that are later used in the rendering process. This is the place where the vertex or uv arrays etc. should be bound. This function is used in the process of resizing the widget. The function must be implemented in an inheriting class.


virtual bool OnWindowResize(Event* ev);

WindowResize event handler.


virtual bool OnDrawableInvokeRender(Event* ev);

DrawableInvokeRender event handler. Basicly invokes Render().


virtual bool OnWindowClose(Event* ev);

WindowClose event handler. Basicly invokes DisalbeWidget().


void UseShader(const char* shaderName);

Gets the pointer to the requested shader data and sets the widget to use it.


virtual void RecalculateMatrices();

Calculates the model and MVP matrix. It is usually invoked before the rendering starts. The model matrix is recalculated only when the m_bChange flag from m_Widget2DProps is true.


virtual void CalculateAnchorVec();

Based on the m_iFlags from m_Widget2DProps, calculates the widget's shift vector.


Variables documentation

Matrices m_Matrices;

Stores matrices describing mathematical transformations on the widget.


std::map<const char*, GLuint, CompareCStr>* m_UsedShader;

Stores data about the used shader.


float m_fRotationAngle;

Stores the angle by which the widget is rotated.