Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
StepPadView.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019-2020 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19#pragma once
20
21#include <vstgui4/vstgui/lib/controls/ccontrol.h>
22#include <vstgui4/vstgui/lib/cdrawcontext.h>
24#include "CustomControlView.h"
25
27
28using namespace VSTGUI;
29
62{
63public:
73
74public:
75 explicit StepPadView(const CRect &iSize) : CustomDiscreteControlView(iSize)
76 {
77 }
78
79 // draw => does the actual drawing job
80 void draw(CDrawContext *iContext) override;
81
82 // called to display the "held" pad state
83 virtual void drawHeldPad(CDrawContext *iContext);
84
85 // called to display the "released" pad state
86 virtual void drawReleasedPad(CDrawContext *iContext);
87
88 // input events (mouse/keyboard)
89 CMouseEventResult onMouseDown(CPoint &where, const CButtonState &buttons) override;
90 CMouseEventResult onMouseMoved(CPoint &where, const CButtonState &buttons) override;
91 CMouseEventResult onMouseUp(CPoint &where, const CButtonState &buttons) override;
92 CMouseEventResult onMouseCancel() override;
93
94 // true if held
95 bool isHeld() const { return fHeld; }
96
102 inline CColor const &getHeldColor() const { return fHeldColor; }
104 void setHeldColor(CColor const &iColor) { fHeldColor = iColor; }
105
108 CColor const &getDisabledColor() const { return fDisabledColor; }
110 void setDisabledColor(CColor const &iColor) { fDisabledColor = iColor; }
111
134 BitmapPtr getImage() const { return fImage; }
135
137 void setImage(BitmapPtr iImage) { fImage = iImage; }
138
145 void setImageHasDisabledState(bool iValue) { fImageHasDisabledState = iValue; }
146
149 int32 getStepIncrement() const { return fStepIncrement; }
151 void setStepIncrement(int32 iStepIncrement) { fStepIncrement = iStepIncrement; }
152
158
160 void setShiftStepIncrement(int32 iStepIncrement) { fShiftStepIncrement = iStepIncrement; }
161
169 double getDragFactor() const { return fDragFactor; }
171 void setDragFactor(double iDragFactor) { fDragFactor = iDragFactor; }
172
178 double getShiftDragFactor() const { return fShiftDragFactor; }
180 void setShiftDragFactor(double iShiftDragFactor) { fShiftDragFactor = iShiftDragFactor; }
181
185 inline bool getWrap() const { return fWrap; }
187 void setWrap(bool iFlag) { fWrap = iFlag; }
188
195 bool getInverse() const { return fInverse; }
197 void setInverse(bool iInverse) { fInverse = iInverse; }
198
214 void setDirection(EPositiveDirection iDirection) { fDirection = iDirection; }
215
216protected:
217 // registerParameters
218 void registerParameters() override;
219
222 virtual CMouseEventResult setNextValue(CPoint &iWhere, const CButtonState &iButtons);
223
224 // sizeToFit
225 bool sizeToFit() override;
226
227protected:
230 bool fHeld{false};
231
234 double fDragFactor{100.0};
235 double fShiftDragFactor{100.0};
236 bool fWrap{false};
237
238 CColor fHeldColor{kRedCColor};
239 CColor fDisabledColor{kBlackCColor};
241 bool fInverse{false};
243
244 // whether the image has disabled state (3 frames) or not (2 frames)
246
247 // the editor for handling parameter change
250
251public:
252 class Creator : public CustomViewCreator<StepPadView, CustomDiscreteControlView>
253 {
254 public:
255 explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
256 CustomViewCreator(iViewName, iDisplayName)
257 {
270 {
275 }
276 );
277 }
278 };
279};
280
281}
std::unique_ptr< EditorType > Editor
Definition GUIOptionalParam.h:59
CustomDiscreteControlView(const CRect &iSize)
Definition CustomControlView.h:157
CustomViewCreator(char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
Definition CustomViewCreator.h:1318
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition StepPadView.h:255
bool fWrap
Definition StepPadView.h:236
int32 fStepIncrement
Definition StepPadView.h:232
int32 fShiftStepIncrement
Definition StepPadView.h:233
bool getImageHasDisabledState() const
Flag to determine whether the image contains a disabled state (3 frames) or not (2 frames).
Definition StepPadView.h:143
EPositiveDirection getDirection() const
Defines the direction in which the mouse needs to be dragged in order to increase the value.
Definition StepPadView.h:212
void setDirection(EPositiveDirection iDirection)
Attribute positive-direction.
Definition StepPadView.h:214
EPositiveDirection fDirection
Definition StepPadView.h:242
void registerParameters() override
Registers the optional parameter using getControlTag() as its id.
Definition StepPadView.cpp:179
bool getInverse() const
Inverses the meaning of "held" and "released" in regards to drawing the view/image.
Definition StepPadView.h:195
CMouseEventResult onMouseUp(CPoint &where, const CButtonState &buttons) override
Definition StepPadView.cpp:145
void setWrap(bool iFlag)
Attribute wrap.
Definition StepPadView.h:187
int32 getStepIncrement() const
Value by which this pad will increment (positive) or decrement (negative) the parameter.
Definition StepPadView.h:149
bool fInverse
Definition StepPadView.h:241
void setHeldColor(CColor const &iColor)
attribute held-color
Definition StepPadView.h:104
CColor fHeldColor
Definition StepPadView.h:238
CMouseEventResult onMouseDown(CPoint &where, const CButtonState &buttons) override
Definition StepPadView.cpp:116
void draw(CDrawContext *iContext) override
Definition StepPadView.cpp:30
bool sizeToFit() override
Definition StepPadView.cpp:199
virtual void drawHeldPad(CDrawContext *iContext)
Definition StepPadView.cpp:49
void setImage(BitmapPtr iImage)
Attribute pad-image.
Definition StepPadView.h:137
bool fHeld
State of the pad (true for held, false for released).
Definition StepPadView.h:230
double getShiftDragFactor() const
Defines how many pixels the mouse needs to move to go through the range of values when shift is being...
Definition StepPadView.h:178
CMouseEventResult onMouseCancel() override
Definition StepPadView.cpp:163
BitmapPtr getImage() const
The image to use to draw the pad.
Definition StepPadView.h:134
EPositiveDirection
Represents the direction the mouse needs to be moved to register a change.
Definition StepPadView.h:67
StepPadView(const CRect &iSize)
Definition StepPadView.h:75
CColor const & getDisabledColor() const
When no image is provided and the control is disabled, this color is used instead.
Definition StepPadView.h:108
CPoint fMousePosition
Definition StepPadView.h:249
bool getWrap() const
Defines what happens when the value reaches its end of range after being incremented (resp.
Definition StepPadView.h:185
void setDisabledColor(CColor const &iColor)
attribute disabled-color
Definition StepPadView.h:110
GUIOptionalParam< int32 >::Editor fEditor
Definition StepPadView.h:248
double fShiftDragFactor
Definition StepPadView.h:235
void setStepIncrement(int32 iStepIncrement)
Attribute step-increment.
Definition StepPadView.h:151
BitmapSPtr fImage
Definition StepPadView.h:240
bool fImageHasDisabledState
Definition StepPadView.h:245
void setShiftDragFactor(double iShiftDragFactor)
Attribute shift-drag-factor.
Definition StepPadView.h:180
int32 getShiftStepIncrement() const
Value by which this pad will increment (positive) or decrement (negative) the parameter when the shif...
Definition StepPadView.h:157
void setImageHasDisabledState(bool iValue)
Attribute button-image.
Definition StepPadView.h:145
CColor const & getHeldColor() const
When no image is provided, the "released" color is the back color.
Definition StepPadView.h:102
void setDragFactor(double iDragFactor)
Attribute drag-factor.
Definition StepPadView.h:171
bool isHeld() const
Definition StepPadView.h:95
double fDragFactor
Definition StepPadView.h:234
void setInverse(bool iInverse)
Attribute inverse.
Definition StepPadView.h:197
virtual CMouseEventResult setNextValue(CPoint &iWhere, const CButtonState &iButtons)
Compute mouse movement and determine the next value for the control.
Definition StepPadView.cpp:208
CColor fDisabledColor
Definition StepPadView.h:239
CMouseEventResult onMouseMoved(CPoint &where, const CButtonState &buttons) override
Definition StepPadView.cpp:132
double getDragFactor() const
Defines how many pixels the mouse needs to move to go through the range of values.
Definition StepPadView.h:169
virtual void drawReleasedPad(CDrawContext *iContext)
Definition StepPadView.cpp:81
void setShiftStepIncrement(int32 iStepIncrement)
Attribute shift-step-increment.
Definition StepPadView.h:160
void registerColorAttribute(std::string const &iName, typename ColorAttribute::Getter iGetter, typename ColorAttribute::Setter iSetter)
Definition CustomViewCreator.h:952
void registerBitmapAttribute(std::string const &iName, typename BitmapAttribute::Getter iGetter, typename BitmapAttribute::Setter iSetter)
Definition CustomViewCreator.h:972
void registerIntegerAttribute(std::string const &iName, typename IntegerAttribute< TInt >::Getter iGetter, typename IntegerAttribute< TInt >::Setter iSetter)
Definition CustomViewCreator.h:1060
void registerBooleanAttribute(std::string const &iName, typename BooleanAttribute::Getter iGetter, typename BooleanAttribute::Setter iSetter)
Definition CustomViewCreator.h:1100
void registerListAttribute(std::string const &iName, typename ListAttribute< T >::Getter iGetter, typename ListAttribute< T >::Setter iSetter, AttrValInitList< T > const &iAttributeValues)
Definition CustomViewCreator.h:1038
void registerDoubleAttribute(std::string const &iName, typename FloatAttribute< double >::Getter iGetter, typename FloatAttribute< double >::Setter iSetter)
Definition CustomViewCreator.h:1090
Definition CustomController.h:25
CBitmap * BitmapPtr
Definition Types.h:50
SharedPointer< CBitmap > BitmapSPtr
Definition Types.h:51