iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IRTTextControl.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#pragma once
12
19#include "IControl.h"
20#include "ISender.h"
21#include "IPlugStructs.h"
22
23BEGIN_IPLUG_NAMESPACE
24BEGIN_IGRAPHICS_NAMESPACE
25
27template <int MAXNC = 1, typename T = double>
29{
30public:
31 IRTTextControl(const IRECT& bounds, const char* fmtStr = "%f", const char* separatorStr = ", ", const char* initStr = "", const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR)
32 : ITextControl(bounds, initStr, text, BGColor)
33 , mFMTStr(fmtStr)
34 , mSeparatorStr(separatorStr)
35 {
36 }
37
38 void OnMsgFromDelegate(int msgTag, int dataSize, const void* pData) override
39 {
40 if (!IsDisabled() && msgTag == ISender<>::kUpdateMessage)
41 {
42 IByteStream stream(pData, dataSize);
43
44 int pos = 0;
46 pos = stream.Get(&d, pos);
47
48 WDL_String str;
49
50 for(int i=0; i<d.nChans-1; i++)
51 {
52 str.AppendFormatted(256, mFMTStr.Get(), d.vals[i]);
53 str.Append(mSeparatorStr.Get());
54 }
55 str.AppendFormatted(256, mFMTStr.Get(), d.vals[d.nChans-1]);
56
57 SetStr(str.Get());
58 SetDirty(false);
59 }
60 }
61
62protected:
63 WDL_String mFMTStr;
64 WDL_String mSeparatorStr;
65};
66
67END_IGRAPHICS_NAMESPACE
68END_IPLUG_NAMESPACE
This file contains the base IControl implementation, along with some base classes for specific types ...
Manages a non-owned block of memory, for receiving arbitrary message byte streams.
Definition: IPlugStructs.h:268
int Get(T *pDst, int startPos) const
Get arbitary typed data from the stream.
Definition: IPlugStructs.h:289
bool IsDisabled() const
Definition: IControl.h:362
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
A control to display some text in the UI, driven by values in the RT audio thread.
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate()
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
Definition: ISender.h:65
A basic control to display some text.
Definition: IControl.h:2152
virtual void SetStr(const char *str)
Set the text to display.
Definition: IControl.cpp:456
Used to manage color data, independent of draw class/platform.
Used to manage a rectangular area, independent of draw class/platform.
ISenderData is used to represent a typed data packet, that may contain values for multiple channels.
Definition: ISender.h:34
IText is used to manage font and text/text entry style for a piece of text on the UI,...