Initial release
This commit is contained in:
Vendored
+154
@@ -0,0 +1,154 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "animationsplashscreencreator.h"
|
||||
|
||||
#include "../../lib/controls/csplashscreen.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AnimationSplashScreenCreator::AnimationSplashScreenCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr AnimationSplashScreenCreator::getViewName () const
|
||||
{
|
||||
return kCAnimationSplashScreen;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr AnimationSplashScreenCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr AnimationSplashScreenCreator::getDisplayName () const
|
||||
{
|
||||
return "Animation Splash Screen";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* AnimationSplashScreenCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CAnimationSplashScreen (CRect (0, 0, 0, 0), -1, nullptr, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AnimationSplashScreenCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* splashScreen = dynamic_cast<CAnimationSplashScreen*> (view);
|
||||
if (!splashScreen)
|
||||
return false;
|
||||
|
||||
CBitmap* bitmap;
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrSplashBitmap), bitmap, description))
|
||||
splashScreen->setSplashBitmap (bitmap);
|
||||
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrSplashOrigin, p))
|
||||
{
|
||||
CRect size = splashScreen->getSplashRect ();
|
||||
size.originize ();
|
||||
size.offset (p.x, p.y);
|
||||
splashScreen->setSplashRect (size);
|
||||
}
|
||||
if (attributes.getPointAttribute (kAttrSplashSize, p))
|
||||
{
|
||||
CRect size = splashScreen->getSplashRect ();
|
||||
size.setWidth (p.x);
|
||||
size.setHeight (p.y);
|
||||
splashScreen->setSplashRect (size);
|
||||
}
|
||||
int32_t value;
|
||||
if (attributes.getIntegerAttribute (kAttrAnimationIndex, value))
|
||||
splashScreen->setAnimationIndex (static_cast<uint32_t> (value));
|
||||
if (attributes.getIntegerAttribute (kAttrAnimationTime, value))
|
||||
splashScreen->setAnimationTime (static_cast<uint32_t> (value));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AnimationSplashScreenCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrSplashBitmap);
|
||||
attributeNames.emplace_back (kAttrSplashOrigin);
|
||||
attributeNames.emplace_back (kAttrSplashSize);
|
||||
attributeNames.emplace_back (kAttrAnimationIndex);
|
||||
attributeNames.emplace_back (kAttrAnimationTime);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto AnimationSplashScreenCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrSplashBitmap)
|
||||
return kBitmapType;
|
||||
if (attributeName == kAttrSplashOrigin)
|
||||
return kRectType;
|
||||
if (attributeName == kAttrSplashSize)
|
||||
return kRectType;
|
||||
if (attributeName == kAttrAnimationIndex)
|
||||
return kIntegerType;
|
||||
if (attributeName == kAttrAnimationTime)
|
||||
return kIntegerType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AnimationSplashScreenCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto* splashScreen = dynamic_cast<CAnimationSplashScreen*> (view);
|
||||
if (!splashScreen)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrSplashBitmap)
|
||||
{
|
||||
CBitmap* bitmap = splashScreen->getSplashBitmap ();
|
||||
if (bitmap)
|
||||
bitmapToString (bitmap, stringValue, desc);
|
||||
else
|
||||
stringValue = "";
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrSplashOrigin)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (splashScreen->getSplashRect ().getTopLeft ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrSplashSize)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (splashScreen->getSplashRect ().getSize ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrAnimationIndex)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (splashScreen->getAnimationIndex ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrAnimationTime)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (splashScreen->getAnimationTime ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct AnimationSplashScreenCreator : ViewCreatorAdapter
|
||||
{
|
||||
AnimationSplashScreenCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "animknobcreator.h"
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
|
||||
#include "../../lib/controls/cknob.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AnimKnobCreator::AnimKnobCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr AnimKnobCreator::getViewName () const
|
||||
{
|
||||
return kCAnimKnob;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr AnimKnobCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr AnimKnobCreator::getDisplayName () const
|
||||
{
|
||||
return "Animation Knob";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* AnimKnobCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CAnimKnob (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AnimKnobCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* animKnob = dynamic_cast<CAnimKnob*> (view);
|
||||
if (!animKnob)
|
||||
return false;
|
||||
|
||||
bool b;
|
||||
if (attributes.getBooleanAttribute (kAttrInverseBitmap, b))
|
||||
{
|
||||
animKnob->setInverseBitmap (b);
|
||||
}
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
IMultiBitmapControlCreator::apply (view, attributes, description);
|
||||
#endif
|
||||
return KnobBaseCreator::apply (view, attributes, description);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AnimKnobCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrInverseBitmap);
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
IMultiBitmapControlCreator::getAttributeNames (attributeNames);
|
||||
#endif
|
||||
return KnobBaseCreator::getAttributeNames (attributeNames);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto AnimKnobCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrInverseBitmap)
|
||||
return kBooleanType;
|
||||
auto res = KnobBaseCreator::getAttributeType (attributeName);
|
||||
if (res != kUnknownType)
|
||||
return res;
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
return IMultiBitmapControlCreator::getAttributeType (attributeName);
|
||||
#else
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AnimKnobCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* animKnob = dynamic_cast<CAnimKnob*> (view);
|
||||
if (!animKnob)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrInverseBitmap)
|
||||
{
|
||||
stringValue = animKnob->getInverseBitmap () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (KnobBaseCreator::getAttributeValue (view, attributeName, stringValue, desc))
|
||||
return true;
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
return IMultiBitmapControlCreator::getAttributeValue (view, attributeName, stringValue, desc);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "knobcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct AnimKnobCreator : KnobBaseCreator
|
||||
{
|
||||
AnimKnobCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "autoanimationcreator.h"
|
||||
|
||||
#include "../../lib/controls/cautoanimation.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
AutoAnimationCreator::AutoAnimationCreator () { UIViewFactory::registerViewCreator (*this); }
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr AutoAnimationCreator::getViewName () const { return kCAutoAnimation; }
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr AutoAnimationCreator::getBaseViewName () const { return kCControl; }
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr AutoAnimationCreator::getDisplayName () const { return "Auto Animation"; }
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* AutoAnimationCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CAutoAnimation (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AutoAnimationCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrAnimationTime);
|
||||
attributeNames.emplace_back (kAttrBitmapOffset);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto AutoAnimationCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrAnimationTime)
|
||||
return kIntegerType;
|
||||
if (attributeName == kAttrBitmapOffset)
|
||||
return kPointType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AutoAnimationCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto autoAnimation = dynamic_cast<CAutoAnimation*> (view);
|
||||
if (autoAnimation == nullptr)
|
||||
return false;
|
||||
int32_t value;
|
||||
if (attributes.getIntegerAttribute (kAttrAnimationTime, value))
|
||||
autoAnimation->setAnimationTime (static_cast<uint32_t> (value));
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
CPoint point;
|
||||
if (attributes.getPointAttribute (kAttrBitmapOffset, point))
|
||||
autoAnimation->setBitmapOffset (point);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool AutoAnimationCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto autoAnimation = dynamic_cast<CAutoAnimation*> (view);
|
||||
if (autoAnimation == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrAnimationTime)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (
|
||||
static_cast<int32_t> (autoAnimation->getAnimationTime ()));
|
||||
return true;
|
||||
}
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
if (attributeName == kAttrBitmapOffset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (autoAnimation->getBitmapOffset ());
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct AutoAnimationCreator : MultiBitmapControlCreator
|
||||
{
|
||||
AutoAnimationCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "checkboxcreator.h"
|
||||
|
||||
#include "../../lib/controls/cbuttons.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CheckBoxCreator::CheckBoxCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr CheckBoxCreator::getViewName () const
|
||||
{
|
||||
return kCCheckBox;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr CheckBoxCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr CheckBoxCreator::getDisplayName () const
|
||||
{
|
||||
return "Checkbox";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* CheckBoxCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CCheckBox (CRect (0, 0, 100, 20), nullptr, -1, "Title");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool CheckBoxCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* checkbox = dynamic_cast<CCheckBox*> (view);
|
||||
if (!checkbox)
|
||||
return false;
|
||||
|
||||
const auto* attr = attributes.getAttributeValue (kAttrTitle);
|
||||
if (attr)
|
||||
checkbox->setTitle (attr->c_str ());
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrFont);
|
||||
if (attr)
|
||||
{
|
||||
CFontRef font = description->getFont (attr->c_str ());
|
||||
if (font)
|
||||
{
|
||||
checkbox->setFont (font);
|
||||
}
|
||||
}
|
||||
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFontColor), color, description))
|
||||
checkbox->setFontColor (color);
|
||||
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrBoxframeColor), color, description))
|
||||
checkbox->setBoxFrameColor (color);
|
||||
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrBoxfillColor), color, description))
|
||||
checkbox->setBoxFillColor (color);
|
||||
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrCheckmarkColor), color, description))
|
||||
checkbox->setCheckMarkColor (color);
|
||||
|
||||
int32_t style = checkbox->getStyle ();
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrDrawCrossbox), CCheckBox::kDrawCrossBox,
|
||||
style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrAutosizeToFit), CCheckBox::kAutoSizeToFit,
|
||||
style);
|
||||
checkbox->setStyle (style);
|
||||
|
||||
double dv;
|
||||
if (attributes.getDoubleAttribute (kAttrFrameWidth, dv))
|
||||
checkbox->setFrameWidth (dv);
|
||||
if (attributes.getDoubleAttribute (kAttrRoundRectRadius, dv))
|
||||
checkbox->setRoundRectRadius (dv);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool CheckBoxCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrTitle);
|
||||
attributeNames.emplace_back (kAttrFont);
|
||||
attributeNames.emplace_back (kAttrFontColor);
|
||||
attributeNames.emplace_back (kAttrBoxframeColor);
|
||||
attributeNames.emplace_back (kAttrBoxfillColor);
|
||||
attributeNames.emplace_back (kAttrCheckmarkColor);
|
||||
attributeNames.emplace_back (kAttrFrameWidth);
|
||||
attributeNames.emplace_back (kAttrRoundRectRadius);
|
||||
attributeNames.emplace_back (kAttrAutosizeToFit);
|
||||
attributeNames.emplace_back (kAttrDrawCrossbox);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto CheckBoxCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrTitle)
|
||||
return kStringType;
|
||||
else if (attributeName == kAttrFont)
|
||||
return kFontType;
|
||||
else if (attributeName == kAttrFontColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrBoxframeColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrBoxfillColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrCheckmarkColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrFrameWidth)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrRoundRectRadius)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrAutosizeToFit)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrDrawCrossbox)
|
||||
return kBooleanType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool CheckBoxCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* checkbox = dynamic_cast<CCheckBox*> (view);
|
||||
if (!checkbox)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrTitle)
|
||||
{
|
||||
stringValue = checkbox->getTitle ().getString ();
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFont)
|
||||
{
|
||||
UTF8StringPtr fontName = desc->lookupFontName (checkbox->getFont ());
|
||||
if (fontName)
|
||||
{
|
||||
stringValue = fontName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (attributeName == kAttrFontColor)
|
||||
{
|
||||
colorToString (checkbox->getFontColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrBoxframeColor)
|
||||
{
|
||||
colorToString (checkbox->getBoxFrameColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrBoxfillColor)
|
||||
{
|
||||
colorToString (checkbox->getBoxFillColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrCheckmarkColor)
|
||||
{
|
||||
colorToString (checkbox->getCheckMarkColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrAutosizeToFit)
|
||||
{
|
||||
if (checkbox->getStyle () & CCheckBox::kAutoSizeToFit)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrDrawCrossbox)
|
||||
{
|
||||
if (checkbox->getStyle () & CCheckBox::kDrawCrossBox)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (checkbox->getFrameWidth ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrRoundRectRadius)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (checkbox->getRoundRectRadius ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct CheckBoxCreator : ViewCreatorAdapter
|
||||
{
|
||||
CheckBoxCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+183
@@ -0,0 +1,183 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "controlcreator.h"
|
||||
|
||||
#include "../../lib/controls/ccontrol.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct CControlCreatorDummyControl : CControl
|
||||
{
|
||||
CControlCreatorDummyControl () : CControl (CRect (0, 0, 40, 40), nullptr, -1) {}
|
||||
void draw (CDrawContext* pContext) override { CView::draw (pContext); }
|
||||
|
||||
CLASS_METHODS (CControlCreatorDummyControl, CControl)
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
ControlCreator::ControlCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ControlCreator::getViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ControlCreator::getBaseViewName () const
|
||||
{
|
||||
return kCView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr ControlCreator::getDisplayName () const
|
||||
{
|
||||
return "Control";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* ControlCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CControlCreatorDummyControl ();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ControlCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* control = dynamic_cast<CControl*> (view);
|
||||
if (control == nullptr)
|
||||
return false;
|
||||
|
||||
double value;
|
||||
if (attributes.getDoubleAttribute (kAttrDefaultValue, value))
|
||||
control->setDefaultValue (static_cast<float> (value));
|
||||
if (attributes.getDoubleAttribute (kAttrMinValue, value))
|
||||
control->setMin (static_cast<float> (value));
|
||||
if (attributes.getDoubleAttribute (kAttrMaxValue, value))
|
||||
control->setMax (static_cast<float> (value));
|
||||
if (attributes.getDoubleAttribute (kAttrWheelIncValue, value))
|
||||
control->setWheelInc (static_cast<float> (value));
|
||||
|
||||
const auto* controlTagAttr = attributes.getAttributeValue (kAttrControlTag);
|
||||
if (controlTagAttr)
|
||||
{
|
||||
if (controlTagAttr->length () == 0)
|
||||
{
|
||||
control->setTag (-1);
|
||||
control->setListener (nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t tag = description->getTagForName (controlTagAttr->c_str ());
|
||||
if (tag != -1)
|
||||
{
|
||||
control->setListener (description->getControlListener (controlTagAttr->c_str ()));
|
||||
control->setTag (tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* endPtr = nullptr;
|
||||
tag = (int32_t)strtol (controlTagAttr->c_str (), &endPtr, 10);
|
||||
if (endPtr != controlTagAttr->c_str ())
|
||||
{
|
||||
control->setListener (
|
||||
description->getControlListener (controlTagAttr->c_str ()));
|
||||
control->setTag (tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
control->setTag (-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ControlCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrControlTag);
|
||||
attributeNames.emplace_back (kAttrDefaultValue);
|
||||
attributeNames.emplace_back (kAttrMinValue);
|
||||
attributeNames.emplace_back (kAttrMaxValue);
|
||||
attributeNames.emplace_back (kAttrWheelIncValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto ControlCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrControlTag)
|
||||
return kTagType;
|
||||
else if (attributeName == kAttrDefaultValue)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrMinValue)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrMaxValue)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrWheelIncValue)
|
||||
return kFloatType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ControlCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* control = dynamic_cast<CControl*> (view);
|
||||
if (control == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrControlTag)
|
||||
{
|
||||
if (control->getTag () != -1)
|
||||
{
|
||||
UTF8StringPtr controlTag = desc->lookupControlTagName (control->getTag ());
|
||||
if (controlTag)
|
||||
{
|
||||
stringValue = controlTag;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (attributeName == kAttrDefaultValue)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (control->getDefaultValue ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrMinValue)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (control->getMin ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrMaxValue)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (control->getMax ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrWheelIncValue)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (control->getWheelInc (), 5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct ControlCreator : ViewCreatorAdapter
|
||||
{
|
||||
ControlCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "gradientviewcreator.h"
|
||||
|
||||
#include "../../lib/cgradientview.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto GradientViewCreator::styleStrings () -> StyleStrings&
|
||||
{
|
||||
static StyleStrings strings = {"linear", "radial"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
GradientViewCreator::GradientViewCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr GradientViewCreator::getViewName () const
|
||||
{
|
||||
return kCGradientView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr GradientViewCreator::getBaseViewName () const
|
||||
{
|
||||
return kCView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr GradientViewCreator::getDisplayName () const
|
||||
{
|
||||
return "Gradient View";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* GradientViewCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
CGradientView* gradientView = new CGradientView (CRect (0, 0, 100, 100));
|
||||
if (description)
|
||||
{
|
||||
std::list<const string*> gradients;
|
||||
description->collectGradientNames (gradients);
|
||||
if (!gradients.empty ())
|
||||
{
|
||||
gradientView->setGradient (description->getGradient (gradients.front ()->c_str ()));
|
||||
}
|
||||
}
|
||||
return gradientView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool GradientViewCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* gv = dynamic_cast<CGradientView*> (view);
|
||||
if (gv == nullptr)
|
||||
return false;
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFrameColor), color, description))
|
||||
gv->setFrameColor (color);
|
||||
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrGradientAngle, d))
|
||||
gv->setGradientAngle (d);
|
||||
if (attributes.getDoubleAttribute (kAttrRoundRectRadius, d))
|
||||
gv->setRoundRectRadius (d);
|
||||
if (attributes.getDoubleAttribute (kAttrFrameWidth, d))
|
||||
gv->setFrameWidth (d);
|
||||
|
||||
bool b;
|
||||
if (attributes.getBooleanAttribute (kAttrDrawAntialiased, b))
|
||||
gv->setDrawAntialiased (b);
|
||||
|
||||
const auto* attr = attributes.getAttributeValue (kAttrGradientStyle);
|
||||
if (attr)
|
||||
{
|
||||
if (*attr == styleStrings ()[CGradientView::kRadialGradient])
|
||||
gv->setGradientStyle (CGradientView::kRadialGradient);
|
||||
else
|
||||
gv->setGradientStyle (CGradientView::kLinearGradient);
|
||||
}
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrRadialCenter, p))
|
||||
gv->setRadialCenter (p);
|
||||
if (attributes.getDoubleAttribute (kAttrRadialRadius, d))
|
||||
gv->setRadialRadius (d);
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrGradient);
|
||||
if (attr)
|
||||
{
|
||||
CGradient* gradient = description->getGradient (attr->c_str ());
|
||||
gv->setGradient (gradient);
|
||||
}
|
||||
else
|
||||
{ // support old version
|
||||
bool hasOldGradient = true;
|
||||
CColor startColor, endColor;
|
||||
if (!stringToColor (attributes.getAttributeValue (kAttrGradientStartColor), startColor,
|
||||
description))
|
||||
hasOldGradient = false;
|
||||
if (hasOldGradient && !stringToColor (attributes.getAttributeValue (kAttrGradientEndColor),
|
||||
endColor, description))
|
||||
hasOldGradient = false;
|
||||
double startOffset = 0.0, endOffset = 1.0;
|
||||
if (hasOldGradient &&
|
||||
!attributes.getDoubleAttribute (kAttrGradientStartColorOffset, startOffset))
|
||||
hasOldGradient = false;
|
||||
if (hasOldGradient &&
|
||||
!attributes.getDoubleAttribute (kAttrGradientEndColorOffset, endOffset))
|
||||
hasOldGradient = false;
|
||||
if (hasOldGradient)
|
||||
{
|
||||
SharedPointer<CGradient> gradient =
|
||||
owned (CGradient::create (startOffset, 1. - endOffset, startColor, endColor));
|
||||
gv->setGradient (gradient);
|
||||
addGradientToUIDescription (description, gradient, "GradientView");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool GradientViewCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrGradientStyle);
|
||||
attributeNames.emplace_back (kAttrGradient);
|
||||
attributeNames.emplace_back (kAttrGradientAngle);
|
||||
attributeNames.emplace_back (kAttrRadialCenter);
|
||||
attributeNames.emplace_back (kAttrRadialRadius);
|
||||
attributeNames.emplace_back (kAttrFrameColor);
|
||||
attributeNames.emplace_back (kAttrRoundRectRadius);
|
||||
attributeNames.emplace_back (kAttrFrameWidth);
|
||||
attributeNames.emplace_back (kAttrDrawAntialiased);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto GradientViewCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrGradientStyle)
|
||||
return kListType;
|
||||
if (attributeName == kAttrGradient)
|
||||
return kGradientType;
|
||||
if (attributeName == kAttrFrameColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrGradientAngle)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrRoundRectRadius)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrFrameWidth)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrDrawAntialiased)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrRadialCenter)
|
||||
return kPointType;
|
||||
if (attributeName == kAttrRadialRadius)
|
||||
return kFloatType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool GradientViewCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* gv = dynamic_cast<CGradientView*> (view);
|
||||
if (gv == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrFrameColor)
|
||||
{
|
||||
colorToString (gv->getFrameColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrGradientAngle)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (gv->getGradientAngle ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrRoundRectRadius)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (gv->getRoundRectRadius ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrFrameWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (gv->getFrameWidth ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawAntialiased)
|
||||
{
|
||||
stringValue = gv->getDrawAntialised () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrGradientStyle)
|
||||
{
|
||||
stringValue = styleStrings ()[gv->getGradientStyle ()];
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrRadialRadius)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (gv->getRadialRadius ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrRadialCenter)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (gv->getRadialCenter ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrGradient)
|
||||
{
|
||||
CGradient* gradient = gv->getGradient ();
|
||||
UTF8StringPtr gradientName = gradient ? desc->lookupGradientName (gradient) : nullptr;
|
||||
stringValue = gradientName ? gradientName : "";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool GradientViewCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrGradientStyle)
|
||||
{
|
||||
for (auto& str : styleStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool GradientViewCreator::getAttributeValueRange (const string& attributeName, double& minValue,
|
||||
double& maxValue) const
|
||||
{
|
||||
if (attributeName == kAttrGradientAngle)
|
||||
{
|
||||
minValue = 0.;
|
||||
maxValue = 360.;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct GradientViewCreator : ViewCreatorAdapter
|
||||
{
|
||||
GradientViewCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
bool getAttributeValueRange (const string& attributeName, double& minValue,
|
||||
double& maxValue) const override;
|
||||
|
||||
private:
|
||||
using StyleStrings = std::array<string, 2>;
|
||||
static StyleStrings& styleStrings ();
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "kickbuttoncreator.h"
|
||||
|
||||
#include "../../lib/controls/cbuttons.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
KickButtonCreator::KickButtonCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr KickButtonCreator::getViewName () const
|
||||
{
|
||||
return kCKickButton;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr KickButtonCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr KickButtonCreator::getDisplayName () const
|
||||
{
|
||||
return "Kick Button";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* KickButtonCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CKickButton (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct KickButtonCreator : MultiBitmapControlCreator
|
||||
{
|
||||
KickButtonCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+403
@@ -0,0 +1,403 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "knobcreator.h"
|
||||
|
||||
#include "../../lib/controls/cknob.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool KnobBaseCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* knob = dynamic_cast<CKnobBase*> (view);
|
||||
if (!knob)
|
||||
return false;
|
||||
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrAngleStart, d))
|
||||
{
|
||||
// convert from degree
|
||||
d = d / 180.f * static_cast<float> (Constants::pi);
|
||||
knob->setStartAngle (static_cast<float> (d));
|
||||
}
|
||||
if (attributes.getDoubleAttribute (kAttrAngleRange, d))
|
||||
{
|
||||
// convert from degree
|
||||
d = d / 180.f * static_cast<float> (Constants::pi);
|
||||
knob->setRangeAngle (static_cast<float> (d));
|
||||
}
|
||||
if (attributes.getDoubleAttribute (kAttrKnobRange, d))
|
||||
knob->setKnobRange (static_cast<float> (d));
|
||||
if (attributes.getDoubleAttribute (kAttrValueInset, d))
|
||||
knob->setInsetValue (d);
|
||||
if (attributes.getDoubleAttribute (kAttrZoomFactor, d))
|
||||
knob->setZoomFactor (static_cast<float> (d));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool KnobBaseCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrAngleStart);
|
||||
attributeNames.emplace_back (kAttrAngleRange);
|
||||
attributeNames.emplace_back (kAttrKnobRange);
|
||||
attributeNames.emplace_back (kAttrValueInset);
|
||||
attributeNames.emplace_back (kAttrZoomFactor);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto KnobBaseCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrAngleStart)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrAngleRange)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrKnobRange)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrValueInset)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrZoomFactor)
|
||||
return kFloatType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool KnobBaseCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* knob = dynamic_cast<CKnobBase*> (view);
|
||||
if (!knob)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrAngleStart)
|
||||
{
|
||||
stringValue =
|
||||
UIAttributes::doubleToString ((knob->getStartAngle () / Constants::pi * 180.), 5);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrAngleRange)
|
||||
{
|
||||
stringValue =
|
||||
UIAttributes::doubleToString ((knob->getRangeAngle () / Constants::pi * 180.), 5);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrKnobRange)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (knob->getKnobRange (), 5);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrValueInset)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (knob->getInsetValue ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrZoomFactor)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (knob->getZoomFactor ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
KnobCreator::KnobCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr KnobCreator::getViewName () const
|
||||
{
|
||||
return kCKnob;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr KnobCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr KnobCreator::getDisplayName () const
|
||||
{
|
||||
return "Knob";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* KnobCreator::create (const UIAttributes& attributes, const IUIDescription* description) const
|
||||
{
|
||||
auto knob = new CKnob (CRect (0, 0, 70, 70), nullptr, -1, nullptr, nullptr);
|
||||
knob->setDrawStyle (CKnob::kCoronaDrawing | CKnob::kCoronaOutline | CKnob::kCoronaLineDashDot |
|
||||
CKnob::kCoronaLineCapButt | CKnob::kSkipHandleDrawing);
|
||||
knob->setCoronaColor (kRedCColor);
|
||||
knob->setColorShadowHandle (kBlackCColor);
|
||||
knob->setHandleLineWidth (8.);
|
||||
knob->setCoronaInset (12);
|
||||
knob->setCoronaOutlineWidthAdd (2.);
|
||||
knob->setCoronaDashDotLengths ({1.26, 0.1});
|
||||
knob->setValue (1.f);
|
||||
return knob;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool KnobCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* knob = dynamic_cast<CKnob*> (view);
|
||||
if (!knob)
|
||||
return false;
|
||||
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrCoronaInset, d))
|
||||
knob->setCoronaInset (d);
|
||||
if (attributes.getDoubleAttribute (kAttrHandleLineWidth, d))
|
||||
knob->setHandleLineWidth (d);
|
||||
if (attributes.getDoubleAttribute (kAttrCoronaOutlineWidthAdd, d))
|
||||
knob->setCoronaOutlineWidthAdd (d);
|
||||
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrCoronaColor), color, description))
|
||||
knob->setCoronaColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrHandleShadowColor), color, description))
|
||||
knob->setColorShadowHandle (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrHandleColor), color, description))
|
||||
knob->setColorHandle (color);
|
||||
|
||||
UIAttributes::StringArray dashLengthsStrings;
|
||||
if (attributes.getStringArrayAttribute (kAttrCoronaDashDotLengths, dashLengthsStrings))
|
||||
{
|
||||
CLineStyle::CoordVector lengths;
|
||||
for (auto& str : dashLengthsStrings)
|
||||
{
|
||||
double value;
|
||||
if (UIAttributes::stringToDouble (str, value))
|
||||
{
|
||||
lengths.emplace_back (value);
|
||||
}
|
||||
}
|
||||
knob->setCoronaDashDotLengths (lengths);
|
||||
}
|
||||
|
||||
CBitmap* bitmap;
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrHandleBitmap), bitmap, description))
|
||||
knob->setHandleBitmap (bitmap);
|
||||
|
||||
int32_t drawStyle = knob->getDrawStyle ();
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrCircleDrawing), CKnob::kHandleCircleDrawing,
|
||||
drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrCoronaDrawing), CKnob::kCoronaDrawing,
|
||||
drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrCoronaFromCenter), CKnob::kCoronaFromCenter,
|
||||
drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrCoronaInverted), CKnob::kCoronaInverted,
|
||||
drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrCoronaDashDot), CKnob::kCoronaLineDashDot,
|
||||
drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrCoronaOutline), CKnob::kCoronaOutline,
|
||||
drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrCoronaLineCapButt),
|
||||
CKnob::kCoronaLineCapButt, drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrSkipHandleDrawing),
|
||||
CKnob::kSkipHandleDrawing, drawStyle);
|
||||
knob->setDrawStyle (drawStyle);
|
||||
return KnobBaseCreator::apply (view, attributes, description);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool KnobCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrCircleDrawing);
|
||||
attributeNames.emplace_back (kAttrCoronaDrawing);
|
||||
attributeNames.emplace_back (kAttrCoronaOutline);
|
||||
attributeNames.emplace_back (kAttrCoronaFromCenter);
|
||||
attributeNames.emplace_back (kAttrCoronaInverted);
|
||||
attributeNames.emplace_back (kAttrCoronaDashDot);
|
||||
attributeNames.emplace_back (kAttrCoronaLineCapButt);
|
||||
attributeNames.emplace_back (kAttrSkipHandleDrawing);
|
||||
attributeNames.emplace_back (kAttrCoronaInset);
|
||||
attributeNames.emplace_back (kAttrCoronaColor);
|
||||
attributeNames.emplace_back (kAttrHandleShadowColor);
|
||||
attributeNames.emplace_back (kAttrHandleColor);
|
||||
attributeNames.emplace_back (kAttrHandleLineWidth);
|
||||
attributeNames.emplace_back (kAttrCoronaOutlineWidthAdd);
|
||||
attributeNames.emplace_back (kAttrCoronaDashDotLengths);
|
||||
attributeNames.emplace_back (kAttrHandleBitmap);
|
||||
return KnobBaseCreator::getAttributeNames (attributeNames);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto KnobCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrCircleDrawing)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrCoronaDrawing)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrCoronaOutline)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrCoronaFromCenter)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrCoronaInverted)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrCoronaDashDot)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrCoronaLineCapButt)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrSkipHandleDrawing)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrCoronaInset)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrCoronaColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrHandleShadowColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrHandleColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrHandleLineWidth)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrCoronaOutlineWidthAdd)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrCoronaDashDotLengths)
|
||||
return kStringType;
|
||||
if (attributeName == kAttrHandleBitmap)
|
||||
return kBitmapType;
|
||||
return KnobBaseCreator::getAttributeType (attributeName);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool KnobCreator::getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto* knob = dynamic_cast<CKnob*> (view);
|
||||
if (!knob)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrCoronaInset)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (knob->getCoronaInset ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrHandleLineWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (knob->getHandleLineWidth ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaOutlineWidthAdd)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (knob->getCoronaOutlineWidthAdd ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaColor)
|
||||
{
|
||||
colorToString (knob->getCoronaColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrHandleShadowColor)
|
||||
{
|
||||
colorToString (knob->getColorShadowHandle (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrHandleColor)
|
||||
{
|
||||
colorToString (knob->getColorHandle (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrHandleBitmap)
|
||||
{
|
||||
CBitmap* bitmap = knob->getHandleBitmap ();
|
||||
if (bitmap)
|
||||
{
|
||||
return bitmapToString (bitmap, stringValue, desc);
|
||||
}
|
||||
}
|
||||
if (attributeName == kAttrCircleDrawing)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kHandleCircleDrawing)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaDrawing)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kCoronaDrawing)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaFromCenter)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kCoronaFromCenter)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaInverted)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kCoronaInverted)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaDashDot)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kCoronaLineDashDot)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaOutline)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kCoronaOutline)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaLineCapButt)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kCoronaLineCapButt)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrSkipHandleDrawing)
|
||||
{
|
||||
if (knob->getDrawStyle () & CKnob::kSkipHandleDrawing)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrCoronaDashDotLengths)
|
||||
{
|
||||
const auto& lengths = knob->getCoronaDashDotLengths ();
|
||||
UIAttributes::StringArray lengthStrings;
|
||||
for (auto value : lengths)
|
||||
{
|
||||
lengthStrings.emplace_back (UIAttributes::doubleToString (value));
|
||||
}
|
||||
stringValue = UIAttributes::stringArrayToString (lengthStrings);
|
||||
return true;
|
||||
}
|
||||
return KnobBaseCreator::getAttributeValue (view, attributeName, stringValue, desc);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
@@ -0,0 +1,43 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct KnobBaseCreator : ViewCreatorAdapter
|
||||
{
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct KnobCreator : KnobBaseCreator
|
||||
{
|
||||
KnobCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "layeredviewcontainercreator.h"
|
||||
|
||||
#include "../../lib/clayeredviewcontainer.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
LayeredViewContainerCreator::LayeredViewContainerCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr LayeredViewContainerCreator::getViewName () const
|
||||
{
|
||||
return kCLayeredViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr LayeredViewContainerCreator::getBaseViewName () const
|
||||
{
|
||||
return kCViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr LayeredViewContainerCreator::getDisplayName () const
|
||||
{
|
||||
return "Layered View Container";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* LayeredViewContainerCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CLayeredViewContainer (CRect (0, 0, 100, 100));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool LayeredViewContainerCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* lvc = dynamic_cast<CLayeredViewContainer*> (view);
|
||||
if (lvc == nullptr)
|
||||
return false;
|
||||
int32_t zIndex;
|
||||
if (attributes.getIntegerAttribute (kAttrZIndex, zIndex))
|
||||
lvc->setZIndex (static_cast<uint32_t> (zIndex));
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool LayeredViewContainerCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrZIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto LayeredViewContainerCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrZIndex)
|
||||
return kIntegerType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool LayeredViewContainerCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto* lvc = dynamic_cast<CLayeredViewContainer*> (view);
|
||||
if (lvc == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrZIndex)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (static_cast<int32_t> (lvc->getZIndex ()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct LayeredViewContainerCreator : ViewCreatorAdapter
|
||||
{
|
||||
LayeredViewContainerCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "moviebitmapcreator.h"
|
||||
|
||||
#include "../../lib/controls/cmoviebitmap.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
MovieBitmapCreator::MovieBitmapCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr MovieBitmapCreator::getViewName () const
|
||||
{
|
||||
return kCMovieBitmap;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr MovieBitmapCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr MovieBitmapCreator::getDisplayName () const
|
||||
{
|
||||
return "Movie Bitmap";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* MovieBitmapCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CMovieBitmap (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct MovieBitmapCreator : MultiBitmapControlCreator
|
||||
{
|
||||
MovieBitmapCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "moviebuttoncreator.h"
|
||||
|
||||
#include "../../lib/controls/cmoviebutton.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
MovieButtonCreator::MovieButtonCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr MovieButtonCreator::getViewName () const
|
||||
{
|
||||
return kCMovieButton;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr MovieButtonCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr MovieButtonCreator::getDisplayName () const
|
||||
{
|
||||
return "Movie Button";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* MovieButtonCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CMovieButton (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct MovieButtonCreator : MultiBitmapControlCreator
|
||||
{
|
||||
MovieButtonCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
|
||||
#include "../../lib/controls/ccontrol.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool IMultiBitmapControlCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description)
|
||||
{
|
||||
auto* multiBitmapControl = dynamic_cast<IMultiBitmapControl*> (view);
|
||||
if (!multiBitmapControl)
|
||||
return false;
|
||||
|
||||
int32_t value;
|
||||
if (attributes.getIntegerAttribute (kAttrHeightOfOneImage, value))
|
||||
multiBitmapControl->setHeightOfOneImage (value);
|
||||
else
|
||||
multiBitmapControl->autoComputeHeightOfOneImage ();
|
||||
|
||||
if (attributes.getIntegerAttribute (kAttrSubPixmaps, value))
|
||||
multiBitmapControl->setNumSubPixmaps (value);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool IMultiBitmapControlCreator::getAttributeNames (StringList& attributeNames)
|
||||
{
|
||||
attributeNames.emplace_back (kAttrHeightOfOneImage);
|
||||
attributeNames.emplace_back (kAttrSubPixmaps);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IViewCreator::AttrType IMultiBitmapControlCreator::getAttributeType (const string& attributeName)
|
||||
{
|
||||
if (attributeName == kAttrHeightOfOneImage)
|
||||
return IViewCreator::AttrType::kIntegerType;
|
||||
if (attributeName == kAttrSubPixmaps)
|
||||
return IViewCreator::AttrType::kIntegerType;
|
||||
return IViewCreator::AttrType::kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool IMultiBitmapControlCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc)
|
||||
{
|
||||
auto* multiBitmapControl = dynamic_cast<IMultiBitmapControl*> (view);
|
||||
if (!multiBitmapControl)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrHeightOfOneImage)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (
|
||||
static_cast<int32_t> (multiBitmapControl->getHeightOfOneImage ()));
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrSubPixmaps)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (multiBitmapControl->getNumSubPixmaps ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
|
||||
#endif // VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
//------------------------------------------------------------------------
|
||||
struct IMultiBitmapControlCreator
|
||||
{
|
||||
using string = IViewCreator::string;
|
||||
using StringList = IViewCreator::StringList;
|
||||
|
||||
static bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description);
|
||||
static bool getAttributeNames (StringList& attributeNames);
|
||||
static IViewCreator::AttrType getAttributeType (const string& attributeName);
|
||||
static bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct MultiBitmapControlCreator : ViewCreatorAdapter
|
||||
{
|
||||
bool getAttributeNames (StringList& attributeNames) const override
|
||||
{
|
||||
return IMultiBitmapControlCreator::getAttributeNames (attributeNames);
|
||||
}
|
||||
AttrType getAttributeType (const string& attributeName) const override
|
||||
{
|
||||
return IMultiBitmapControlCreator::getAttributeType (attributeName);
|
||||
}
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override
|
||||
{
|
||||
return IMultiBitmapControlCreator::apply (view, attributes, description);
|
||||
}
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override
|
||||
{
|
||||
return IMultiBitmapControlCreator::getAttributeValue (view, attributeName, stringValue,
|
||||
desc);
|
||||
}
|
||||
};
|
||||
#else
|
||||
using MultiBitmapControlCreator = ViewCreatorAdapter;
|
||||
|
||||
#endif // VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+148
@@ -0,0 +1,148 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "multilinetextlabelcreator.h"
|
||||
|
||||
#include "../../lib/controls/ctextlabel.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto MultiLineTextLabelCreator::lineLayoutStrings () -> LineLayoutStrings&
|
||||
{
|
||||
static LineLayoutStrings strings = {"clip", "truncate", "wrap"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
MultiLineTextLabelCreator::MultiLineTextLabelCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr MultiLineTextLabelCreator::getViewName () const
|
||||
{
|
||||
return kCMultiLineTextLabel;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr MultiLineTextLabelCreator::getBaseViewName () const
|
||||
{
|
||||
return kCTextLabel;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr MultiLineTextLabelCreator::getDisplayName () const
|
||||
{
|
||||
return "Multiline Label";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* MultiLineTextLabelCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CMultiLineTextLabel (CRect (0, 0, 100, 20));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool MultiLineTextLabelCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
using LineLayout = CMultiLineTextLabel::LineLayout;
|
||||
|
||||
auto label = dynamic_cast<CMultiLineTextLabel*> (view);
|
||||
if (!label)
|
||||
return false;
|
||||
|
||||
auto attr = attributes.getAttributeValue (kAttrLineLayout);
|
||||
if (attr)
|
||||
{
|
||||
for (auto index = 0u; index <= static_cast<size_t> (LineLayout::wrap); ++index)
|
||||
{
|
||||
if (*attr == lineLayoutStrings ()[index])
|
||||
label->setLineLayout (static_cast<LineLayout> (index));
|
||||
}
|
||||
}
|
||||
bool autoHeight;
|
||||
if (attributes.getBooleanAttribute (kAttrAutoHeight, autoHeight))
|
||||
label->setAutoHeight (autoHeight);
|
||||
bool verticalCentered;
|
||||
if (attributes.getBooleanAttribute (kAttrVerticalCentered, verticalCentered))
|
||||
label->setVerticalCentered (verticalCentered);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool MultiLineTextLabelCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrLineLayout);
|
||||
attributeNames.emplace_back (kAttrAutoHeight);
|
||||
attributeNames.emplace_back (kAttrVerticalCentered);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto MultiLineTextLabelCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrLineLayout)
|
||||
return kListType;
|
||||
if (attributeName == kAttrAutoHeight)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrVerticalCentered)
|
||||
return kBooleanType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool MultiLineTextLabelCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto label = dynamic_cast<CMultiLineTextLabel*> (view);
|
||||
if (!label)
|
||||
return false;
|
||||
if (attributeName == kAttrLineLayout)
|
||||
{
|
||||
stringValue = lineLayoutStrings ()[static_cast<size_t> (label->getLineLayout ())];
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrAutoHeight)
|
||||
{
|
||||
stringValue = label->getAutoHeight () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrVerticalCentered)
|
||||
{
|
||||
stringValue = label->getVerticalCentered () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool MultiLineTextLabelCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrLineLayout)
|
||||
{
|
||||
for (auto& str : lineLayoutStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct MultiLineTextLabelCreator : ViewCreatorAdapter
|
||||
{
|
||||
MultiLineTextLabelCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
|
||||
private:
|
||||
using LineLayoutStrings = std::array<string, 3>;
|
||||
static LineLayoutStrings& lineLayoutStrings ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "onoffbuttoncreator.h"
|
||||
|
||||
#include "../../lib/controls/cbuttons.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
OnOffButtonCreator::OnOffButtonCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr OnOffButtonCreator::getViewName () const
|
||||
{
|
||||
return kCOnOffButton;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr OnOffButtonCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr OnOffButtonCreator::getDisplayName () const
|
||||
{
|
||||
return "OnOff Button";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* OnOffButtonCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new COnOffButton (CRect (0, 0, 20, 20), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct OnOffButtonCreator : ViewCreatorAdapter
|
||||
{
|
||||
OnOffButtonCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "optionmenucreator.h"
|
||||
|
||||
#include "../../lib/controls/coptionmenu.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
OptionMenuCreator::OptionMenuCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr OptionMenuCreator::getViewName () const
|
||||
{
|
||||
return kCOptionMenu;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr OptionMenuCreator::getBaseViewName () const
|
||||
{
|
||||
return kCParamDisplay;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr OptionMenuCreator::getDisplayName () const
|
||||
{
|
||||
return "Option Menu";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* OptionMenuCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new COptionMenu (CRect (0, 0, 100, 20), nullptr, -1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool OptionMenuCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* menu = dynamic_cast<COptionMenu*> (view);
|
||||
if (!menu)
|
||||
return false;
|
||||
|
||||
int32_t style = menu->getStyle ();
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrMenuPopupStyle), COptionMenu::kPopupStyle,
|
||||
style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrMenuCheckStyle), COptionMenu::kCheckStyle,
|
||||
style);
|
||||
menu->setStyle (style);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool OptionMenuCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrMenuPopupStyle);
|
||||
attributeNames.emplace_back (kAttrMenuCheckStyle);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto OptionMenuCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrMenuPopupStyle)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrMenuCheckStyle)
|
||||
return kBooleanType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool OptionMenuCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* menu = dynamic_cast<COptionMenu*> (view);
|
||||
if (!menu)
|
||||
return false;
|
||||
if (attributeName == kAttrMenuPopupStyle)
|
||||
{
|
||||
stringValue = (menu->getStyle () & COptionMenu::kPopupStyle) ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrMenuCheckStyle)
|
||||
{
|
||||
stringValue = (menu->getStyle () & COptionMenu::kCheckStyle) ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct OptionMenuCreator : ViewCreatorAdapter
|
||||
{
|
||||
OptionMenuCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "paramdisplaycreator.h"
|
||||
|
||||
#include "../../lib/controls/cparamdisplay.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
ParamDisplayCreator::ParamDisplayCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ParamDisplayCreator::getViewName () const
|
||||
{
|
||||
return kCParamDisplay;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ParamDisplayCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr ParamDisplayCreator::getDisplayName () const
|
||||
{
|
||||
return "Parameter Display";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* ParamDisplayCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CParamDisplay (CRect (0, 0, 100, 20));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ParamDisplayCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* display = dynamic_cast<CParamDisplay*> (view);
|
||||
if (!display)
|
||||
return false;
|
||||
|
||||
const auto* fontAttr = attributes.getAttributeValue (kAttrFont);
|
||||
if (fontAttr)
|
||||
{
|
||||
CFontRef font = description->getFont (fontAttr->c_str ());
|
||||
if (font)
|
||||
{
|
||||
display->setFont (font);
|
||||
}
|
||||
}
|
||||
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFontColor), color, description))
|
||||
display->setFontColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrBackColor), color, description))
|
||||
display->setBackColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFrameColor), color, description))
|
||||
display->setFrameColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrShadowColor), color, description))
|
||||
display->setShadowColor (color);
|
||||
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrTextInset, p))
|
||||
display->setTextInset (p);
|
||||
if (attributes.getPointAttribute (kAttrTextShadowOffset, p))
|
||||
display->setShadowTextOffset (p);
|
||||
if (attributes.getPointAttribute (kAttrBackgroundOffset, p))
|
||||
display->setBackOffset (p);
|
||||
bool b;
|
||||
if (attributes.getBooleanAttribute (kAttrFontAntialias, b))
|
||||
display->setAntialias (b);
|
||||
|
||||
const auto* textAlignmentAttr = attributes.getAttributeValue (kAttrTextAlignment);
|
||||
if (textAlignmentAttr)
|
||||
{
|
||||
CHoriTxtAlign align = kCenterText;
|
||||
if (*textAlignmentAttr == strLeft)
|
||||
align = kLeftText;
|
||||
else if (*textAlignmentAttr == strRight)
|
||||
align = kRightText;
|
||||
display->setHoriAlign (align);
|
||||
}
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrRoundRectRadius, d))
|
||||
display->setRoundRectRadius (d);
|
||||
if (attributes.getDoubleAttribute (kAttrFrameWidth, d))
|
||||
display->setFrameWidth (d);
|
||||
if (attributes.getDoubleAttribute (kAttrTextRotation, d))
|
||||
display->setTextRotation (d);
|
||||
|
||||
int32_t style = display->getStyle ();
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyle3DIn), CParamDisplay::k3DIn, style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyle3DOut), CParamDisplay::k3DOut, style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyleNoFrame), CParamDisplay::kNoFrame,
|
||||
style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyleNoDraw), CParamDisplay::kNoDrawStyle,
|
||||
style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyleNoText), CParamDisplay::kNoTextStyle,
|
||||
style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyleShadowText), CParamDisplay::kShadowText,
|
||||
style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyleRoundRect),
|
||||
CParamDisplay::kRoundRectStyle, style);
|
||||
display->setStyle (style);
|
||||
|
||||
const auto* precisionAttr = attributes.getAttributeValue (kAttrValuePrecision);
|
||||
if (precisionAttr)
|
||||
{
|
||||
uint8_t precision = (uint8_t)strtol (precisionAttr->c_str (), nullptr, 10);
|
||||
display->setPrecision (precision);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ParamDisplayCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrFont);
|
||||
attributeNames.emplace_back (kAttrFontColor);
|
||||
attributeNames.emplace_back (kAttrBackColor);
|
||||
attributeNames.emplace_back (kAttrFrameColor);
|
||||
attributeNames.emplace_back (kAttrShadowColor);
|
||||
attributeNames.emplace_back (kAttrRoundRectRadius);
|
||||
attributeNames.emplace_back (kAttrFrameWidth);
|
||||
attributeNames.emplace_back (kAttrTextAlignment);
|
||||
attributeNames.emplace_back (kAttrTextInset);
|
||||
attributeNames.emplace_back (kAttrTextShadowOffset);
|
||||
attributeNames.emplace_back (kAttrValuePrecision);
|
||||
attributeNames.emplace_back (kAttrBackgroundOffset);
|
||||
attributeNames.emplace_back (kAttrFontAntialias);
|
||||
attributeNames.emplace_back (kAttrStyle3DIn);
|
||||
attributeNames.emplace_back (kAttrStyle3DOut);
|
||||
attributeNames.emplace_back (kAttrStyleNoFrame);
|
||||
attributeNames.emplace_back (kAttrStyleNoText);
|
||||
attributeNames.emplace_back (kAttrStyleNoDraw);
|
||||
attributeNames.emplace_back (kAttrStyleShadowText);
|
||||
attributeNames.emplace_back (kAttrStyleRoundRect);
|
||||
attributeNames.emplace_back (kAttrTextRotation);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto ParamDisplayCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrFont)
|
||||
return kFontType;
|
||||
else if (attributeName == kAttrFontColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrBackColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrFrameColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrShadowColor)
|
||||
return kColorType;
|
||||
else if (attributeName == kAttrFontAntialias)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrStyle3DIn)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrStyle3DOut)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrStyleNoFrame)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrStyleNoText)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrStyleNoDraw)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrStyleShadowText)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrStyleRoundRect)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrRoundRectRadius)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrFrameWidth)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrTextAlignment)
|
||||
return kStringType;
|
||||
else if (attributeName == kAttrTextInset)
|
||||
return kPointType;
|
||||
else if (attributeName == kAttrTextShadowOffset)
|
||||
return kPointType;
|
||||
else if (attributeName == kAttrValuePrecision)
|
||||
return kIntegerType;
|
||||
else if (attributeName == kAttrTextRotation)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrBackgroundOffset)
|
||||
return kPointType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ParamDisplayCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* pd = dynamic_cast<CParamDisplay*> (view);
|
||||
if (pd == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrFont)
|
||||
{
|
||||
UTF8StringPtr fontName = desc->lookupFontName (pd->getFont ());
|
||||
if (fontName)
|
||||
{
|
||||
stringValue = fontName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (attributeName == kAttrFontColor)
|
||||
{
|
||||
colorToString (pd->getFontColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrBackColor)
|
||||
{
|
||||
colorToString (pd->getBackColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameColor)
|
||||
{
|
||||
colorToString (pd->getFrameColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrShadowColor)
|
||||
{
|
||||
colorToString (pd->getShadowColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextInset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (pd->getTextInset ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextShadowOffset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (pd->getShadowTextOffset ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFontAntialias)
|
||||
{
|
||||
stringValue = pd->getAntialias () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyle3DIn)
|
||||
{
|
||||
stringValue = pd->getStyle () & CParamDisplay::k3DIn ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyle3DOut)
|
||||
{
|
||||
stringValue = pd->getStyle () & CParamDisplay::k3DOut ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyleNoFrame)
|
||||
{
|
||||
stringValue = pd->getStyle () & CParamDisplay::kNoFrame ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyleNoText)
|
||||
{
|
||||
stringValue = pd->getStyle () & CParamDisplay::kNoTextStyle ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyleNoDraw)
|
||||
{
|
||||
stringValue = pd->getStyle () & CParamDisplay::kNoDrawStyle ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyleShadowText)
|
||||
{
|
||||
stringValue = pd->getStyle () & CParamDisplay::kShadowText ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyleRoundRect)
|
||||
{
|
||||
stringValue = pd->getStyle () & CParamDisplay::kRoundRectStyle ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrRoundRectRadius)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (pd->getRoundRectRadius ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (pd->getFrameWidth ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextAlignment)
|
||||
{
|
||||
CHoriTxtAlign align = pd->getHoriAlign ();
|
||||
switch (align)
|
||||
{
|
||||
case kLeftText: stringValue = strLeft; break;
|
||||
case kRightText: stringValue = strRight; break;
|
||||
case kCenterText: stringValue = strCenter; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrValuePrecision)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (static_cast<int32_t> (pd->getPrecision ()));
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextRotation)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (pd->getTextRotation ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrBackgroundOffset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (pd->getBackOffset ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ParamDisplayCreator::getAttributeValueRange (const string& attributeName, double& minValue,
|
||||
double& maxValue) const
|
||||
{
|
||||
if (attributeName == kAttrTextRotation)
|
||||
{
|
||||
minValue = 0.;
|
||||
maxValue = 360.;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct ParamDisplayCreator : ViewCreatorAdapter
|
||||
{
|
||||
ParamDisplayCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getAttributeValueRange (const string& attributeName, double& minValue,
|
||||
double& maxValue) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "rockerswitchcreator.h"
|
||||
|
||||
#include "../../lib/controls/cswitch.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
RockerSwitchCreator::RockerSwitchCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr RockerSwitchCreator::getViewName () const
|
||||
{
|
||||
return kCRockerSwitch;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr RockerSwitchCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr RockerSwitchCreator::getDisplayName () const
|
||||
{
|
||||
return "Rocker Switch";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* RockerSwitchCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CRockerSwitch (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct RockerSwitchCreator : MultiBitmapControlCreator
|
||||
{
|
||||
RockerSwitchCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "rowcolumnviewcreator.h"
|
||||
|
||||
#include "../../lib/crowcolumnview.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto RowColumnViewCreator::layoutStrings () -> LayoutStrings&
|
||||
{
|
||||
static LayoutStrings strings = {
|
||||
"left-top", "center", "right-bottom", "stretch", "top-left",
|
||||
"top-center", "top-right", "middle-left", "middle-center", "middle-right",
|
||||
"bottom-left", "bottom-center", "bottom-right"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
RowColumnViewCreator::RowColumnViewCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr RowColumnViewCreator::getViewName () const
|
||||
{
|
||||
return kCRowColumnView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr RowColumnViewCreator::getBaseViewName () const
|
||||
{
|
||||
return kCViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr RowColumnViewCreator::getDisplayName () const
|
||||
{
|
||||
return "Row Column View Container";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* RowColumnViewCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CRowColumnView (CRect (0, 0, 100, 100));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool RowColumnViewCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* rcv = dynamic_cast<CRowColumnView*> (view);
|
||||
if (rcv == nullptr)
|
||||
return false;
|
||||
const auto* attr = attributes.getAttributeValue (kAttrRowStyle);
|
||||
if (attr)
|
||||
rcv->setStyle (*attr == strTrue ? CRowColumnView::kRowStyle : CRowColumnView::kColumnStyle);
|
||||
attr = attributes.getAttributeValue (kAttrSpacing);
|
||||
if (attr)
|
||||
{
|
||||
CCoord spacing = UTF8StringView (attr->c_str ()).toDouble ();
|
||||
rcv->setSpacing (spacing);
|
||||
}
|
||||
CRect margin;
|
||||
if (attributes.getRectAttribute (kAttrMargin, margin))
|
||||
rcv->setMargin (margin);
|
||||
attr = attributes.getAttributeValue (kAttrAnimateViewResizing);
|
||||
if (attr)
|
||||
rcv->setAnimateViewResizing (*attr == strTrue ? true : false);
|
||||
attr = attributes.getAttributeValue (kAttrHideClippedSubviews);
|
||||
if (attr)
|
||||
rcv->setHideClippedSubviews (*attr == strTrue ? true : false);
|
||||
attr = attributes.getAttributeValue (kAttrEqualSizeLayout);
|
||||
if (attr)
|
||||
{
|
||||
for (auto index = 0u; index <= CRowColumnView::kBottomRight; ++index)
|
||||
{
|
||||
if (*attr == layoutStrings ()[index])
|
||||
{
|
||||
rcv->setLayoutStyle (static_cast<CRowColumnView::LayoutStyle> (index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
attr = attributes.getAttributeValue (kAttrViewResizeAnimationTime);
|
||||
if (attr)
|
||||
{
|
||||
uint32_t time = (uint32_t)strtol (attr->c_str (), nullptr, 10);
|
||||
rcv->setViewResizeAnimationTime (time);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool RowColumnViewCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrRowStyle);
|
||||
attributeNames.emplace_back (kAttrSpacing);
|
||||
attributeNames.emplace_back (kAttrMargin);
|
||||
attributeNames.emplace_back (kAttrEqualSizeLayout);
|
||||
attributeNames.emplace_back (kAttrHideClippedSubviews);
|
||||
attributeNames.emplace_back (kAttrAnimateViewResizing);
|
||||
attributeNames.emplace_back (kAttrViewResizeAnimationTime);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto RowColumnViewCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrRowStyle)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrSpacing)
|
||||
return kIntegerType;
|
||||
if (attributeName == kAttrMargin)
|
||||
return kRectType;
|
||||
if (attributeName == kAttrEqualSizeLayout)
|
||||
return kListType;
|
||||
if (attributeName == kAttrHideClippedSubviews)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrAnimateViewResizing)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrViewResizeAnimationTime)
|
||||
return kIntegerType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool RowColumnViewCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* rcv = dynamic_cast<CRowColumnView*> (view);
|
||||
if (rcv == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrRowStyle)
|
||||
{
|
||||
stringValue = rcv->getStyle () == CRowColumnView::kRowStyle ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrAnimateViewResizing)
|
||||
{
|
||||
stringValue = rcv->isAnimateViewResizing () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrHideClippedSubviews)
|
||||
{
|
||||
stringValue = rcv->hideClippedSubviews () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrSpacing)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (static_cast<int32_t> (rcv->getSpacing ()));
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrViewResizeAnimationTime)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (
|
||||
static_cast<int32_t> (rcv->getViewResizeAnimationTime ()));
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrMargin)
|
||||
{
|
||||
stringValue = UIAttributes::rectToString (rcv->getMargin ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrEqualSizeLayout)
|
||||
{
|
||||
stringValue = layoutStrings ()[rcv->getLayoutStyle ()];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool RowColumnViewCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrEqualSizeLayout)
|
||||
{
|
||||
for (auto& str : layoutStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct RowColumnViewCreator : ViewCreatorAdapter
|
||||
{
|
||||
RowColumnViewCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
|
||||
private:
|
||||
using LayoutStrings = std::array<string, 13>;
|
||||
static LayoutStrings& layoutStrings ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "scrollviewcreator.h"
|
||||
|
||||
#include "../../lib/controls/cscrollbar.h"
|
||||
#include "../../lib/cscrollview.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
ScrollViewCreator::ScrollViewCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ScrollViewCreator::getViewName () const
|
||||
{
|
||||
return kCScrollView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ScrollViewCreator::getBaseViewName () const
|
||||
{
|
||||
return kCViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr ScrollViewCreator::getDisplayName () const
|
||||
{
|
||||
return "Scroll View";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* ScrollViewCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CScrollView (CRect (0, 0, 100, 100), CRect (0, 0, 200, 200),
|
||||
CScrollView::kHorizontalScrollbar | CScrollView::kVerticalScrollbar);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ScrollViewCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* scrollView = dynamic_cast<CScrollView*> (view);
|
||||
if (scrollView == nullptr)
|
||||
return false;
|
||||
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrContainerSize, p))
|
||||
{
|
||||
CRect r;
|
||||
r.setSize (p);
|
||||
scrollView->setContainerSize (r);
|
||||
}
|
||||
|
||||
int32_t style = scrollView->getStyle ();
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrHorizontalScrollbar),
|
||||
CScrollView::kHorizontalScrollbar, style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrVerticalScrollbar),
|
||||
CScrollView::kVerticalScrollbar, style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrAutoDragScrolling),
|
||||
CScrollView::kAutoDragScrolling, style);
|
||||
const auto* attr = attributes.getAttributeValue (kAttrBordered);
|
||||
if (attr)
|
||||
{
|
||||
setBit (style, CScrollView::kDontDrawFrame, *attr != strTrue);
|
||||
}
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrOverlayScrollbars),
|
||||
CScrollView::kOverlayScrollbars, style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrFollowFocusView),
|
||||
CScrollView::kFollowFocusView, style);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrAutoHideScrollbars),
|
||||
CScrollView::kAutoHideScrollbars, style);
|
||||
scrollView->setStyle (style);
|
||||
CColor color;
|
||||
CScrollbar* vscrollbar = scrollView->getVerticalScrollbar ();
|
||||
CScrollbar* hscrollbar = scrollView->getHorizontalScrollbar ();
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrScrollbarBackgroundColor), color,
|
||||
description))
|
||||
{
|
||||
if (vscrollbar)
|
||||
vscrollbar->setBackgroundColor (color);
|
||||
if (hscrollbar)
|
||||
hscrollbar->setBackgroundColor (color);
|
||||
}
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrScrollbarFrameColor), color, description))
|
||||
{
|
||||
if (vscrollbar)
|
||||
vscrollbar->setFrameColor (color);
|
||||
if (hscrollbar)
|
||||
hscrollbar->setFrameColor (color);
|
||||
}
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrScrollbarScrollerColor), color,
|
||||
description))
|
||||
{
|
||||
if (vscrollbar)
|
||||
vscrollbar->setScrollerColor (color);
|
||||
if (hscrollbar)
|
||||
hscrollbar->setScrollerColor (color);
|
||||
}
|
||||
CCoord width;
|
||||
if (attributes.getDoubleAttribute (kAttrScrollbarWidth, width))
|
||||
scrollView->setScrollbarWidth (width);
|
||||
if (attributes.getDoubleAttribute (kAttrMinScrollerSize, width))
|
||||
{
|
||||
if (vscrollbar)
|
||||
vscrollbar->setMinScrollerLength (width);
|
||||
if (hscrollbar)
|
||||
hscrollbar->setMinScrollerLength (width);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ScrollViewCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrContainerSize);
|
||||
attributeNames.emplace_back (kAttrScrollbarBackgroundColor);
|
||||
attributeNames.emplace_back (kAttrScrollbarFrameColor);
|
||||
attributeNames.emplace_back (kAttrScrollbarScrollerColor);
|
||||
attributeNames.emplace_back (kAttrHorizontalScrollbar);
|
||||
attributeNames.emplace_back (kAttrVerticalScrollbar);
|
||||
attributeNames.emplace_back (kAttrAutoHideScrollbars);
|
||||
attributeNames.emplace_back (kAttrAutoDragScrolling);
|
||||
attributeNames.emplace_back (kAttrOverlayScrollbars);
|
||||
attributeNames.emplace_back (kAttrScrollbarWidth);
|
||||
attributeNames.emplace_back (kAttrMinScrollerSize);
|
||||
attributeNames.emplace_back (kAttrBordered);
|
||||
attributeNames.emplace_back (kAttrFollowFocusView);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto ScrollViewCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrContainerSize)
|
||||
return kPointType;
|
||||
if (attributeName == kAttrScrollbarBackgroundColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrScrollbarFrameColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrScrollbarScrollerColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrHorizontalScrollbar)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrVerticalScrollbar)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrAutoHideScrollbars)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrAutoDragScrolling)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrOverlayScrollbars)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrScrollbarWidth)
|
||||
return kIntegerType;
|
||||
if (attributeName == kAttrMinScrollerSize)
|
||||
return kIntegerType;
|
||||
if (attributeName == kAttrBordered)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrFollowFocusView)
|
||||
return kBooleanType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ScrollViewCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* sc = dynamic_cast<CScrollView*> (view);
|
||||
if (sc == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrContainerSize)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (sc->getContainerSize ().getSize ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrScrollbarWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (sc->getScrollbarWidth ());
|
||||
return true;
|
||||
}
|
||||
CScrollbar* scrollbar = sc->getVerticalScrollbar ();
|
||||
if (!scrollbar)
|
||||
scrollbar = sc->getHorizontalScrollbar ();
|
||||
if (scrollbar)
|
||||
{
|
||||
if (attributeName == kAttrScrollbarBackgroundColor)
|
||||
{
|
||||
colorToString (scrollbar->getBackgroundColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrScrollbarFrameColor)
|
||||
{
|
||||
colorToString (scrollbar->getFrameColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrScrollbarScrollerColor)
|
||||
{
|
||||
colorToString (scrollbar->getScrollerColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrMinScrollerSize)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (scrollbar->getMinScrollerLength ());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (attributeName == kAttrHorizontalScrollbar)
|
||||
{
|
||||
stringValue = sc->getStyle () & CScrollView::kHorizontalScrollbar ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrVerticalScrollbar)
|
||||
{
|
||||
stringValue = sc->getStyle () & CScrollView::kVerticalScrollbar ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrAutoHideScrollbars)
|
||||
{
|
||||
stringValue = sc->getStyle () & CScrollView::kAutoHideScrollbars ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrAutoDragScrolling)
|
||||
{
|
||||
stringValue = sc->getStyle () & CScrollView::kAutoDragScrolling ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrBordered)
|
||||
{
|
||||
stringValue = sc->getStyle () & CScrollView::kDontDrawFrame ? strFalse : strTrue;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrOverlayScrollbars)
|
||||
{
|
||||
stringValue = sc->getStyle () & CScrollView::kOverlayScrollbars ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrFollowFocusView)
|
||||
{
|
||||
stringValue = sc->getStyle () & CScrollView::kFollowFocusView ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct ScrollViewCreator : ViewCreatorAdapter
|
||||
{
|
||||
ScrollViewCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "searchtexteditcreator.h"
|
||||
|
||||
#include "../../lib/controls/csearchtextedit.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
SearchTextEditCreator::SearchTextEditCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SearchTextEditCreator::getViewName () const
|
||||
{
|
||||
return kCSearchTextEdit;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SearchTextEditCreator::getBaseViewName () const
|
||||
{
|
||||
return kCTextEdit;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr SearchTextEditCreator::getDisplayName () const
|
||||
{
|
||||
return "Search Text Edit";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* SearchTextEditCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CSearchTextEdit (CRect (0, 0, 100, 20), nullptr, -1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SearchTextEditCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto ste = dynamic_cast<CSearchTextEdit*> (view);
|
||||
if (!ste)
|
||||
return false;
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrClearMarkInset, p))
|
||||
ste->setClearMarkInset (p);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SearchTextEditCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrClearMarkInset);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SearchTextEditCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrClearMarkInset)
|
||||
return kPointType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SearchTextEditCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto ste = dynamic_cast<CSearchTextEdit*> (view);
|
||||
if (!ste)
|
||||
return false;
|
||||
if (attributeName == kAttrClearMarkInset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (ste->getClearMarkInset ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct SearchTextEditCreator : ViewCreatorAdapter
|
||||
{
|
||||
SearchTextEditCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+402
@@ -0,0 +1,402 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "segmentbuttoncreator.h"
|
||||
|
||||
#include "../../lib/controls/csegmentbutton.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
#include <sstream>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SegmentButtonCreator::selectionModeStrings ()->SelectionModeStrings&
|
||||
{
|
||||
static SelectionModeStrings strings = {"Single", "Single-Toggle", "Multiple"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
SegmentButtonCreator::SegmentButtonCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SegmentButtonCreator::getViewName () const
|
||||
{
|
||||
return kCSegmentButton;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SegmentButtonCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr SegmentButtonCreator::getDisplayName () const
|
||||
{
|
||||
return "Segment Button";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* SegmentButtonCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
CSegmentButton* button = new CSegmentButton (CRect (0, 0, 200, 20));
|
||||
updateSegmentCount (button, 4);
|
||||
return button;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void SegmentButtonCreator::updateSegmentCount (CSegmentButton* button, uint32_t numSegments) const
|
||||
{
|
||||
if (button->getSegments ().size () != numSegments)
|
||||
{
|
||||
button->removeAllSegments ();
|
||||
for (uint32_t i = 0; i < numSegments; i++)
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "Segment ";
|
||||
str << i + 1;
|
||||
CSegmentButton::Segment seg;
|
||||
seg.name = str.str ().c_str ();
|
||||
button->addSegment (std::move (seg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void SegmentButtonCreator::updateSegments (CSegmentButton* button,
|
||||
const UIAttributes::StringArray& names) const
|
||||
{
|
||||
button->removeAllSegments ();
|
||||
for (const auto& name : names)
|
||||
{
|
||||
CSegmentButton::Segment segment;
|
||||
segment.name = name.c_str ();
|
||||
button->addSegment (std::move (segment));
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SegmentButtonCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* button = dynamic_cast<CSegmentButton*> (view);
|
||||
if (!button)
|
||||
return false;
|
||||
|
||||
const auto* attr = attributes.getAttributeValue (kAttrFont);
|
||||
if (attr)
|
||||
{
|
||||
CFontRef font = description->getFont (attr->c_str ());
|
||||
if (font)
|
||||
{
|
||||
button->setFont (font);
|
||||
}
|
||||
}
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrStyle);
|
||||
if (attr)
|
||||
{
|
||||
if (*attr == strHorizontal)
|
||||
button->setStyle (CSegmentButton::Style::kHorizontal);
|
||||
else if (*attr == strVertical)
|
||||
button->setStyle (CSegmentButton::Style::kVertical);
|
||||
else if (*attr == strHorizontalInverse)
|
||||
button->setStyle (CSegmentButton::Style::kHorizontalInverse);
|
||||
else if (*attr == strVerticalInverse)
|
||||
button->setStyle (CSegmentButton::Style::kVerticalInverse);
|
||||
}
|
||||
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrTextColor), color, description))
|
||||
button->setTextColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrTextColorHighlighted), color,
|
||||
description))
|
||||
button->setTextColorHighlighted (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFrameColor), color, description))
|
||||
button->setFrameColor (color);
|
||||
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrFrameWidth, d))
|
||||
button->setFrameWidth (d);
|
||||
if (attributes.getDoubleAttribute (kAttrRoundRadius, d))
|
||||
button->setRoundRadius (d);
|
||||
if (attributes.getDoubleAttribute (kAttrIconTextMargin, d))
|
||||
button->setTextMargin (d);
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrTextAlignment);
|
||||
if (attr)
|
||||
{
|
||||
CHoriTxtAlign align = kCenterText;
|
||||
if (*attr == strLeft)
|
||||
align = kLeftText;
|
||||
else if (*attr == strRight)
|
||||
align = kRightText;
|
||||
button->setTextAlignment (align);
|
||||
}
|
||||
const auto* gradientName = attributes.getAttributeValue (kAttrGradient);
|
||||
if (gradientName)
|
||||
button->setGradient (description->getGradient (gradientName->c_str ()));
|
||||
const auto* gradientHighlightedName = attributes.getAttributeValue (kAttrGradientHighlighted);
|
||||
if (gradientHighlightedName)
|
||||
button->setGradientHighlighted (
|
||||
description->getGradient (gradientHighlightedName->c_str ()));
|
||||
|
||||
UIAttributes::StringArray segmentNames;
|
||||
if (attributes.getStringArrayAttribute (kAttrSegmentNames, segmentNames))
|
||||
updateSegments (button, segmentNames);
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrTruncateMode);
|
||||
if (attr)
|
||||
{
|
||||
if (*attr == strHead)
|
||||
button->setTextTruncateMode (CDrawMethods::kTextTruncateHead);
|
||||
else if (*attr == strTail)
|
||||
button->setTextTruncateMode (CDrawMethods::kTextTruncateTail);
|
||||
else
|
||||
button->setTextTruncateMode (CDrawMethods::kTextTruncateNone);
|
||||
}
|
||||
attr = attributes.getAttributeValue (kAttrSelectionMode);
|
||||
if (attr)
|
||||
{
|
||||
using SelectionMode = CSegmentButton::SelectionMode;
|
||||
for (auto index = 0u; index <= static_cast<size_t> (SelectionMode::kMultiple); ++index)
|
||||
{
|
||||
if (*attr == selectionModeStrings ()[index])
|
||||
{
|
||||
button->setSelectionMode (static_cast<SelectionMode> (index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SegmentButtonCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrStyle);
|
||||
attributeNames.emplace_back (kAttrSelectionMode);
|
||||
attributeNames.emplace_back (kAttrSegmentNames);
|
||||
attributeNames.emplace_back (kAttrFont);
|
||||
attributeNames.emplace_back (kAttrTextColor);
|
||||
attributeNames.emplace_back (kAttrTextColorHighlighted);
|
||||
attributeNames.emplace_back (kAttrGradient);
|
||||
attributeNames.emplace_back (kAttrGradientHighlighted);
|
||||
attributeNames.emplace_back (kAttrFrameColor);
|
||||
attributeNames.emplace_back (kAttrRoundRadius);
|
||||
attributeNames.emplace_back (kAttrFrameWidth);
|
||||
attributeNames.emplace_back (kAttrIconTextMargin);
|
||||
attributeNames.emplace_back (kAttrTextAlignment);
|
||||
attributeNames.emplace_back (kAttrTruncateMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SegmentButtonCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrStyle)
|
||||
return kListType;
|
||||
if (attributeName == kAttrSelectionMode)
|
||||
return kListType;
|
||||
if (attributeName == kAttrSegmentNames)
|
||||
return kStringType;
|
||||
if (attributeName == kAttrFont)
|
||||
return kFontType;
|
||||
if (attributeName == kAttrTextColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrTextColorHighlighted)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrGradient)
|
||||
return kGradientType;
|
||||
if (attributeName == kAttrGradientHighlighted)
|
||||
return kGradientType;
|
||||
if (attributeName == kAttrFrameColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrFrameWidth)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrRoundRadius)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrIconTextMargin)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrTextAlignment)
|
||||
return kStringType;
|
||||
if (attributeName == kAttrTruncateMode)
|
||||
return kListType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SegmentButtonCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrStyle)
|
||||
{
|
||||
if (getStandardAttributeListValues (kAttrOrientation, values))
|
||||
{
|
||||
static std::string kHorizontalInverse = strHorizontalInverse;
|
||||
static std::string kVerticalInverse = strVerticalInverse;
|
||||
|
||||
values.emplace_back (&kHorizontalInverse);
|
||||
values.emplace_back (&kVerticalInverse);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (attributeName == kAttrSelectionMode)
|
||||
{
|
||||
for (auto& str : selectionModeStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTruncateMode)
|
||||
{
|
||||
return getStandardAttributeListValues (kAttrTruncateMode, values);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SegmentButtonCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* button = dynamic_cast<CSegmentButton*> (view);
|
||||
if (!button)
|
||||
return false;
|
||||
if (attributeName == kAttrFont)
|
||||
{
|
||||
UTF8StringPtr fontName = desc->lookupFontName (button->getFont ());
|
||||
if (fontName)
|
||||
{
|
||||
stringValue = fontName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (attributeName == kAttrSegmentNames)
|
||||
{
|
||||
const CSegmentButton::Segments& segments = button->getSegments ();
|
||||
UIAttributes::StringArray stringArray;
|
||||
for (const auto& segment : segments)
|
||||
stringArray.emplace_back (segment.name.getString ());
|
||||
stringValue = UIAttributes::stringArrayToString (stringArray);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextColor)
|
||||
{
|
||||
colorToString (button->getTextColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextColorHighlighted)
|
||||
{
|
||||
colorToString (button->getTextColorHighlighted (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameColor)
|
||||
{
|
||||
colorToString (button->getFrameColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (button->getFrameWidth ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrRoundRadius)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (button->getRoundRadius ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyle)
|
||||
{
|
||||
switch (button->getStyle ())
|
||||
{
|
||||
case CSegmentButton::Style::kHorizontal:
|
||||
{
|
||||
stringValue = strHorizontal;
|
||||
return true;
|
||||
}
|
||||
case CSegmentButton::Style::kHorizontalInverse:
|
||||
{
|
||||
stringValue = strHorizontalInverse;
|
||||
return true;
|
||||
}
|
||||
case CSegmentButton::Style::kVertical:
|
||||
{
|
||||
stringValue = strVertical;
|
||||
return true;
|
||||
}
|
||||
case CSegmentButton::Style::kVerticalInverse:
|
||||
{
|
||||
stringValue = strVerticalInverse;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (attributeName == kAttrIconTextMargin)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (button->getTextMargin ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextAlignment)
|
||||
{
|
||||
CHoriTxtAlign align = button->getTextAlignment ();
|
||||
switch (align)
|
||||
{
|
||||
case kLeftText: stringValue = strLeft; break;
|
||||
case kRightText: stringValue = strRight; break;
|
||||
case kCenterText: stringValue = strCenter; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrGradient)
|
||||
{
|
||||
CGradient* gradient = button->getGradient ();
|
||||
if (gradient)
|
||||
{
|
||||
UTF8StringPtr gradientName = desc->lookupGradientName (gradient);
|
||||
stringValue = gradientName ? gradientName : "";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrGradientHighlighted)
|
||||
{
|
||||
CGradient* gradient = button->getGradientHighlighted ();
|
||||
if (gradient)
|
||||
{
|
||||
UTF8StringPtr gradientName = desc->lookupGradientName (gradient);
|
||||
stringValue = gradientName ? gradientName : "";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTruncateMode)
|
||||
{
|
||||
switch (button->getTextTruncateMode ())
|
||||
{
|
||||
case CDrawMethods::kTextTruncateHead: stringValue = strHead; break;
|
||||
case CDrawMethods::kTextTruncateTail: stringValue = strTail; break;
|
||||
case CDrawMethods::kTextTruncateNone: stringValue = ""; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrSelectionMode)
|
||||
{
|
||||
stringValue = selectionModeStrings ()[static_cast<size_t> (button->getSelectionMode ())];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
#include "../uiattributes.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct SegmentButtonCreator : ViewCreatorAdapter
|
||||
{
|
||||
SegmentButtonCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
|
||||
private:
|
||||
void updateSegmentCount (CSegmentButton* button, uint32_t numSegments) const;
|
||||
void updateSegments (CSegmentButton* button, const UIAttributes::StringArray& names) const;
|
||||
|
||||
using SelectionModeStrings = std::array<string, 3>;
|
||||
static SelectionModeStrings& selectionModeStrings ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+134
@@ -0,0 +1,134 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "shadowviewcontainercreator.h"
|
||||
|
||||
#include "../../lib/cshadowviewcontainer.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
ShadowViewContainerCreator::ShadowViewContainerCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ShadowViewContainerCreator::getViewName () const
|
||||
{
|
||||
return kCShadowViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ShadowViewContainerCreator::getBaseViewName () const
|
||||
{
|
||||
return kCViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr ShadowViewContainerCreator::getDisplayName () const
|
||||
{
|
||||
return "Shadow View Container";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* ShadowViewContainerCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CShadowViewContainer (CRect (0, 0, 200, 200));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ShadowViewContainerCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* shadowView = dynamic_cast<CShadowViewContainer*> (view);
|
||||
if (!shadowView)
|
||||
return false;
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrShadowIntensity, d))
|
||||
shadowView->setShadowIntensity (static_cast<float> (d));
|
||||
if (attributes.getDoubleAttribute (kAttrShadowBlurSize, d))
|
||||
shadowView->setShadowBlurSize (d);
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrShadowOffset, p))
|
||||
shadowView->setShadowOffset (p);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ShadowViewContainerCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrShadowIntensity);
|
||||
attributeNames.emplace_back (kAttrShadowOffset);
|
||||
attributeNames.emplace_back (kAttrShadowBlurSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto ShadowViewContainerCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrShadowIntensity)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrShadowOffset)
|
||||
return kPointType;
|
||||
if (attributeName == kAttrShadowBlurSize)
|
||||
return kFloatType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ShadowViewContainerCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto* shadowView = dynamic_cast<CShadowViewContainer*> (view);
|
||||
if (!shadowView)
|
||||
return false;
|
||||
if (attributeName == kAttrShadowIntensity)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (shadowView->getShadowIntensity ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrShadowBlurSize)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (shadowView->getShadowBlurSize ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrShadowOffset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (shadowView->getShadowOffset ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ShadowViewContainerCreator::getAttributeValueRange (const string& attributeName,
|
||||
double& minValue, double& maxValue) const
|
||||
{
|
||||
if (attributeName == kAttrShadowBlurSize)
|
||||
{
|
||||
minValue = 0.8;
|
||||
maxValue = 20;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrShadowIntensity)
|
||||
{
|
||||
minValue = 0;
|
||||
maxValue = 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct ShadowViewContainerCreator : ViewCreatorAdapter
|
||||
{
|
||||
ShadowViewContainerCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getAttributeValueRange (const string& attributeName, double& minValue,
|
||||
double& maxValue) const override;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+406
@@ -0,0 +1,406 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "sliderviewcreator.h"
|
||||
|
||||
#include "../../lib/controls/cslider.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SliderBaseCreator::modeStrings () -> ModeStrings&
|
||||
{
|
||||
static ModeStrings strings = {"touch", "relative touch", "free click", "ramp", "use global"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SliderBaseCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* slider = dynamic_cast<CSliderBase*> (view);
|
||||
if (!slider)
|
||||
return false;
|
||||
|
||||
// support old attribute name and convert it
|
||||
const auto* freeClickAttr = attributes.getAttributeValue ("free-click");
|
||||
if (freeClickAttr)
|
||||
{
|
||||
slider->setSliderMode (*freeClickAttr == strTrue ? CSliderMode::FreeClick :
|
||||
CSliderMode::Touch);
|
||||
}
|
||||
|
||||
const auto* modeAttr = attributes.getAttributeValue (kAttrMode);
|
||||
if (modeAttr)
|
||||
{
|
||||
for (auto index = 0u; index <= static_cast<size_t> (CSliderMode::UseGlobal); ++index)
|
||||
{
|
||||
if (*modeAttr == modeStrings ()[index])
|
||||
{
|
||||
slider->setSliderMode (static_cast<CSliderMode> (index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrHandleOffset, p))
|
||||
slider->setOffsetHandle (p);
|
||||
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrZoomFactor, d))
|
||||
slider->setZoomFactor (static_cast<float> (d));
|
||||
|
||||
const auto* orientationAttr = attributes.getAttributeValue (kAttrOrientation);
|
||||
if (orientationAttr)
|
||||
{
|
||||
auto style = slider->getStyle ();
|
||||
if (*orientationAttr == strVertical)
|
||||
{
|
||||
style ^= CSlider::kHorizontal;
|
||||
style |= CSlider::kVertical;
|
||||
}
|
||||
else
|
||||
{
|
||||
style ^= CSlider::kVertical;
|
||||
style |= CSlider::kHorizontal;
|
||||
}
|
||||
slider->setStyle (style);
|
||||
}
|
||||
const auto* reverseOrientationAttr = attributes.getAttributeValue (kAttrReverseOrientation);
|
||||
if (reverseOrientationAttr)
|
||||
{
|
||||
auto style = slider->getStyle ();
|
||||
if (*reverseOrientationAttr == strTrue)
|
||||
{
|
||||
if (style & CSlider::kVertical)
|
||||
{
|
||||
style ^= CSlider::kBottom;
|
||||
style |= CSlider::kTop;
|
||||
}
|
||||
else if (style & CSlider::kHorizontal)
|
||||
{
|
||||
style ^= CSlider::kLeft;
|
||||
style |= CSlider::kRight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (style & CSlider::kVertical)
|
||||
{
|
||||
style ^= CSlider::kTop;
|
||||
style |= CSlider::kBottom;
|
||||
}
|
||||
else if (style & CSlider::kHorizontal)
|
||||
{
|
||||
style ^= CSlider::kRight;
|
||||
style |= CSlider::kLeft;
|
||||
}
|
||||
}
|
||||
slider->setStyle (style);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SliderBaseCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrMode);
|
||||
attributeNames.emplace_back (kAttrOrientation);
|
||||
attributeNames.emplace_back (kAttrReverseOrientation);
|
||||
attributeNames.emplace_back (kAttrHandleOffset);
|
||||
attributeNames.emplace_back (kAttrZoomFactor);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SliderBaseCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrMode)
|
||||
return kListType;
|
||||
if (attributeName == kAttrHandleOffset)
|
||||
return kPointType;
|
||||
if (attributeName == kAttrZoomFactor)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrOrientation)
|
||||
return kListType;
|
||||
if (attributeName == kAttrReverseOrientation)
|
||||
return kBooleanType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SliderBaseCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* slider = dynamic_cast<CSliderBase*> (view);
|
||||
if (!slider)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrMode)
|
||||
{
|
||||
stringValue = modeStrings ()[static_cast<size_t> (slider->getSliderMode ())];
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrHandleOffset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (slider->getOffsetHandle ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrZoomFactor)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (slider->getZoomFactor ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrOrientation)
|
||||
{
|
||||
if (slider->getStyle () & CSlider::kVertical)
|
||||
stringValue = strVertical;
|
||||
else
|
||||
stringValue = strHorizontal;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrReverseOrientation)
|
||||
{
|
||||
auto style = slider->getStyle ();
|
||||
stringValue = strFalse;
|
||||
if (((style & CSlider::kVertical) && (style & CSlider::kTop)) ||
|
||||
((style & CSlider::kHorizontal) && (style & CSlider::kRight)))
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SliderBaseCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrOrientation)
|
||||
{
|
||||
return getStandardAttributeListValues (kAttrOrientation, values);
|
||||
}
|
||||
if (attributeName == kAttrMode)
|
||||
{
|
||||
for (auto& str : modeStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
SliderCreator::SliderCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SliderCreator::getViewName () const
|
||||
{
|
||||
return kCSlider;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SliderCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr SliderCreator::getDisplayName () const
|
||||
{
|
||||
return "Slider";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* SliderCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CSlider (CRect (0, 0, 0, 0), nullptr, -1, 0, 0, nullptr, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SliderCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* slider = dynamic_cast<CSlider*> (view);
|
||||
if (!slider)
|
||||
return false;
|
||||
|
||||
CBitmap* bitmap;
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrHandleBitmap), bitmap, description))
|
||||
slider->setHandle (bitmap);
|
||||
|
||||
CPoint p;
|
||||
if (attributes.getPointAttribute (kAttrBitmapOffset, p))
|
||||
slider->setBackgroundOffset (p);
|
||||
|
||||
int32_t drawStyle = slider->getDrawStyle ();
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrDrawFrame), CSlider::kDrawFrame, drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrDrawBack), CSlider::kDrawBack, drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrDrawValue), CSlider::kDrawValue, drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrDrawValueFromCenter),
|
||||
CSlider::kDrawValueFromCenter, drawStyle);
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrDrawValueInverted), CSlider::kDrawInverted,
|
||||
drawStyle);
|
||||
slider->setDrawStyle (drawStyle);
|
||||
|
||||
CCoord lineWidth;
|
||||
if (attributes.getDoubleAttribute (kAttrFrameWidth, lineWidth))
|
||||
slider->setFrameWidth (lineWidth);
|
||||
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrDrawFrameColor), color, description))
|
||||
slider->setFrameColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrDrawBackColor), color, description))
|
||||
slider->setBackColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrDrawValueColor), color, description))
|
||||
slider->setValueColor (color);
|
||||
return SliderBaseCreator::apply (view, attributes, description);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SliderCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
SliderBaseCreator::getAttributeNames (attributeNames);
|
||||
attributeNames.emplace_back (kAttrHandleBitmap);
|
||||
attributeNames.emplace_back (kAttrBitmapOffset);
|
||||
attributeNames.emplace_back (kAttrDrawFrame);
|
||||
attributeNames.emplace_back (kAttrDrawBack);
|
||||
attributeNames.emplace_back (kAttrDrawValue);
|
||||
attributeNames.emplace_back (kAttrDrawValueFromCenter);
|
||||
attributeNames.emplace_back (kAttrDrawValueInverted);
|
||||
attributeNames.emplace_back (kAttrFrameWidth);
|
||||
attributeNames.emplace_back (kAttrDrawFrameColor);
|
||||
attributeNames.emplace_back (kAttrDrawBackColor);
|
||||
attributeNames.emplace_back (kAttrDrawValueColor);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SliderCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrHandleBitmap)
|
||||
return kBitmapType;
|
||||
if (attributeName == kAttrBitmapOffset)
|
||||
return kPointType;
|
||||
if (attributeName == kAttrDrawFrame)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrDrawBack)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrDrawValue)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrDrawValueFromCenter)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrDrawValueInverted)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrFrameWidth)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrDrawFrameColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrDrawBackColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrDrawValueColor)
|
||||
return kColorType;
|
||||
return SliderBaseCreator::getAttributeType (attributeName);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SliderCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* slider = dynamic_cast<CSlider*> (view);
|
||||
if (!slider)
|
||||
return false;
|
||||
if (attributeName == kAttrHandleBitmap)
|
||||
{
|
||||
CBitmap* bitmap = slider->getHandle ();
|
||||
if (bitmap)
|
||||
{
|
||||
bitmapToString (bitmap, stringValue, desc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrBitmapOffset)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (slider->getBackgroundOffset ());
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawFrame)
|
||||
{
|
||||
if (slider->getDrawStyle () & CSlider::kDrawFrame)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawBack)
|
||||
{
|
||||
if (slider->getDrawStyle () & CSlider::kDrawBack)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawValue)
|
||||
{
|
||||
if (slider->getDrawStyle () & CSlider::kDrawValue)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawValueFromCenter)
|
||||
{
|
||||
if (slider->getDrawStyle () & CSlider::kDrawValueFromCenter)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawValueInverted)
|
||||
{
|
||||
if (slider->getDrawStyle () & CSlider::kDrawInverted)
|
||||
stringValue = strTrue;
|
||||
else
|
||||
stringValue = strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawFrameColor)
|
||||
{
|
||||
colorToString (slider->getFrameColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawBackColor)
|
||||
{
|
||||
colorToString (slider->getBackColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrDrawValueColor)
|
||||
{
|
||||
colorToString (slider->getValueColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrFrameWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (slider->getFrameWidth ());
|
||||
return true;
|
||||
}
|
||||
return SliderBaseCreator::getAttributeValue (view, attributeName, stringValue, desc);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct SliderBaseCreator : ViewCreatorAdapter
|
||||
{
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
|
||||
private:
|
||||
using ModeStrings = std::array<string, 5>;
|
||||
static ModeStrings& modeStrings ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct SliderCreator : SliderBaseCreator
|
||||
{
|
||||
SliderCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "splitviewcreator.h"
|
||||
|
||||
#include "../../lib/csplitview.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SplitViewCreator::resizeModeStrings () -> ResizeModeStrings&
|
||||
{
|
||||
static ResizeModeStrings strings = {"first", "second", "last", "all"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
SplitViewCreator::SplitViewCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SplitViewCreator::getViewName () const
|
||||
{
|
||||
return kCSplitView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr SplitViewCreator::getBaseViewName () const
|
||||
{
|
||||
return kCViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr SplitViewCreator::getDisplayName () const
|
||||
{
|
||||
return "Split View";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* SplitViewCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CSplitView (CRect (0, 0, 100, 100));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SplitViewCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* splitView = dynamic_cast<CSplitView*> (view);
|
||||
if (!splitView)
|
||||
return false;
|
||||
|
||||
int32_t width;
|
||||
if (attributes.getIntegerAttribute (kAttrSeparatorWidth, width))
|
||||
splitView->setSeparatorWidth (width);
|
||||
const auto* attr = attributes.getAttributeValue (kAttrOrientation);
|
||||
if (attr)
|
||||
{
|
||||
if (*attr == strHorizontal)
|
||||
{
|
||||
splitView->setStyle (CSplitView::kHorizontal);
|
||||
}
|
||||
else
|
||||
{
|
||||
splitView->setStyle (CSplitView::kVertical);
|
||||
}
|
||||
}
|
||||
attr = attributes.getAttributeValue (kAttrResizeMethod);
|
||||
if (attr)
|
||||
{
|
||||
for (auto index = 0u; index <= CSplitView::kResizeAllViews; ++index)
|
||||
{
|
||||
if (*attr == resizeModeStrings ()[index])
|
||||
{
|
||||
splitView->setResizeMethod (static_cast<CSplitView::ResizeMethod> (index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SplitViewCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrOrientation);
|
||||
attributeNames.emplace_back (kAttrResizeMethod);
|
||||
attributeNames.emplace_back (kAttrSeparatorWidth);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SplitViewCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrOrientation)
|
||||
return kListType;
|
||||
if (attributeName == kAttrResizeMethod)
|
||||
return kListType;
|
||||
if (attributeName == kAttrSeparatorWidth)
|
||||
return kIntegerType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SplitViewCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* splitView = dynamic_cast<CSplitView*> (view);
|
||||
if (!splitView)
|
||||
return false;
|
||||
if (attributeName == kAttrSeparatorWidth)
|
||||
{
|
||||
stringValue =
|
||||
UIAttributes::integerToString (static_cast<int32_t> (splitView->getSeparatorWidth ()));
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrOrientation)
|
||||
{
|
||||
stringValue =
|
||||
splitView->getStyle () == CSplitView::kHorizontal ? strHorizontal : strVertical;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrResizeMethod)
|
||||
{
|
||||
stringValue = resizeModeStrings ()[splitView->getResizeMethod ()];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SplitViewCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrOrientation)
|
||||
{
|
||||
return getStandardAttributeListValues (kAttrOrientation, values);
|
||||
}
|
||||
else if (attributeName == kAttrResizeMethod)
|
||||
{
|
||||
for (auto& str : resizeModeStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct SplitViewCreator : ViewCreatorAdapter
|
||||
{
|
||||
SplitViewCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
|
||||
private:
|
||||
using ResizeModeStrings = std::array<string, 4>;
|
||||
static ResizeModeStrings& resizeModeStrings ();
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+253
@@ -0,0 +1,253 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "stringlistcontrolcreator.h"
|
||||
|
||||
#include "../../lib/controls/cstringlist.h"
|
||||
#include "../../lib/ccolor.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
StringListControlCreator::StringListControlCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr StringListControlCreator::getViewName () const
|
||||
{
|
||||
return kCStringListControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr StringListControlCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr StringListControlCreator::getDisplayName () const
|
||||
{
|
||||
return "String List Control";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* StringListControlCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto control = new CListControl (CRect (0, 0, 100, 200));
|
||||
auto drawer = makeOwned<StringListControlDrawer> ();
|
||||
control->setDrawer (drawer);
|
||||
auto configurator = makeOwned<StaticListControlConfigurator> (12.);
|
||||
control->setConfigurator (configurator);
|
||||
return control;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool StringListControlCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrStyleHover);
|
||||
attributeNames.emplace_back (kAttrFont);
|
||||
attributeNames.emplace_back (kAttrFontColor);
|
||||
attributeNames.emplace_back (kAttrSelectedFontColor);
|
||||
attributeNames.emplace_back (kAttrBackColor);
|
||||
attributeNames.emplace_back (kAttrSelectedBackColor);
|
||||
attributeNames.emplace_back (kAttrHoverColor);
|
||||
attributeNames.emplace_back (kAttrLineColor);
|
||||
attributeNames.emplace_back (kAttrLineWidth);
|
||||
attributeNames.emplace_back (kAttrTextInset);
|
||||
attributeNames.emplace_back (kAttrRowHeight);
|
||||
attributeNames.emplace_back (kAttrTextAlignment);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto StringListControlCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrFont)
|
||||
return kFontType;
|
||||
if (attributeName == kAttrFontColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrSelectedFontColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrBackColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrSelectedBackColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrHoverColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrLineColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrLineWidth)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrTextInset)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrRowHeight)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrStyleHover)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrTextAlignment)
|
||||
return kStringType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool StringListControlCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto control = dynamic_cast<CListControl*> (view);
|
||||
if (!control)
|
||||
return false;
|
||||
auto drawer = dynamic_cast<StringListControlDrawer*> (control->getDrawer ());
|
||||
auto configurator = dynamic_cast<StaticListControlConfigurator*> (control->getConfigurator ());
|
||||
if (!drawer || !configurator)
|
||||
return false;
|
||||
|
||||
if (const auto* fontAttr = attributes.getAttributeValue (kAttrFont))
|
||||
{
|
||||
if (auto font = description->getFont (fontAttr->data ()))
|
||||
drawer->setFont (font);
|
||||
}
|
||||
if (const auto* textAlignmentAttr = attributes.getAttributeValue (kAttrTextAlignment))
|
||||
{
|
||||
CHoriTxtAlign align = kCenterText;
|
||||
if (*textAlignmentAttr == strLeft)
|
||||
align = kLeftText;
|
||||
else if (*textAlignmentAttr == strRight)
|
||||
align = kRightText;
|
||||
drawer->setTextAlign (align);
|
||||
}
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFontColor), color, description))
|
||||
drawer->setFontColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrSelectedFontColor), color, description))
|
||||
drawer->setSelectedFontColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrBackColor), color, description))
|
||||
drawer->setBackColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrSelectedBackColor), color, description))
|
||||
drawer->setSelectedBackColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrHoverColor), color, description))
|
||||
drawer->setHoverColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrLineColor), color, description))
|
||||
drawer->setLineColor (color);
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrLineWidth, d))
|
||||
drawer->setLineWidth (d);
|
||||
if (attributes.getDoubleAttribute (kAttrTextInset, d))
|
||||
drawer->setTextInset (d);
|
||||
if (attributes.getDoubleAttribute (kAttrRowHeight, d))
|
||||
configurator->setRowHeight (d);
|
||||
bool b;
|
||||
if (attributes.getBooleanAttribute (kAttrStyleHover, b))
|
||||
{
|
||||
CListControlRowDesc::Flags f (CListControlRowDesc::Selectable);
|
||||
if (b)
|
||||
f |= CListControlRowDesc::Hoverable;
|
||||
configurator->setFlags (f);
|
||||
}
|
||||
control->invalid ();
|
||||
control->recalculateLayout ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool StringListControlCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto control = dynamic_cast<CListControl*> (view);
|
||||
if (!control)
|
||||
return false;
|
||||
auto drawer = dynamic_cast<StringListControlDrawer*> (control->getDrawer ());
|
||||
auto configurator = dynamic_cast<StaticListControlConfigurator*> (control->getConfigurator ());
|
||||
if (!drawer || !configurator)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrFont)
|
||||
{
|
||||
UTF8StringPtr fontName = desc->lookupFontName (drawer->getFont ());
|
||||
if (fontName)
|
||||
{
|
||||
stringValue = fontName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (attributeName == kAttrFontColor)
|
||||
{
|
||||
colorToString (drawer->getFontColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrSelectedFontColor)
|
||||
{
|
||||
colorToString (drawer->getSelectedFontColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrBackColor)
|
||||
{
|
||||
colorToString (drawer->getBackColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrSelectedBackColor)
|
||||
{
|
||||
colorToString (drawer->getSelectedBackColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrHoverColor)
|
||||
{
|
||||
colorToString (drawer->getHoverColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrLineColor)
|
||||
{
|
||||
colorToString (drawer->getLineColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrLineWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (drawer->getLineWidth ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextInset)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (drawer->getTextInset ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrRowHeight)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (configurator->getRowHeight ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrStyleHover)
|
||||
{
|
||||
stringValue =
|
||||
UIAttributes::boolToString (configurator->getFlags () & CListControlRowDesc::Hoverable);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextAlignment)
|
||||
{
|
||||
CHoriTxtAlign align = drawer->getTextAlign ();
|
||||
switch (align)
|
||||
{
|
||||
case kLeftText: stringValue = strLeft; break;
|
||||
case kRightText: stringValue = strRight; break;
|
||||
case kCenterText: stringValue = strCenter; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct StringListControlCreator : ViewCreatorAdapter
|
||||
{
|
||||
StringListControlCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "multibitmapcontrolcreator.h"
|
||||
#include "switchcreators.h"
|
||||
|
||||
#include "../../lib/controls/cswitch.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SwitchBaseCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrInverseBitmap);
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
return IMultiBitmapControlCreator::getAttributeNames (attributeNames);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto SwitchBaseCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrInverseBitmap)
|
||||
return kBooleanType;
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
return IMultiBitmapControlCreator::getAttributeType (attributeName);
|
||||
#else
|
||||
return kUnknownType;
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SwitchBaseCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto control = dynamic_cast<CSwitchBase*> (view);
|
||||
if (!control)
|
||||
return false;
|
||||
|
||||
bool b;
|
||||
if (attributes.getBooleanAttribute (kAttrInverseBitmap, b))
|
||||
{
|
||||
control->setInverseBitmap (b);
|
||||
}
|
||||
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
return IMultiBitmapControlCreator::apply (view, attributes, description);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool SwitchBaseCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto control = dynamic_cast<CSwitchBase*> (view);
|
||||
if (!control)
|
||||
return false;
|
||||
|
||||
if (attributeName == kAttrInverseBitmap)
|
||||
{
|
||||
stringValue = control->getInverseBitmap () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
#if VSTGUI_ENABLE_DEPRECATED_METHODS
|
||||
return IMultiBitmapControlCreator::getAttributeValue (view, attributeName, stringValue, desc);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
VerticalSwitchCreator::VerticalSwitchCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr VerticalSwitchCreator::getViewName () const
|
||||
{
|
||||
return kCVerticalSwitch;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr VerticalSwitchCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr VerticalSwitchCreator::getDisplayName () const
|
||||
{
|
||||
return "Vertical Switch";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* VerticalSwitchCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CVerticalSwitch (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
HorizontalSwitchCreator::HorizontalSwitchCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr HorizontalSwitchCreator::getViewName () const
|
||||
{
|
||||
return kCHorizontalSwitch;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr HorizontalSwitchCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr HorizontalSwitchCreator::getDisplayName () const
|
||||
{
|
||||
return "Horizontal Switch";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* HorizontalSwitchCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CHorizontalSwitch (CRect (0, 0, 0, 0), nullptr, -1, nullptr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct SwitchBaseCreator : ViewCreatorAdapter
|
||||
{
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct VerticalSwitchCreator : SwitchBaseCreator
|
||||
{
|
||||
VerticalSwitchCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct HorizontalSwitchCreator : SwitchBaseCreator
|
||||
{
|
||||
HorizontalSwitchCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+366
@@ -0,0 +1,366 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "textbuttoncreator.h"
|
||||
|
||||
#include "../../lib/controls/cbuttons.h"
|
||||
#include "../../lib/algorithm.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto TextButtonCreator::getPositionStrings () -> PositionStringArray&
|
||||
{
|
||||
static PositionStringArray positionsStrings = {
|
||||
{strLeft, "center above text", "center below text", strRight}};
|
||||
static_assert (positionsStrings.size () == CDrawMethods::kIconRight + 1, "Update needed!");
|
||||
return positionsStrings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
TextButtonCreator::TextButtonCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr TextButtonCreator::getViewName () const
|
||||
{
|
||||
return kCTextButton;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr TextButtonCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr TextButtonCreator::getDisplayName () const
|
||||
{
|
||||
return "Text Button";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* TextButtonCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
CTextButton* button = new CTextButton (CRect (0, 0, 100, 20), nullptr, -1, "");
|
||||
if (!description->lookupGradientName (button->getGradient ()))
|
||||
addGradientToUIDescription (description, button->getGradient (),
|
||||
"Default TextButton Gradient");
|
||||
if (!description->lookupGradientName (button->getGradientHighlighted ()))
|
||||
addGradientToUIDescription (description, button->getGradientHighlighted (),
|
||||
"Default TextButton Gradient Highlighted");
|
||||
return button;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextButtonCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* button = dynamic_cast<CTextButton*> (view);
|
||||
if (!button)
|
||||
return false;
|
||||
|
||||
const auto* attr = attributes.getAttributeValue (kAttrTitle);
|
||||
if (attr)
|
||||
button->setTitle (attr->c_str ());
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrFont);
|
||||
if (attr)
|
||||
{
|
||||
CFontRef font = description->getFont (attr->c_str ());
|
||||
if (font)
|
||||
{
|
||||
button->setFont (font);
|
||||
}
|
||||
}
|
||||
|
||||
CColor color;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrTextColor), color, description))
|
||||
button->setTextColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrTextColorHighlighted), color,
|
||||
description))
|
||||
button->setTextColorHighlighted (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFrameColor), color, description))
|
||||
button->setFrameColor (color);
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrFrameColorHighlighted), color,
|
||||
description))
|
||||
button->setFrameColorHighlighted (color);
|
||||
|
||||
double d;
|
||||
if (attributes.getDoubleAttribute (kAttrFrameWidth, d))
|
||||
button->setFrameWidth (d);
|
||||
if (attributes.getDoubleAttribute (kAttrRoundRadius, d))
|
||||
button->setRoundRadius (d);
|
||||
if (attributes.getDoubleAttribute (kAttrIconTextMargin, d))
|
||||
button->setTextMargin (d);
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrKickStyle);
|
||||
if (attr)
|
||||
{
|
||||
button->setStyle (*attr == strTrue ? CTextButton::kKickStyle : CTextButton::kOnOffStyle);
|
||||
}
|
||||
|
||||
CBitmap* bitmap;
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrIcon), bitmap, description))
|
||||
button->setIcon (bitmap);
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrIconHighlighted), bitmap, description))
|
||||
button->setIconHighlighted (bitmap);
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrIconPosition);
|
||||
if (attr)
|
||||
{
|
||||
if (auto index =
|
||||
indexOf (getPositionStrings ().begin (), getPositionStrings ().end (), *attr))
|
||||
button->setIconPosition (static_cast<CDrawMethods::IconPosition> (*index));
|
||||
}
|
||||
attr = attributes.getAttributeValue (kAttrTextAlignment);
|
||||
if (attr)
|
||||
{
|
||||
CHoriTxtAlign align = kCenterText;
|
||||
if (*attr == strLeft)
|
||||
align = kLeftText;
|
||||
else if (*attr == strRight)
|
||||
align = kRightText;
|
||||
button->setTextAlignment (align);
|
||||
}
|
||||
const auto* gradientName = attributes.getAttributeValue (kAttrGradient);
|
||||
if (gradientName)
|
||||
button->setGradient (description->getGradient (gradientName->c_str ()));
|
||||
const auto* gradientHighlightedName = attributes.getAttributeValue (kAttrGradientHighlighted);
|
||||
if (gradientHighlightedName)
|
||||
button->setGradientHighlighted (
|
||||
description->getGradient (gradientHighlightedName->c_str ()));
|
||||
|
||||
if (gradientName == nullptr && gradientHighlightedName == nullptr)
|
||||
{
|
||||
bool hasOldGradient = true;
|
||||
CColor startColor, highlightedStartColor, endColor, highlightedEndColor;
|
||||
if (!stringToColor (attributes.getAttributeValue (kAttrGradientStartColor), startColor,
|
||||
description))
|
||||
hasOldGradient = false;
|
||||
if (hasOldGradient &&
|
||||
!stringToColor (attributes.getAttributeValue (kAttrGradientStartColorHighlighted),
|
||||
highlightedStartColor, description))
|
||||
hasOldGradient = false;
|
||||
if (hasOldGradient && !stringToColor (attributes.getAttributeValue (kAttrGradientEndColor),
|
||||
endColor, description))
|
||||
hasOldGradient = false;
|
||||
if (hasOldGradient &&
|
||||
!stringToColor (attributes.getAttributeValue (kAttrGradientEndColorHighlighted),
|
||||
highlightedEndColor, description))
|
||||
hasOldGradient = false;
|
||||
if (hasOldGradient)
|
||||
{
|
||||
SharedPointer<CGradient> gradient =
|
||||
owned (CGradient::create (0, 1, startColor, endColor));
|
||||
button->setGradient (gradient);
|
||||
addGradientToUIDescription (description, gradient, "TextButton");
|
||||
gradient = owned (CGradient::create (0, 1, highlightedStartColor, highlightedEndColor));
|
||||
button->setGradientHighlighted (gradient);
|
||||
addGradientToUIDescription (description, gradient, "TextButton Highlighted");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextButtonCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrKickStyle);
|
||||
attributeNames.emplace_back (kAttrTitle);
|
||||
attributeNames.emplace_back (kAttrFont);
|
||||
attributeNames.emplace_back (kAttrTextColor);
|
||||
attributeNames.emplace_back (kAttrTextColorHighlighted);
|
||||
attributeNames.emplace_back (kAttrGradient);
|
||||
attributeNames.emplace_back (kAttrGradientHighlighted);
|
||||
attributeNames.emplace_back (kAttrFrameColor);
|
||||
attributeNames.emplace_back (kAttrFrameColorHighlighted);
|
||||
attributeNames.emplace_back (kAttrRoundRadius);
|
||||
attributeNames.emplace_back (kAttrFrameWidth);
|
||||
attributeNames.emplace_back (kAttrIconTextMargin);
|
||||
attributeNames.emplace_back (kAttrTextAlignment);
|
||||
attributeNames.emplace_back (kAttrIcon);
|
||||
attributeNames.emplace_back (kAttrIconHighlighted);
|
||||
attributeNames.emplace_back (kAttrIconPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto TextButtonCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrTitle)
|
||||
return kStringType;
|
||||
if (attributeName == kAttrFont)
|
||||
return kFontType;
|
||||
if (attributeName == kAttrTextColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrTextColorHighlighted)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrGradient)
|
||||
return kGradientType;
|
||||
if (attributeName == kAttrGradientHighlighted)
|
||||
return kGradientType;
|
||||
if (attributeName == kAttrFrameColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrFrameColorHighlighted)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrFrameWidth)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrRoundRadius)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrKickStyle)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrIcon)
|
||||
return kBitmapType;
|
||||
if (attributeName == kAttrIconHighlighted)
|
||||
return kBitmapType;
|
||||
if (attributeName == kAttrIconPosition)
|
||||
return kListType;
|
||||
if (attributeName == kAttrIconTextMargin)
|
||||
return kFloatType;
|
||||
if (attributeName == kAttrTextAlignment)
|
||||
return kStringType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextButtonCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrIconPosition)
|
||||
{
|
||||
for (const auto& s : getPositionStrings ())
|
||||
values.emplace_back (&s);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextButtonCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* button = dynamic_cast<CTextButton*> (view);
|
||||
if (!button)
|
||||
return false;
|
||||
if (attributeName == kAttrTitle)
|
||||
{
|
||||
stringValue = button->getTitle ().getString ();
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFont)
|
||||
{
|
||||
UTF8StringPtr fontName = desc->lookupFontName (button->getFont ());
|
||||
if (fontName)
|
||||
{
|
||||
stringValue = fontName;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (attributeName == kAttrTextColor)
|
||||
{
|
||||
colorToString (button->getTextColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextColorHighlighted)
|
||||
{
|
||||
colorToString (button->getTextColorHighlighted (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameColor)
|
||||
{
|
||||
colorToString (button->getFrameColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameColorHighlighted)
|
||||
{
|
||||
colorToString (button->getFrameColorHighlighted (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrFrameWidth)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (button->getFrameWidth ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrRoundRadius)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (button->getRoundRadius ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrKickStyle)
|
||||
{
|
||||
stringValue = button->getStyle () == CTextButton::kKickStyle ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrIcon)
|
||||
{
|
||||
CBitmap* bitmap = button->getIcon ();
|
||||
if (bitmap)
|
||||
{
|
||||
return bitmapToString (bitmap, stringValue, desc);
|
||||
}
|
||||
}
|
||||
else if (attributeName == kAttrIconHighlighted)
|
||||
{
|
||||
CBitmap* bitmap = button->getIconHighlighted ();
|
||||
if (bitmap)
|
||||
{
|
||||
return bitmapToString (bitmap, stringValue, desc);
|
||||
}
|
||||
}
|
||||
else if (attributeName == kAttrIconPosition)
|
||||
{
|
||||
auto pos = button->getIconPosition ();
|
||||
vstgui_assert (pos < getPositionStrings ().size ());
|
||||
stringValue = getPositionStrings ()[pos];
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrIconTextMargin)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (button->getTextMargin ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTextAlignment)
|
||||
{
|
||||
CHoriTxtAlign align = button->getTextAlignment ();
|
||||
switch (align)
|
||||
{
|
||||
case kLeftText: stringValue = strLeft; break;
|
||||
case kRightText: stringValue = strRight; break;
|
||||
case kCenterText: stringValue = strCenter; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrGradient)
|
||||
{
|
||||
CGradient* gradient = button->getGradient ();
|
||||
UTF8StringPtr gradientName = gradient ? desc->lookupGradientName (gradient) : nullptr;
|
||||
stringValue = gradientName ? gradientName : "";
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrGradientHighlighted)
|
||||
{
|
||||
CGradient* gradient = button->getGradientHighlighted ();
|
||||
UTF8StringPtr gradientName = gradient ? desc->lookupGradientName (gradient) : nullptr;
|
||||
stringValue = gradientName ? gradientName : "";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct TextButtonCreator : ViewCreatorAdapter
|
||||
{
|
||||
TextButtonCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
|
||||
private:
|
||||
using PositionStringArray = std::array<string, 4>;
|
||||
static PositionStringArray& getPositionStrings ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "texteditcreator.h"
|
||||
|
||||
#include "../../lib/controls/ctextedit.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
TextEditCreator::TextEditCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr TextEditCreator::getViewName () const
|
||||
{
|
||||
return kCTextEdit;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr TextEditCreator::getBaseViewName () const
|
||||
{
|
||||
return kCTextLabel;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr TextEditCreator::getDisplayName () const
|
||||
{
|
||||
return "Text Edit";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* TextEditCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CTextEdit (CRect (0, 0, 100, 20), nullptr, -1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextEditCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* label = dynamic_cast<CTextEdit*> (view);
|
||||
if (!label)
|
||||
return false;
|
||||
|
||||
bool b;
|
||||
if (attributes.getBooleanAttribute (kAttrSecureStyle, b))
|
||||
label->setSecureStyle (b);
|
||||
if (attributes.getBooleanAttribute (kAttrImmediateTextChange, b))
|
||||
label->setImmediateTextChange (b);
|
||||
|
||||
int32_t style = label->getStyle ();
|
||||
applyStyleMask (attributes.getAttributeValue (kAttrStyleDoubleClick),
|
||||
CTextEdit::kDoubleClickStyle, style);
|
||||
label->setStyle (style);
|
||||
|
||||
if (auto placeholder = attributes.getAttributeValue (kAttrPlaceholderTitle))
|
||||
label->setPlaceholderString (placeholder->c_str ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextEditCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrSecureStyle);
|
||||
attributeNames.emplace_back (kAttrImmediateTextChange);
|
||||
attributeNames.emplace_back (kAttrStyleDoubleClick);
|
||||
attributeNames.emplace_back (kAttrPlaceholderTitle);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto TextEditCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrSecureStyle)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrImmediateTextChange)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrStyleDoubleClick)
|
||||
return kBooleanType;
|
||||
if (attributeName == kAttrPlaceholderTitle)
|
||||
return kStringType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextEditCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* label = dynamic_cast<CTextEdit*> (view);
|
||||
if (!label)
|
||||
return false;
|
||||
if (attributeName == kAttrSecureStyle)
|
||||
{
|
||||
stringValue = label->getSecureStyle () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrImmediateTextChange)
|
||||
{
|
||||
stringValue = label->getImmediateTextChange () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrStyleDoubleClick)
|
||||
{
|
||||
stringValue = label->getStyle () & CTextEdit::kDoubleClickStyle ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrPlaceholderTitle)
|
||||
{
|
||||
stringValue = label->getPlaceholderString ().getString ();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct TextEditCreator : ViewCreatorAdapter
|
||||
{
|
||||
TextEditCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "textlabelcreator.h"
|
||||
|
||||
#include "../../lib/controls/ctextlabel.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
TextLabelCreator::TextLabelCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr TextLabelCreator::getViewName () const
|
||||
{
|
||||
return kCTextLabel;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr TextLabelCreator::getBaseViewName () const
|
||||
{
|
||||
return kCParamDisplay;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr TextLabelCreator::getDisplayName () const
|
||||
{
|
||||
return "Label";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* TextLabelCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CTextLabel (CRect (0, 0, 100, 20));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextLabelCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* label = dynamic_cast<CTextLabel*> (view);
|
||||
if (!label)
|
||||
return false;
|
||||
|
||||
const auto* attr = attributes.getAttributeValue (kAttrTitle);
|
||||
if (attr)
|
||||
{
|
||||
auto index = attr->find ("\\n");
|
||||
if (index != string::npos)
|
||||
{
|
||||
auto str = *attr;
|
||||
while (index != string::npos)
|
||||
{
|
||||
str.replace (index, 2, "\n");
|
||||
index = str.find ("\\n");
|
||||
}
|
||||
label->setText (UTF8String (std::move (str)));
|
||||
}
|
||||
else
|
||||
label->setText (UTF8String (*attr));
|
||||
}
|
||||
attr = attributes.getAttributeValue (kAttrTruncateMode);
|
||||
if (attr)
|
||||
{
|
||||
if (*attr == strHead)
|
||||
label->setTextTruncateMode (CTextLabel::kTruncateHead);
|
||||
else if (*attr == strTail)
|
||||
label->setTextTruncateMode (CTextLabel::kTruncateTail);
|
||||
else
|
||||
label->setTextTruncateMode (CTextLabel::kTruncateNone);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextLabelCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrTitle);
|
||||
attributeNames.emplace_back (kAttrTruncateMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto TextLabelCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrTitle)
|
||||
return kStringType;
|
||||
if (attributeName == kAttrTruncateMode)
|
||||
return kListType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextLabelCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* label = dynamic_cast<CTextLabel*> (view);
|
||||
if (!label)
|
||||
return false;
|
||||
if (attributeName == kAttrTitle)
|
||||
{
|
||||
stringValue = label->getText ().getString ();
|
||||
auto index = stringValue.find ("\n");
|
||||
while (index != string::npos)
|
||||
{
|
||||
stringValue.replace (index, 1, "\\n");
|
||||
index = stringValue.find ("\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTruncateMode)
|
||||
{
|
||||
switch (label->getTextTruncateMode ())
|
||||
{
|
||||
case CTextLabel::kTruncateHead: stringValue = strHead; break;
|
||||
case CTextLabel::kTruncateTail: stringValue = strTail; break;
|
||||
case CTextLabel::kTruncateNone: stringValue = ""; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool TextLabelCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrTruncateMode)
|
||||
{
|
||||
return getStandardAttributeListValues (kAttrTruncateMode, values);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct TextLabelCreator : ViewCreatorAdapter
|
||||
{
|
||||
TextLabelCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+230
@@ -0,0 +1,230 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "uiviewswitchcontainercreator.h"
|
||||
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include "../uiviewswitchcontainer.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto UIViewSwitchContainerCreator::timingFunctionStrings () -> TimingFunctionStrings&
|
||||
{
|
||||
static TimingFunctionStrings strings = {"linear", "easy-in", "easy-out", "easy-in-out", "easy"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto UIViewSwitchContainerCreator::animationStyleStrings () -> AnimationStyleStrings&
|
||||
{
|
||||
static AnimationStyleStrings strings = {"fade", "move", "push"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UIViewSwitchContainerCreator::UIViewSwitchContainerCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr UIViewSwitchContainerCreator::getViewName () const
|
||||
{
|
||||
return kUIViewSwitchContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr UIViewSwitchContainerCreator::getBaseViewName () const
|
||||
{
|
||||
return kCViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr UIViewSwitchContainerCreator::getDisplayName () const
|
||||
{
|
||||
return "View Switch Container";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* UIViewSwitchContainerCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
UIViewSwitchContainer* vsc = new UIViewSwitchContainer (CRect (0, 0, 100, 100));
|
||||
new UIDescriptionViewSwitchController (vsc, description, description->getController ());
|
||||
return vsc;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool UIViewSwitchContainerCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* viewSwitch = dynamic_cast<UIViewSwitchContainer*> (view);
|
||||
if (!viewSwitch)
|
||||
return false;
|
||||
const auto* attr = attributes.getAttributeValue (kAttrTemplateNames);
|
||||
if (attr)
|
||||
{
|
||||
auto* controller =
|
||||
dynamic_cast<UIDescriptionViewSwitchController*> (viewSwitch->getController ());
|
||||
if (controller)
|
||||
{
|
||||
controller->setTemplateNames (attr->c_str ());
|
||||
}
|
||||
}
|
||||
attr = attributes.getAttributeValue (kAttrTemplateSwitchControl);
|
||||
if (attr)
|
||||
{
|
||||
auto* controller =
|
||||
dynamic_cast<UIDescriptionViewSwitchController*> (viewSwitch->getController ());
|
||||
if (controller)
|
||||
{
|
||||
int32_t tag = description->getTagForName (attr->c_str ());
|
||||
controller->setSwitchControlTag (tag);
|
||||
}
|
||||
}
|
||||
attr = attributes.getAttributeValue (kAttrAnimationStyle);
|
||||
if (attr)
|
||||
{
|
||||
for (auto index = 0u; index <= UIViewSwitchContainer::kPushInOut; ++index)
|
||||
{
|
||||
if (*attr == animationStyleStrings ()[index])
|
||||
{
|
||||
viewSwitch->setAnimationStyle (
|
||||
static_cast<UIViewSwitchContainer::AnimationStyle> (index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attr = attributes.getAttributeValue (kAttrAnimationTimingFunction);
|
||||
if (attr)
|
||||
{
|
||||
for (auto index = 0u; index <= UIViewSwitchContainer::kEasy; ++index)
|
||||
{
|
||||
if (*attr == timingFunctionStrings ()[index])
|
||||
{
|
||||
viewSwitch->setTimingFunction (
|
||||
static_cast<UIViewSwitchContainer::TimingFunction> (index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t animationTime;
|
||||
if (attributes.getIntegerAttribute (kAttrAnimationTime, animationTime))
|
||||
{
|
||||
viewSwitch->setAnimationTime (static_cast<uint32_t> (animationTime));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool UIViewSwitchContainerCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrTemplateNames);
|
||||
attributeNames.emplace_back (kAttrTemplateSwitchControl);
|
||||
attributeNames.emplace_back (kAttrAnimationStyle);
|
||||
attributeNames.emplace_back (kAttrAnimationTimingFunction);
|
||||
attributeNames.emplace_back (kAttrAnimationTime);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto UIViewSwitchContainerCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrTemplateNames)
|
||||
return kStringType;
|
||||
if (attributeName == kAttrTemplateSwitchControl)
|
||||
return kTagType;
|
||||
if (attributeName == kAttrAnimationStyle)
|
||||
return kListType;
|
||||
if (attributeName == kAttrAnimationTimingFunction)
|
||||
return kListType;
|
||||
if (attributeName == kAttrAnimationTime)
|
||||
return kIntegerType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool UIViewSwitchContainerCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto* viewSwitch = dynamic_cast<UIViewSwitchContainer*> (view);
|
||||
if (!viewSwitch)
|
||||
return false;
|
||||
if (attributeName == kAttrTemplateNames)
|
||||
{
|
||||
auto* controller =
|
||||
dynamic_cast<UIDescriptionViewSwitchController*> (viewSwitch->getController ());
|
||||
if (controller)
|
||||
{
|
||||
controller->getTemplateNames (stringValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (attributeName == kAttrTemplateSwitchControl)
|
||||
{
|
||||
auto* controller =
|
||||
dynamic_cast<UIDescriptionViewSwitchController*> (viewSwitch->getController ());
|
||||
if (controller)
|
||||
{
|
||||
UTF8StringPtr controlTag =
|
||||
desc->lookupControlTagName (controller->getSwitchControlTag ());
|
||||
if (controlTag)
|
||||
{
|
||||
stringValue = controlTag;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (attributeName == kAttrAnimationTime)
|
||||
{
|
||||
stringValue =
|
||||
UIAttributes::integerToString (static_cast<int32_t> (viewSwitch->getAnimationTime ()));
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrAnimationStyle)
|
||||
{
|
||||
stringValue = animationStyleStrings ()[viewSwitch->getAnimationStyle ()];
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrAnimationTimingFunction)
|
||||
{
|
||||
stringValue = timingFunctionStrings ()[viewSwitch->getTimingFunction ()];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool UIViewSwitchContainerCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrAnimationStyle)
|
||||
{
|
||||
for (auto& str : animationStyleStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrAnimationTimingFunction)
|
||||
{
|
||||
for (auto& str : timingFunctionStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct UIViewSwitchContainerCreator : ViewCreatorAdapter
|
||||
{
|
||||
|
||||
UIViewSwitchContainerCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
|
||||
private:
|
||||
using TimingFunctionStrings = std::array<string, 5>;
|
||||
using AnimationStyleStrings = std::array<string, 3>;
|
||||
static TimingFunctionStrings& timingFunctionStrings ();
|
||||
static AnimationStyleStrings& animationStyleStrings ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "viewcontainercreator.h"
|
||||
|
||||
#include "../../lib/ccolor.h"
|
||||
#include "../../lib/cviewcontainer.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include <array>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto ViewContainerCreator::backgroundColorDrawStyleStrings () -> BackgroundColorDrawStyleStrings&
|
||||
{
|
||||
static BackgroundColorDrawStyleStrings strings = {"stroked", "filled", "filled and stroked"};
|
||||
return strings;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
ViewContainerCreator::ViewContainerCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ViewContainerCreator::getViewName () const
|
||||
{
|
||||
return kCViewContainer;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ViewContainerCreator::getBaseViewName () const
|
||||
{
|
||||
return kCView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr ViewContainerCreator::getDisplayName () const
|
||||
{
|
||||
return "View Container";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* ViewContainerCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CViewContainer (CRect (0, 0, 100, 100));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewContainerCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
CViewContainer* viewContainer = view->asViewContainer ();
|
||||
if (viewContainer == nullptr)
|
||||
return false;
|
||||
CColor backColor;
|
||||
if (stringToColor (attributes.getAttributeValue (kAttrBackgroundColor), backColor, description))
|
||||
viewContainer->setBackgroundColor (backColor);
|
||||
const auto* attr = attributes.getAttributeValue (kAttrBackgroundColorDrawStyle);
|
||||
if (attr)
|
||||
{
|
||||
for (auto index = 0u; index <= kDrawFilledAndStroked; ++index)
|
||||
{
|
||||
if (*attr == backgroundColorDrawStyleStrings ()[index])
|
||||
{
|
||||
viewContainer->setBackgroundColorDrawStyle (static_cast<CDrawStyle> (index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewContainerCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrBackgroundColor);
|
||||
attributeNames.emplace_back (kAttrBackgroundColorDrawStyle);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto ViewContainerCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrBackgroundColor)
|
||||
return kColorType;
|
||||
if (attributeName == kAttrBackgroundColorDrawStyle)
|
||||
return kListType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewContainerCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
CViewContainer* vc = view->asViewContainer ();
|
||||
if (vc == nullptr)
|
||||
return false;
|
||||
if (attributeName == kAttrBackgroundColor)
|
||||
{
|
||||
colorToString (vc->getBackgroundColor (), stringValue, desc);
|
||||
return true;
|
||||
}
|
||||
if (attributeName == kAttrBackgroundColorDrawStyle)
|
||||
{
|
||||
stringValue = backgroundColorDrawStyleStrings ()[vc->getBackgroundColorDrawStyle ()];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewContainerCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrBackgroundColorDrawStyle)
|
||||
{
|
||||
for (auto& str : backgroundColorDrawStyleStrings ())
|
||||
values.emplace_back (&str);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct ViewContainerCreator : ViewCreatorAdapter
|
||||
{
|
||||
ViewContainerCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
|
||||
private:
|
||||
using BackgroundColorDrawStyleStrings = std::array<string, 3>;
|
||||
static BackgroundColorDrawStyleStrings& backgroundColorDrawStyleStrings ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+353
@@ -0,0 +1,353 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "viewcreator.h"
|
||||
|
||||
#include "../../lib/cview.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
#if VSTGUI_LIVE_EDITING
|
||||
#include "../../lib/cdrawcontext.h"
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
#if VSTGUI_LIVE_EDITING
|
||||
//-----------------------------------------------------------------------------
|
||||
class LiveEditingCView : public CView
|
||||
{
|
||||
public:
|
||||
LiveEditingCView (const CRect& r) : CView (r) {}
|
||||
void draw (CDrawContext* context) override
|
||||
{
|
||||
if (getDrawBackground ())
|
||||
{
|
||||
CView::draw (context);
|
||||
return;
|
||||
}
|
||||
context->setLineWidth (1.);
|
||||
context->setLineStyle (kLineSolid);
|
||||
context->setDrawMode (kAliasing);
|
||||
context->setFrameColor ({200, 200, 200, 100});
|
||||
context->setFillColor ({200, 200, 200, 100});
|
||||
constexpr auto width = 5.;
|
||||
CRect viewSize = getViewSize ();
|
||||
auto r = viewSize;
|
||||
r.setSize ({width, width});
|
||||
uint32_t row = 0u;
|
||||
while (r.top < viewSize.bottom)
|
||||
{
|
||||
uint32_t column = (row % 2) ? 0u : 1u;
|
||||
while (r.left < viewSize.right)
|
||||
{
|
||||
if (column % 2)
|
||||
context->drawRect (r, kDrawFilled);
|
||||
r.offset (width, 0);
|
||||
++column;
|
||||
}
|
||||
r.left = viewSize.left;
|
||||
r.right = r.left + width;
|
||||
r.offset (0, width);
|
||||
++row;
|
||||
}
|
||||
context->drawRect (viewSize, kDrawStroked);
|
||||
setDirty (false);
|
||||
}
|
||||
};
|
||||
using SimpleCView = LiveEditingCView;
|
||||
#else
|
||||
using SimpleCView = CView;
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
ViewCreator::ViewCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ViewCreator::getViewName () const
|
||||
{
|
||||
return kCView;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr ViewCreator::getBaseViewName () const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr ViewCreator::getDisplayName () const
|
||||
{
|
||||
return "View";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* ViewCreator::create (const UIAttributes& attributes, const IUIDescription* description) const
|
||||
{
|
||||
return new SimpleCView (CRect (0, 0, 50, 50));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
CPoint origin;
|
||||
CPoint size;
|
||||
CRect viewSize;
|
||||
if (!attributes.getPointAttribute (kAttrOrigin, origin))
|
||||
origin = view->getViewSize ().getTopLeft ();
|
||||
if (!attributes.getPointAttribute (kAttrSize, size))
|
||||
size = view->getViewSize ().getSize ();
|
||||
viewSize.setTopLeft (origin);
|
||||
viewSize.setSize (size);
|
||||
if (viewSize != view->getViewSize ())
|
||||
{
|
||||
view->setViewSize (viewSize, false);
|
||||
view->setMouseableArea (viewSize);
|
||||
}
|
||||
|
||||
CBitmap* bitmap;
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrBitmap), bitmap, description))
|
||||
view->setBackground (bitmap);
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrDisabledBitmap), bitmap, description))
|
||||
view->setDisabledBackground (bitmap);
|
||||
bool b;
|
||||
if (attributes.getBooleanAttribute (kAttrTransparent, b))
|
||||
view->setTransparency (b);
|
||||
if (attributes.getBooleanAttribute (kAttrMouseEnabled, b))
|
||||
view->setMouseEnabled (b);
|
||||
if (attributes.hasAttribute (kAttrWantsFocus) &&
|
||||
attributes.getBooleanAttribute (kAttrWantsFocus, b))
|
||||
view->setWantsFocus (b);
|
||||
if (const auto* attrValue = attributes.getAttributeValue (kAttrAutosize))
|
||||
{
|
||||
int32_t autosize = kAutosizeNone;
|
||||
if (attrValue->find ("left") != string::npos)
|
||||
autosize |= kAutosizeLeft;
|
||||
if (attrValue->find ("top") != string::npos)
|
||||
autosize |= kAutosizeTop;
|
||||
if (attrValue->find ("right") != string::npos)
|
||||
autosize |= kAutosizeRight;
|
||||
if (attrValue->find ("bottom") != string::npos)
|
||||
autosize |= kAutosizeBottom;
|
||||
if (attrValue->find ("row") != string::npos)
|
||||
autosize |= kAutosizeRow;
|
||||
if (attrValue->find ("column") != string::npos)
|
||||
autosize |= kAutosizeColumn;
|
||||
view->setAutosizeFlags (autosize);
|
||||
}
|
||||
if (const auto* attrValue = attributes.getAttributeValue (kAttrTooltip))
|
||||
{
|
||||
if (!attrValue->empty ())
|
||||
view->setTooltipText (attrValue->data ());
|
||||
else
|
||||
view->setTooltipText (nullptr);
|
||||
}
|
||||
if (const auto* attrValue = attributes.getAttributeValue (kAttrCustomViewName))
|
||||
{
|
||||
view->setAttribute ('uicv', static_cast<uint32_t> (attrValue->size () + 1),
|
||||
attrValue->data ());
|
||||
}
|
||||
if (const auto* attrValue = attributes.getAttributeValue (kAttrSubController))
|
||||
{
|
||||
view->setAttribute ('uisc', static_cast<uint32_t> (attrValue->size () + 1),
|
||||
attrValue->data ());
|
||||
}
|
||||
if (const auto* attrValue = attributes.getAttributeValue (kAttrUIDescLabel))
|
||||
{
|
||||
if (attrValue->empty ())
|
||||
view->removeAttribute (labelAttrID);
|
||||
else
|
||||
view->setAttribute (labelAttrID, static_cast<uint32_t> (attrValue->size () + 1),
|
||||
attrValue->data ());
|
||||
}
|
||||
double opacity;
|
||||
if (attributes.getDoubleAttribute (kAttrOpacity, opacity))
|
||||
view->setAlphaValue (static_cast<float> (opacity));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrOrigin);
|
||||
attributeNames.emplace_back (kAttrSize);
|
||||
attributeNames.emplace_back (kAttrOpacity);
|
||||
attributeNames.emplace_back (kAttrTransparent);
|
||||
attributeNames.emplace_back (kAttrMouseEnabled);
|
||||
attributeNames.emplace_back (kAttrWantsFocus);
|
||||
attributeNames.emplace_back (kAttrBitmap);
|
||||
attributeNames.emplace_back (kAttrDisabledBitmap);
|
||||
attributeNames.emplace_back (kAttrAutosize);
|
||||
attributeNames.emplace_back (kAttrTooltip);
|
||||
attributeNames.emplace_back (kAttrCustomViewName);
|
||||
attributeNames.emplace_back (kAttrSubController);
|
||||
attributeNames.emplace_back (kAttrUIDescLabel);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto ViewCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrOrigin)
|
||||
return kPointType;
|
||||
else if (attributeName == kAttrSize)
|
||||
return kPointType;
|
||||
else if (attributeName == kAttrOpacity)
|
||||
return kFloatType;
|
||||
else if (attributeName == kAttrTransparent)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrMouseEnabled)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrWantsFocus)
|
||||
return kBooleanType;
|
||||
else if (attributeName == kAttrBitmap)
|
||||
return kBitmapType;
|
||||
else if (attributeName == kAttrDisabledBitmap)
|
||||
return kBitmapType;
|
||||
else if (attributeName == kAttrAutosize)
|
||||
return kStringType;
|
||||
else if (attributeName == kAttrTooltip)
|
||||
return kStringType;
|
||||
else if (attributeName == kAttrCustomViewName)
|
||||
return kStringType;
|
||||
else if (attributeName == kAttrSubController)
|
||||
return kStringType;
|
||||
else if (attributeName == kAttrUIDescLabel)
|
||||
return kStringType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewCreator::getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
if (attributeName == kAttrOrigin)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (view->getViewSize ().getTopLeft ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrSize)
|
||||
{
|
||||
stringValue = UIAttributes::pointToString (view->getViewSize ().getSize ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrOpacity)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (view->getAlphaValue ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTransparent)
|
||||
{
|
||||
stringValue = view->getTransparency () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrMouseEnabled)
|
||||
{
|
||||
stringValue = view->getMouseEnabled () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrWantsFocus)
|
||||
{
|
||||
stringValue = view->wantsFocus () ? strTrue : strFalse;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrBitmap)
|
||||
{
|
||||
CBitmap* bitmap = view->getBackground ();
|
||||
if (bitmap)
|
||||
bitmapToString (bitmap, stringValue, desc);
|
||||
else
|
||||
stringValue = "";
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrDisabledBitmap)
|
||||
{
|
||||
CBitmap* bitmap = view->getDisabledBackground ();
|
||||
if (bitmap)
|
||||
bitmapToString (bitmap, stringValue, desc);
|
||||
else
|
||||
stringValue = "";
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrAutosize)
|
||||
{
|
||||
std::stringstream stream;
|
||||
int32_t autosize = view->getAutosizeFlags ();
|
||||
if (autosize == 0)
|
||||
return true;
|
||||
if (autosize & kAutosizeLeft)
|
||||
stream << "left ";
|
||||
if (autosize & kAutosizeRight)
|
||||
stream << "right ";
|
||||
if (autosize & kAutosizeTop)
|
||||
stream << "top ";
|
||||
if (autosize & kAutosizeBottom)
|
||||
stream << "bottom ";
|
||||
if (autosize & kAutosizeRow)
|
||||
stream << "row ";
|
||||
if (autosize & kAutosizeColumn)
|
||||
stream << "column ";
|
||||
stringValue = stream.str ();
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrTooltip)
|
||||
{
|
||||
return getViewAttributeString (view, kCViewTooltipAttribute, stringValue);
|
||||
}
|
||||
else if (attributeName == kAttrCustomViewName)
|
||||
{
|
||||
return getViewAttributeString (view, 'uicv', stringValue);
|
||||
}
|
||||
else if (attributeName == kAttrSubController)
|
||||
{
|
||||
return getViewAttributeString (view, 'uisc', stringValue);
|
||||
}
|
||||
else if (attributeName == kAttrUIDescLabel)
|
||||
{
|
||||
return getViewAttributeString (view, labelAttrID, stringValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewCreator::getAttributeValueRange (const string& attributeName, double& minValue,
|
||||
double& maxValue) const
|
||||
{
|
||||
if (attributeName == kAttrOpacity)
|
||||
{
|
||||
minValue = 0.;
|
||||
maxValue = 1.;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool ViewCreator::getViewAttributeString (CView* view, const CViewAttributeID attrID, string& value)
|
||||
{
|
||||
uint32_t attrSize = 0;
|
||||
if (view->getAttributeSize (attrID, attrSize) && attrSize > 0)
|
||||
{
|
||||
value.resize (attrSize - 1);
|
||||
if (!view->getAttribute (attrID, attrSize, value.data (), attrSize))
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
@@ -0,0 +1,38 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct ViewCreator : ViewCreatorAdapter
|
||||
{
|
||||
ViewCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getAttributeValueRange (const string& attributeName, double& minValue,
|
||||
double& maxValue) const override;
|
||||
|
||||
static constexpr CViewAttributeID labelAttrID = 'uilb';
|
||||
|
||||
private:
|
||||
static bool getViewAttributeString (CView* view, const CViewAttributeID attrID, string& value);
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "vumetercreator.h"
|
||||
|
||||
#include "../../lib/controls/cvumeter.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
#include "../uiviewfactory.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
VuMeterCreator::VuMeterCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr VuMeterCreator::getViewName () const
|
||||
{
|
||||
return kCVuMeter;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr VuMeterCreator::getBaseViewName () const
|
||||
{
|
||||
return kCControl;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr VuMeterCreator::getDisplayName () const
|
||||
{
|
||||
return "VU Meter";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* VuMeterCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CVuMeter (CRect (0, 0, 0, 0), nullptr, nullptr, 100);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool VuMeterCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto* vuMeter = dynamic_cast<CVuMeter*> (view);
|
||||
if (!vuMeter)
|
||||
return false;
|
||||
|
||||
CBitmap* bitmap;
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrOffBitmap), bitmap, description))
|
||||
vuMeter->setOffBitmap (bitmap);
|
||||
|
||||
const auto* attr = attributes.getAttributeValue (kAttrOrientation);
|
||||
if (attr)
|
||||
vuMeter->setStyle (*attr == strVertical ? CVuMeter::Style::kVertical
|
||||
: CVuMeter::Style::kHorizontal);
|
||||
|
||||
int32_t numLed;
|
||||
if (attributes.getIntegerAttribute (kAttrNumLed, numLed))
|
||||
vuMeter->setNbLed (numLed);
|
||||
|
||||
double value;
|
||||
if (attributes.getDoubleAttribute (kAttrDecreaseStepValue, value))
|
||||
vuMeter->setDecreaseStepValue (static_cast<float> (value));
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool VuMeterCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrOffBitmap);
|
||||
attributeNames.emplace_back (kAttrNumLed);
|
||||
attributeNames.emplace_back (kAttrOrientation);
|
||||
attributeNames.emplace_back (kAttrDecreaseStepValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto VuMeterCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrOffBitmap)
|
||||
return kBitmapType;
|
||||
if (attributeName == kAttrNumLed)
|
||||
return kIntegerType;
|
||||
if (attributeName == kAttrOrientation)
|
||||
return kListType;
|
||||
if (attributeName == kAttrDecreaseStepValue)
|
||||
return kFloatType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool VuMeterCreator::getAttributeValue (CView* view, const string& attributeName,
|
||||
string& stringValue, const IUIDescription* desc) const
|
||||
{
|
||||
auto* vuMeter = dynamic_cast<CVuMeter*> (view);
|
||||
if (!vuMeter)
|
||||
return false;
|
||||
if (attributeName == kAttrOffBitmap)
|
||||
{
|
||||
CBitmap* bitmap = vuMeter->getOffBitmap ();
|
||||
if (bitmap)
|
||||
{
|
||||
bitmapToString (bitmap, stringValue, desc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrOrientation)
|
||||
{
|
||||
if (vuMeter->getStyle () == CVuMeter::Style::kVertical)
|
||||
stringValue = strVertical;
|
||||
else
|
||||
stringValue = strHorizontal;
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrNumLed)
|
||||
{
|
||||
stringValue = UIAttributes::integerToString (vuMeter->getNbLed ());
|
||||
return true;
|
||||
}
|
||||
else if (attributeName == kAttrDecreaseStepValue)
|
||||
{
|
||||
stringValue = UIAttributes::doubleToString (vuMeter->getDecreaseStepValue ());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool VuMeterCreator::getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const
|
||||
{
|
||||
if (attributeName == kAttrOrientation)
|
||||
{
|
||||
return getStandardAttributeListValues (kAttrOrientation, values);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct VuMeterCreator : ViewCreatorAdapter
|
||||
{
|
||||
VuMeterCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
bool getPossibleListValues (const string& attributeName,
|
||||
ConstStringPtrList& values) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#include "xypadcreator.h"
|
||||
|
||||
#include "../../lib/controls/cxypad.h"
|
||||
#include "../detail/uiviewcreatorattributes.h"
|
||||
#include "../uiviewfactory.h"
|
||||
#include "../uiattributes.h"
|
||||
#include "../uiviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
XYPadCreator::XYPadCreator ()
|
||||
{
|
||||
UIViewFactory::registerViewCreator (*this);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr XYPadCreator::getViewName () const
|
||||
{
|
||||
return kCXYPad;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
IdStringPtr XYPadCreator::getBaseViewName () const
|
||||
{
|
||||
return kCParamDisplay;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
UTF8StringPtr XYPadCreator::getDisplayName () const
|
||||
{
|
||||
return "XY Pad";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
CView* XYPadCreator::create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
return new CXYPad (CRect (0, 0, 60, 60));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool XYPadCreator::apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const
|
||||
{
|
||||
auto pad = dynamic_cast<CXYPad*> (view);
|
||||
if (!pad)
|
||||
return false;
|
||||
|
||||
CBitmap* bitmap;
|
||||
if (stringToBitmap (attributes.getAttributeValue (kAttrHandleBitmap), bitmap, description))
|
||||
pad->setHandleBitmap (bitmap);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool XYPadCreator::getAttributeNames (StringList& attributeNames) const
|
||||
{
|
||||
attributeNames.emplace_back (kAttrHandleBitmap);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
auto XYPadCreator::getAttributeType (const string& attributeName) const -> AttrType
|
||||
{
|
||||
if (attributeName == kAttrHandleBitmap)
|
||||
return kBitmapType;
|
||||
return kUnknownType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
bool XYPadCreator::getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const
|
||||
{
|
||||
auto pad = dynamic_cast<CXYPad*> (view);
|
||||
if (!pad)
|
||||
return false;
|
||||
if (attributeName == kAttrHandleBitmap)
|
||||
{
|
||||
if (auto bitmap = pad->getHandleBitmap ())
|
||||
{
|
||||
return bitmapToString (bitmap, stringValue, desc);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// This file is part of VSTGUI. It is subject to the license terms
|
||||
// in the LICENSE file found in the top-level directory of this
|
||||
// distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../iviewcreator.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
namespace VSTGUI {
|
||||
namespace UIViewCreator {
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
struct XYPadCreator : ViewCreatorAdapter
|
||||
{
|
||||
XYPadCreator ();
|
||||
IdStringPtr getViewName () const override;
|
||||
IdStringPtr getBaseViewName () const override;
|
||||
UTF8StringPtr getDisplayName () const override;
|
||||
CView* create (const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool apply (CView* view, const UIAttributes& attributes,
|
||||
const IUIDescription* description) const override;
|
||||
bool getAttributeNames (StringList& attributeNames) const override;
|
||||
AttrType getAttributeType (const string& attributeName) const override;
|
||||
bool getAttributeValue (CView* view, const string& attributeName, string& stringValue,
|
||||
const IUIDescription* desc) const override;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
} // UIViewCreator
|
||||
} // VSTGUI
|
||||
Reference in New Issue
Block a user