FifeGUI 0.3.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 addDropTargetListener (DropTargetListener *listener)
void addFocusListener (FocusListener *focusListener)
void addKeyListener (KeyListener *keyListener)
void addMouseListener (MouseListener *mouseListener)
void addWidgetListener (WidgetListener *widgetListener)
virtual void adjustSize ()
bool captureMouse ()
bool contains (int x, int y) const
virtual void drawBorder (Graphics *graphics)
void drawBorder (Graphics *graphics, unsigned int sides) const
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 getBorderSides () const
unsigned int getBorderSize () const
unsigned int getBorderStyle () 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 hasMouseCapture () const
bool isDescendantOf (Widget const *ancestor) const noexcept
bool isEnabled () const
bool isFixedSize () const
bool isFocusable () const
virtual bool isFocused () const
bool isHorizontalExpand () const
bool isInsideActiveMouseModal () const noexcept
bool isLastPositionSet () const
virtual bool isLayouted ()
virtual bool isModalFocusable () const
virtual bool isModalFocused () const
virtual bool isModalMouseInputFocusable () const
bool isMouseInside (MouseEvent const &mouseEvent) const
bool isSetVisible () const
bool isTabInEnabled () const
bool isTabOutEnabled () const
virtual bool isUnderMouseModal () const
bool isVerticalExpand () const
bool isVisible () const
virtual void logic ()
virtual void moveToBottom (Widget *widget)
virtual void moveToTop (Widget *widget)
virtual void onFocusChanged ()
virtual void onFocusGained ()
virtual void onFocusLost ()
Widgetoperator= (Widget &&)=delete
Widgetoperator= (Widget const &)=delete
void releaseMouse ()
void removeActionListener (ActionListener *actionListener)
void removeDeathListener (DeathListener *deathListener)
void removeDropTargetListener (DropTargetListener *listener)
void removeFocusListener (FocusListener *focusListener)
void removeKeyListener (KeyListener *keyListener)
void removeMouseListener (MouseListener *mouseListener)
void removeWidgetListener (WidgetListener *widgetListener)
virtual void requestFocus ()
virtual void requestMoveToBottom ()
virtual void requestMoveToTop ()
virtual void resizeToContent (bool recursion=true)
void setActionEventId (std::string const &actionEventId)
virtual void setBackgroundColor (Color const &color)
virtual void setBaseColor (Color const &color)
void setBorderBottom (unsigned int size, unsigned int style)
virtual void setBorderColor (Color const &color)
void setBorderSides (unsigned int sides)
void setBorderSize (unsigned int size)
void setBorderStyle (unsigned int style)
void setBorderTop (unsigned int size, unsigned int style)
virtual void setDimension (Rectangle const &dimension)
void setEnabled (bool enabled)
void setFixedSize (Size const &size)
void setFocusable (bool focusable)
virtual void setFocused (bool focused)
virtual void setFont (Font *font)
virtual void setForegroundColor (Color const &color)
virtual 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)
virtual void setSize (int width, int height)
void setTabInEnabled (bool enabled)
void setTabOutEnabled (bool enabled)
void setVerticalExpand (bool expand)
void setVisible (bool visible)
virtual void setWidth (int width)
void setX (int x)
void setY (int y)
virtual void showPart (Rectangle rectangle)
virtual void showWidgetPart (Widget *widget, Rectangle area)
virtual void textInput (TextInputEvent &event)
 Widget ()
 Widget (Widget &&)=delete
 Widget (Widget const &)=delete

Protected Member Functions

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 distributeDragDrop (DragEvent &event)
bool distributeDragEnter (DragEvent &event)
void distributeDragHover (DragEvent &event)
void distributeDragLeave (DragEvent &event)
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 ()

Static Protected Member Functions

static void addControlPoints (PointVector const &points, PointVector &newPoints)
static Point getBezierPoint (PointVector const &points, int elements, float t)

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 mBorderSides {BORDER_ALL}
unsigned int mBorderSize {0}
unsigned int mBorderStyle {BORDER_STYLE_FLAT}
std::list< Widget * > mChildren
FontmCurrentFont {nullptr}
std::list< DeathListener * > mDeathListeners
Rectangle mDimension
std::list< DropTargetListener * > mDropTargetListeners
bool mEnabled {true}
Size mFixedSize {-1, -1}
bool mFixedSizeUsed {false}
bool mFocusable {false}
bool mFocused {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  BorderSide : uint8_t {
  BORDER_NONE = 0 , BORDER_LEFT = 1 << 0 , BORDER_TOP = 1 << 1 , BORDER_RIGHT = 1 << 2 ,
  BORDER_BOTTOM = 1 << 3 , BORDER_ALL = BORDER_LEFT | BORDER_TOP | BORDER_RIGHT | BORDER_BOTTOM
}
enum  BorderStyle : uint8_t { BORDER_STYLE_BEVEL = 0 , BORDER_STYLE_FLAT = 1 }
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 WidgetgetMouseCapture ()
static void resetGlobalFont ()
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
static WidgetsMouseCapture = nullptr

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 25 of file curvegraph.hpp.

Constructor & Destructor Documentation

◆ CurveGraph()

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

Construct with initial data points.

Parameters
dataThe initial vector of points to be used for drawing the curve.

Definition at line 24 of file curvegraph.cpp.

References m_data.

Member Function Documentation

◆ addControlPoints()

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

Helper that adds the control points for bezier curves.

Parameters
pointsThe control points for the bezier curve.
newPointsThe vector to which the new control points will be added.

Definition at line 211 of file curvegraph.cpp.

Referenced by CurveGraph(), and update().

◆ draw()

◆ getBezierPoint()

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

Helper that returns an interpolated Point.

Parameters
pointsThe control points for the bezier curve.
elementsThe number of control points.
tThe interpolation parameter, between 0 and 1.

Definition at line 167 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 34 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 51 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 62 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 72 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 39 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.

Parameters
acpTrue to enable automatic control points, false to disable.

Definition at line 56 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 67 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.

Parameters
dataThe vector of points to be used for drawing the curve.

Definition at line 28 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.

Parameters
thicknessThe thickness of the stroke in pixels.

Definition at line 45 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 126 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 124 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 136 of file curvegraph.hpp.

Referenced by draw(), and update().

◆ m_data

PointVector fcn::CurveGraph::m_data
protected

Raw input point data.

Definition at line 133 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 127 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 121 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 130 of file curvegraph.hpp.

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


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