FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::CurveGraph Class Reference

#include <curvegraph.hpp>

Inheritance diagram for fcn::CurveGraph:
fcn::Widget

Public Member Functions

 CurveGraph ()
 CurveGraph (CurveGraph &&)=delete
 CurveGraph (CurveGraph const &)=delete
 CurveGraph (PointVector data)
void draw (Graphics *graphics) override
PointVector const & getPointVector () const
unsigned int getThickness () const
bool isAutomaticControlPoints () const
bool isOpaque () const
CurveGraphoperator= (CurveGraph &&)=delete
CurveGraphoperator= (CurveGraph const &)=delete
void resetPointVector ()
void setAutomaticControlPoints (bool acp)
void setOpaque (bool opaque)
void setPointVector (PointVector const &data)
void setThickness (unsigned int thickness)
Public Member Functions inherited from fcn::Widget
virtual void _draw (Graphics *graphics)
virtual FocusHandler_getFocusHandler ()
virtual std::list< FocusListener * > const & _getFocusListeners ()
virtual FocusHandler_getInternalFocusHandler ()
virtual std::list< KeyListener * > const & _getKeyListeners ()
virtual std::list< MouseListener * > const & _getMouseListeners ()
virtual void _logic ()
virtual void _setFocusHandler (FocusHandler *focusHandler)
virtual void _setParent (Widget *parent)
void adaptLayout ()
virtual void adaptLayout (bool top)
void addActionListener (ActionListener *actionListener)
void addDeathListener (DeathListener *deathListener)
void addFocusListener (FocusListener *focusListener)
void addKeyListener (KeyListener *keyListener)
void addMouseListener (MouseListener *mouseListener)
void addWidgetListener (WidgetListener *widgetListener)
virtual void adjustSize ()
virtual void drawBorder (Graphics *graphics)
virtual void drawOutline (Graphics *graphics)
virtual void drawSelectionFrame (Graphics *graphics)
void expandContent ()
virtual void expandContent (bool recursion)
virtual void focusNext ()
virtual void focusPrevious ()
virtual void fontChanged ()
virtual void getAbsolutePosition (int &x, int &y) const
std::string const & getActionEventId () const
Color const & getBackgroundColor () const
Color const & getBaseColor () const
Color const & getBorderColor () const
unsigned int getBorderSize () const
virtual Rectangle getChildrenArea ()
unsigned int getChildrenCount () const
Rectangle const & getDimension () const
Size const & getFixedSize () const
FontgetFont () const
Color const & getForegroundColor () const
int getHeight () const
std::string const & getId () const
void getLastPosition (int &x, int &y) const
int getMarginBottom () const
int getMarginLeft () const
int getMarginRight () const
int getMarginTop () const
Size const & getMaxSize () const
Size const & getMinSize () const
Color const & getOutlineColor () const
unsigned int getOutlineSize () const
unsigned int getPaddingBottom () const
unsigned int getPaddingLeft () const
unsigned int getPaddingRight () const
unsigned int getPaddingTop () const
virtual WidgetgetParent () const
Color const & getSelectionColor () const
SelectionMode getSelectionMode () const
virtual WidgetgetTop () const
unsigned int getVisibleChildrenCount () const
WidgetgetWidgetAt (int x, int y)
virtual WidgetgetWidgetAt (int x, int y, Widget *exclude)
std::list< Widget * > getWidgetsIn (Rectangle const &area)
virtual std::list< Widget * > getWidgetsIn (Rectangle const &area, Widget *ignore)
int getWidth () const
int getX () const
int getY () const
bool isEnabled () const
bool isFixedSize () const
bool isFocusable () const
virtual bool isFocused () const
bool isHorizontalExpand () const
bool isLastPositionSet () const
virtual bool isLayouted ()
virtual bool isModalFocusable () const
virtual bool isModalFocused () const
virtual bool isModalMouseInputFocusable () const
virtual bool isModalMouseInputFocused () const
bool isSetVisible () const
bool isTabInEnabled () const
bool isTabOutEnabled () const
bool isVerticalExpand () const
bool isVisible () const
virtual void logic ()
virtual void moveToBottom (Widget *widget)
virtual void moveToTop (Widget *widget)
Widgetoperator= (Widget &&)=delete
Widgetoperator= (Widget const &)=delete
virtual void releaseModalFocus ()
virtual void releaseModalMouseInputFocus ()
void removeActionListener (ActionListener *actionListener)
void removeDeathListener (DeathListener *deathListener)
void removeFocusListener (FocusListener *focusListener)
void removeKeyListener (KeyListener *keyListener)
void removeMouseListener (MouseListener *mouseListener)
void removeWidgetListener (WidgetListener *widgetListener)
virtual void requestFocus ()
virtual void requestModalFocus ()
virtual void requestModalMouseInputFocus ()
virtual void requestMoveToBottom ()
virtual void requestMoveToTop ()
void resizeToContent ()
virtual void resizeToContent (bool recursion)
void setActionEventId (std::string const &actionEventId)
virtual void setBackgroundColor (Color const &color)
virtual void setBaseColor (Color const &color)
virtual void setBorderColor (Color const &color)
void setBorderSize (unsigned int size)
void setDimension (Rectangle const &dimension)
void setEnabled (bool enabled)
void setFixedSize (Size const &size)
void setFocusable (bool focusable)
virtual void setFont (Font *font)
virtual void setForegroundColor (Color const &color)
void setHeight (int height)
void setHorizontalExpand (bool expand)
void setId (std::string const &id)
void setInternalFocusHandler (FocusHandler *internalFocusHandler)
void setLastPosition (int x, int y)
void setMargin (int margin)
void setMarginBottom (int margin)
void setMarginLeft (int margin)
void setMarginRight (int margin)
void setMarginTop (int margin)
void setMaxSize (Size const &size)
void setMinSize (Size const &size)
virtual void setOutlineColor (Color const &color)
void setOutlineSize (unsigned int size)
void setPadding (unsigned int padding)
void setPaddingBottom (unsigned int padding)
void setPaddingLeft (unsigned int padding)
void setPaddingRight (unsigned int padding)
void setPaddingTop (unsigned int padding)
void setPosition (int x, int y)
virtual void setSelectionColor (Color const &color)
virtual void setSelectionMode (SelectionMode mode)
void setSize (int width, int height)
void setTabInEnabled (bool enabled)
void setTabOutEnabled (bool enabled)
void setVerticalExpand (bool expand)
void setVisible (bool visible)
void setWidth (int width)
void setX (int x)
void setY (int y)
virtual void showPart (Rectangle rectangle)
virtual void showWidgetPart (Widget *widget, Rectangle area)
 Widget ()
 Widget (Widget &&)=delete
 Widget (Widget const &)=delete

Protected Member Functions

void addControlPoints (PointVector const &points, PointVector &newPoints)
Point getBezierPoint (PointVector const &points, int elements, float t)
void update ()
Protected Member Functions inherited from fcn::Widget
void add (Widget *widget)
void calculateSize ()
void distributeActionEvent ()
void distributeAncestorHiddenEvent (Widget *ancestor)
void distributeAncestorMovedEvent (Widget *ancestor)
void distributeAncestorShownEvent (Widget *ancestor)
void distributeHiddenEvent ()
void distributeMovedEvent ()
void distributeResizedEvent ()
void distributeShownEvent ()
virtual WidgetfindWidgetById (std::string const &id)
std::list< Widget * > const & getChildren () const
virtual void remove (Widget *widget)
virtual void removeAllChildren ()
void resizeToChildren ()

Protected Attributes

bool m_acp {true}
PointVector m_curveData
PointVector m_data
bool m_needUpdate {false}
bool m_opaque {false}
unsigned int m_thickness {1}
Protected Attributes inherited from fcn::Widget
std::string mActionEventId
std::list< ActionListener * > mActionListeners
Color mBackgroundColor {0xf9fafb}
Color mBaseColor {0xe5e7eb}
Color mBorderColor {0xd1d5db}
unsigned int mBorderSize {0}
std::list< Widget * > mChildren
FontmCurrentFont {nullptr}
std::list< DeathListener * > mDeathListeners
Rectangle mDimension
bool mEnabled {true}
Size mFixedSize {-1, -1}
bool mFixedSizeUsed {false}
bool mFocusable {false}
FocusHandlermFocusHandler {nullptr}
std::list< FocusListener * > mFocusListeners
Color mForegroundColor {0x1f2933}
bool mHExpand {false}
std::string mId
FocusHandlermInternalFocusHandler {nullptr}
std::list< KeyListener * > mKeyListeners
int mLastX {0}
int mLastY {0}
int mMarginBottom {0}
int mMarginLeft {0}
int mMarginRight {0}
int mMarginTop {0}
Size mMaxSize {std::numeric_limits<int>::max(), std::numeric_limits<int>::max()}
Size mMinSize {0, 0}
std::list< MouseListener * > mMouseListeners
Rectangle mOffsetRect
Color mOutlineColor {0x9ca3af}
unsigned int mOutlineSize {0}
unsigned int mPaddingBottom {0}
unsigned int mPaddingLeft {0}
unsigned int mPaddingRight {0}
unsigned int mPaddingTop {0}
WidgetmParent {nullptr}
Color mSelectionColor {0x3b82f6}
SelectionMode mSelectionMode {SelectionMode::None}
bool mTabIn {true}
bool mTabOut {true}
bool mVExpand {false}
bool mVisible {true}
std::list< WidgetListener * > mWidgetListeners

Additional Inherited Members

Public Types inherited from fcn::Widget
enum class  SelectionMode : uint8_t { None = 0 , Border = 1 , Background = 2 }
Static Public Member Functions inherited from fcn::Widget
static DeathListener_getGuiDeathListener ()
static VisibilityEventHandler_getVisibilityEventHandler ()
static void _setGuiDeathListener (DeathListener *deathListener)
static void _setVisibilityEventHandler (VisibilityEventHandler *visibilityEventHandler)
static void setGlobalFont (Font *font)
static bool widgetExists (Widget const *widget)
Static Protected Attributes inherited from fcn::Widget
static DefaultFont mDefaultFont
static FontmGlobalFont = nullptr
static DeathListenermGuiDeathListener = nullptr
static VisibilityEventHandlermVisibilityEventHandler = nullptr
static std::list< Widget * > mWidgetInstances

Detailed Description

Displays data as a smooth curve based on a vector of points.

The graph can be set to be opaque or not with setOpaque. If the graph is opaque, it will be drawn with a solid color, otherwise it will be drawn with a transparent color.

Definition at line 24 of file curvegraph.hpp.

Constructor & Destructor Documentation

◆ CurveGraph()

fcn::CurveGraph::CurveGraph ( PointVector data)
explicit

Construct with initial data points.

Definition at line 20 of file curvegraph.cpp.

References m_data.

Member Function Documentation

◆ addControlPoints()

void fcn::CurveGraph::addControlPoints ( PointVector const & points,
PointVector & newPoints )
protected

Helper that adds the control points for bezier curves.

Definition at line 204 of file curvegraph.cpp.

Referenced by CurveGraph(), and update().

◆ draw()

◆ getBezierPoint()

Point fcn::CurveGraph::getBezierPoint ( PointVector const & points,
int elements,
float t )
protected

Helper that returns an interpolated Point.

Definition at line 160 of file curvegraph.cpp.

References fcn::Math< double >::Pow().

Referenced by CurveGraph(), and update().

◆ getPointVector()

PointVector const & fcn::CurveGraph::getPointVector ( ) const

Get the current point vector.

Definition at line 28 of file curvegraph.cpp.

References m_data.

Referenced by CurveGraph().

◆ getThickness()

unsigned int fcn::CurveGraph::getThickness ( ) const

Get stroke thickness in pixels.

Definition at line 45 of file curvegraph.cpp.

References m_thickness.

Referenced by CurveGraph().

◆ isAutomaticControlPoints()

bool fcn::CurveGraph::isAutomaticControlPoints ( ) const

Return whether automatic control points are enabled.

Definition at line 56 of file curvegraph.cpp.

References m_acp.

Referenced by CurveGraph().

◆ isOpaque()

bool fcn::CurveGraph::isOpaque ( ) const
Returns
Whether this graph is opaque or not.

Definition at line 66 of file curvegraph.cpp.

References m_opaque.

Referenced by CurveGraph(), and draw().

◆ resetPointVector()

void fcn::CurveGraph::resetPointVector ( )

Reset the stored data to an empty vector.

Definition at line 33 of file curvegraph.cpp.

References m_data, and m_needUpdate.

Referenced by CurveGraph().

◆ setAutomaticControlPoints()

void fcn::CurveGraph::setAutomaticControlPoints ( bool acp)

Enable/disable automatic computation of bezier control points.

Definition at line 50 of file curvegraph.cpp.

References m_acp, and m_needUpdate.

Referenced by CurveGraph().

◆ setOpaque()

void fcn::CurveGraph::setOpaque ( bool opaque)

Sets the opacity of the graph.

Parameters
opaqueTrue if opaque, false otherwise.

Definition at line 61 of file curvegraph.cpp.

References m_opaque.

Referenced by CurveGraph().

◆ setPointVector()

void fcn::CurveGraph::setPointVector ( PointVector const & data)

Set the raw point vector used to draw the curve.

Definition at line 22 of file curvegraph.cpp.

References m_data, and m_needUpdate.

Referenced by CurveGraph().

◆ setThickness()

void fcn::CurveGraph::setThickness ( unsigned int thickness)

Set stroke thickness in pixels.

Definition at line 39 of file curvegraph.cpp.

References m_needUpdate, and m_thickness.

Referenced by CurveGraph().

◆ update()

void fcn::CurveGraph::update ( )
protected

Precalculate bezier curve.

Definition at line 119 of file curvegraph.cpp.

References addControlPoints(), getBezierPoint(), m_acp, m_curveData, m_data, m_needUpdate, m_thickness, and fcn::Math< float >::Sqrt().

Referenced by CurveGraph(), and draw().

Member Data Documentation

◆ m_acp

bool fcn::CurveGraph::m_acp {true}
protected

Whether automatic control points are enabled.

Definition at line 95 of file curvegraph.hpp.

Referenced by isAutomaticControlPoints(), setAutomaticControlPoints(), and update().

◆ m_curveData

PointVector fcn::CurveGraph::m_curveData
protected

Precalculated curve points (bezier/interpolated).

Definition at line 107 of file curvegraph.hpp.

Referenced by draw(), and update().

◆ m_data

PointVector fcn::CurveGraph::m_data
protected

Raw input point data.

Definition at line 104 of file curvegraph.hpp.

Referenced by CurveGraph(), getPointVector(), resetPointVector(), setPointVector(), and update().

◆ m_needUpdate

bool fcn::CurveGraph::m_needUpdate {false}
protected

Internal flag marking that the precalculated curve data needs update.

Definition at line 98 of file curvegraph.hpp.

Referenced by draw(), resetPointVector(), setAutomaticControlPoints(), setPointVector(), setThickness(), and update().

◆ m_opaque

bool fcn::CurveGraph::m_opaque {false}
protected

True if the curve is drawn opaque.

Definition at line 92 of file curvegraph.hpp.

Referenced by isOpaque(), and setOpaque().

◆ m_thickness

unsigned int fcn::CurveGraph::m_thickness {1}
protected

Stroke thickness in pixels.

Definition at line 101 of file curvegraph.hpp.

Referenced by draw(), getThickness(), setThickness(), and update().


The documentation for this class was generated from the following files: