iPlug2 - C++ Audio Plug-in Framework
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 
23 BEGIN_IPLUG_NAMESPACE
24 BEGIN_IGRAPHICS_NAMESPACE
25 
27 template <int MAXNC = 1, typename T = double>
29 {
30 public:
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 
62 protected:
63  WDL_String mFMTStr;
64  WDL_String mSeparatorStr;
65 };
66 
67 END_IGRAPHICS_NAMESPACE
68 END_IPLUG_NAMESPACE
int Get(T *pDst, int startPos) const
Get arbitary typed data from the stream.
Definition: IPlugStructs.h:289
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate() ...
Used to manage a rectangular area, independent of draw class/platform.
A basic control to display some text.
Definition: IControl.h:1945
Used to manage color data, independent of draw class/platform.
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
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:267
bool IsDisabled() const
Definition: IControl.h:356
ISenderData is used to represent a typed data packet, that may contain values for multiple channels...
Definition: ISender.h:30
IText is used to manage font and text/text entry style for a piece of text on the UI...
virtual void SetStr(const char *str)
Set the text to display.
Definition: IControl.cpp:454
A control to display some text in the UI, driven by values in the RT audio thread.
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
Definition: ISender.h:57
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:196