libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
libscratchcpp::Monitor Class Reference

The Monitor class represents a stage monitor. More...

#include <scratchcpp/monitor.h>

Inheritance diagram for libscratchcpp::Monitor:
Collaboration diagram for libscratchcpp::Monitor:

Public Types

enum class  Mode { Default , Large , Slider , List }
 

Public Member Functions

 Monitor (const std::string &id, const std::string &opcode)
 
 Monitor (const Monitor &)=delete
 
void setInterface (IMonitorHandler *iface)
 
const std::string & name () const
 
void setName (const std::string &name)
 
Mode mode () const
 
void setMode (Mode mode)
 
std::shared_ptr< Blockblock () const
 
std::shared_ptr< Scriptscript () const
 
void setScript (std::shared_ptr< Script > script)
 
IExtensionextension () const
 
void setExtension (IExtension *extension)
 
Spritesprite () const
 
void setSprite (Sprite *sprite)
 
const std::string & opcode () const
 
void updateValue (const Value &value)
 
void setValueChangeFunction (MonitorChangeFunc f)
 
void changeValue (const Value &newValue)
 
unsigned int width () const
 
void setWidth (unsigned int width)
 
unsigned int height () const
 
void setHeight (unsigned int height)
 
int x () const
 
void setX (int x)
 
int y () const
 
void setY (int y)
 
bool visible () const
 
void setVisible (bool visible)
 
double sliderMin () const
 
void setSliderMin (double sliderMin)
 
double sliderMax () const
 
void setSliderMax (double sliderMax)
 
bool discrete () const
 
void setDiscrete (bool discrete)
 
bool needsAutoPosition () const
 
void autoPosition (const std::vector< std::shared_ptr< Monitor > > &allMonitors)
 
const std::string & id () const
 
void setId (const std::string &newId)
 

Friends

class Engine
 

Detailed Description

The Monitor class represents a stage monitor.

Member Enumeration Documentation

◆ Mode

enum class libscratchcpp::Monitor::Mode
strong
Enumerator
Default 
Large 
Slider 
List 

Constructor & Destructor Documentation

◆ Monitor() [1/2]

Monitor::Monitor ( const std::string & id,
const std::string & opcode )

Constructs Monitor.

◆ Monitor() [2/2]

libscratchcpp::Monitor::Monitor ( const Monitor & )
delete

Member Function Documentation

◆ autoPosition()

void Monitor::autoPosition ( const std::vector< std::shared_ptr< Monitor > > & allMonitors)

Auto-positions the monitor with the other monitors.

Note
Call this only when the monitor size is known.

◆ block()

std::shared_ptr< Block > Monitor::block ( ) const

Returns the block used to get the monitor's value.

◆ changeValue()

void Monitor::changeValue ( const Value & newValue)

Calls the monitor's value update function. For example a variable monitor's function sets the value of the monitored variable.

Note
This doesn't work with list monitors.

◆ discrete()

bool Monitor::discrete ( ) const

Returns true if the monitor's slider allows only integer values.

◆ extension()

IExtension * Monitor::extension ( ) const

◆ height()

unsigned int Monitor::height ( ) const

Returns the monitor's height.

◆ id()

const std::string & Entity::id ( ) const
inherited

Returns the ID.

◆ mode()

Monitor::Mode Monitor::mode ( ) const

Returns the monitor's mode.

◆ name()

const std::string & Monitor::name ( ) const

◆ needsAutoPosition()

bool Monitor::needsAutoPosition ( ) const

Returns true if the monitor needs auto positioning. The renderer should call autoPosition() as soon as it knows the monitor size.

◆ opcode()

const std::string & Monitor::opcode ( ) const

Convenience method which calls block()->opcode().

◆ script()

std::shared_ptr< Script > Monitor::script ( ) const

Returns the script which holds information about the monitor's compiled block.

◆ setDiscrete()

void Monitor::setDiscrete ( bool discrete)

Sets whether the monitor's slider allows only integer values.

◆ setExtension()

void Monitor::setExtension ( IExtension * extension)

Sets the extension this monitor belongs to.

◆ setHeight()

void Monitor::setHeight ( unsigned int height)

Sets the monitor's height.

◆ setId()

void Entity::setId ( const std::string & newId)
inherited

Sets the ID.

◆ setInterface()

void Monitor::setInterface ( IMonitorHandler * iface)

Sets the monitor interface.

◆ setMode()

void Monitor::setMode ( Mode mode)

Sets the monitor's mode.

◆ setName()

void Monitor::setName ( const std::string & name)

Sets the name of this monitor.

◆ setScript()

void Monitor::setScript ( std::shared_ptr< Script > script)

Sets the script which holds information about the monitor's compiled block.

◆ setSliderMax()

void Monitor::setSliderMax ( double sliderMax)

Sets the maximum value of the monitor's slider.

◆ setSliderMin()

void Monitor::setSliderMin ( double sliderMin)

Sets the minimum value of the monitor's slider.

◆ setSprite()

void Monitor::setSprite ( Sprite * sprite)

Convenience method which calls block()->setTarget().

◆ setValueChangeFunction()

void Monitor::setValueChangeFunction ( MonitorChangeFunc f)

Sets the function which is called to change the monitor's value.

See also
changeValue()

◆ setVisible()

void Monitor::setVisible ( bool visible)

Sets whether the monitor is visible or not.

◆ setWidth()

void Monitor::setWidth ( unsigned int width)

Sets the monitor's width.

◆ setX()

void Monitor::setX ( int x)

Sets the monitor's x-coordinate.

◆ setY()

void Monitor::setY ( int y)

Sets the monitor's y-coordinate.

◆ sliderMax()

double Monitor::sliderMax ( ) const

Returns the maximum value of the monitor's slider.

◆ sliderMin()

double Monitor::sliderMin ( ) const

Returns the minimum value of the monitor's slider.

◆ sprite()

Sprite * Monitor::sprite ( ) const

Convenience method which calls block()->target().

◆ updateValue()

void Monitor::updateValue ( const Value & value)

Notifies the monitor's interface about value change. The interaface is supposed to read it from the VirtualMachine.

◆ visible()

bool Monitor::visible ( ) const

Returns true if the monitor is visible.

◆ width()

unsigned int Monitor::width ( ) const

Returns the monitor's width.

◆ x()

int Monitor::x ( ) const

Returns the monitor's x-coordinate.

◆ y()

int Monitor::y ( ) const

Returns the monitor's y-coordinate.

Friends And Related Symbol Documentation

◆ Engine

friend class Engine
friend

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