Skip to content

Commit

Permalink
Merge branch 'develop' into uiscripting
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Oct 22, 2023
2 parents c75d635 + 4728884 commit 61a44e6
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 167 deletions.
3 changes: 3 additions & 0 deletions vstgui/contrib/datepicker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ static void validate (id self, SEL cmd, NSDatePickerCell* datePickerCell,
dateComponents.month = date.month;
dateComponents.year = date.year;
impl->view.dateValue = [calendar dateFromComponents:dateComponents];
#if !__has_feature(objc_arc)
[dateComponents release];
#endif
}

//------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions vstgui/lib/controls/cknob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace VSTGUI {
#if TARGET_OS_IPHONE
static const float kCKnobRange = 300.f;
static const float kCKnobRangeDefault = 300.f;
#else
static const float kCKnobRange = 200.f;
static const float kCKnobRangeDefault = 200.f;
#endif

static constexpr CViewAttributeID kCKnobMouseStateAttribute = 'knms';
Expand All @@ -40,6 +40,7 @@ CKnobBase::CKnobBase (const CRect& size, IControlListener* listener, int32_t tag
setStartAngle ((float)(3.f * Constants::quarter_pi));
setRangeAngle ((float)(3.f * Constants::half_pi));
zoomFactor = 1.5f;
knobRange = kCKnobRangeDefault;
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -112,7 +113,7 @@ CMouseEventResult CKnobBase::onMouseDown (CPoint& where, const CButtonState& but

mouseState.modeLinear = false;
mouseState.entryState = value;
mouseState.range = kCKnobRange;
mouseState.range = knobRange;
mouseState.coef = (getMax () - getMin ()) / mouseState.range;
mouseState.oldButton = buttons;

Expand Down Expand Up @@ -193,7 +194,7 @@ CMouseEventResult CKnobBase::onMouseMoved (CPoint& where, const CButtonState& bu
CCoord diff = (mouseState.firstPoint.y - where.y) + (where.x - mouseState.firstPoint.x);
if (buttons != mouseState.oldButton)
{
mouseState.range = kCKnobRange;
mouseState.range = knobRange;
if (buttons & kZoomModifier)
mouseState.range *= zoomFactor;

Expand Down
4 changes: 4 additions & 0 deletions vstgui/lib/controls/cknob.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class CKnobBase : public CControl, protected CMouseWheelEditingSupport

virtual CCoord getInsetValue () const { return inset; }
virtual void setInsetValue (CCoord val) { inset = val; }

virtual void setKnobRange (float val) { if (val > 0.f) knobRange = val; }
virtual float getKnobRange () const { return knobRange; }
//@}

// overrides
Expand All @@ -56,6 +59,7 @@ class CKnobBase : public CControl, protected CMouseWheelEditingSupport

float startAngle, rangeAngle;
float zoomFactor;
float knobRange;
CCoord inset;

private:
Expand Down
14 changes: 8 additions & 6 deletions vstgui/lib/platform/linux/cairogradient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,24 @@ const PatternHandle& Gradient::getLinearGradient (CPoint start, CPoint end) cons
}

//------------------------------------------------------------------------
const PatternHandle& Gradient::getRadialGradient ()
const PatternHandle& Gradient::getRadialGradient (CPoint center, CCoord radius,
CPoint originOffset) const
{
if (!radialGradient)
{
radialGradient = PatternHandle (cairo_pattern_create_radial (0, 0, 1, 0, 0, 1));
radialGradient = PatternHandle (
cairo_pattern_create_radial (center.x, center.y, 0., center.x, center.y, radius));

for (auto& it : getColorStops ())
{
cairo_pattern_add_color_stop_rgba (
radialGradient, it.first, it.second.normRed<double> (),
it.second.normGreen<double> (), it.second.normBlue<double> (),
it.second.normAlpha<double> ());
radialGradient, it.first, it.second.normRed<double> (),
it.second.normGreen<double> (), it.second.normBlue<double> (),
it.second.normAlpha<double> ());
}
}
return radialGradient;
}

//------------------------------------------------------------------------
} // Cairo
} // VSTGUI
3 changes: 2 additions & 1 deletion vstgui/lib/platform/linux/cairogradient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Gradient : public PlatformGradientBase
~Gradient () noexcept override;

const PatternHandle& getLinearGradient (CPoint start, CPoint end) const;
const PatternHandle& getRadialGradient ();
const PatternHandle& getRadialGradient (CPoint center, CCoord radius,
CPoint originOffset) const;

private:
void changed () override;
Expand Down
29 changes: 27 additions & 2 deletions vstgui/lib/platform/linux/cairographicscontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,33 @@ bool CairoGraphicsDeviceContext::fillRadialGradient (IPlatformGraphicsPath& path
auto cairoPath = dynamic_cast<Cairo::GraphicsPath*> (&path);
if (!cairoPath)
return false;
// TODO: Implementation
return false;

auto cairoGradient = dynamic_cast<const Cairo::Gradient*> (&gradient);
if (!cairoGradient)
return false;
impl->doInContext ([&] () {
std::unique_ptr<Cairo::GraphicsPath> alignedPath;
if (impl->state.drawMode.integralMode ())
{
alignedPath = cairoPath->copyPixelAlign ([&] (CPoint p) {
p = pixelAlign (impl->state.tm, p);
return p;
});
}
auto p = alignedPath ? alignedPath->getCairoPath () : cairoPath->getCairoPath ();
cairo_append_path (impl->context, p);

const auto& radialGradient =
cairoGradient->getRadialGradient (center, radius, originOffset);
cairo_set_source (impl->context, radialGradient);
if (evenOdd)
cairo_set_fill_rule (impl->context, CAIRO_FILL_RULE_EVEN_ODD);

cairo_arc (impl->context, 0, 0, 0, 0., M_PI * 2.);
cairo_fill (impl->context);
});

return true;
}

//------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion vstgui/lib/platform/mac/cocoa/nsviewdraggingsession.mm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static Class CreateClass ()
//-----------------------------------------------------------------------------
NSImage* NSViewDraggingSession::nsImageForDragOperation (CBitmap* bitmap)
{
return bitmapToNSImage (bitmap);
return [bitmapToNSImage (bitmap) autorelease];
}

//------------------------------------------------------------------------
Expand Down
45 changes: 8 additions & 37 deletions vstgui/lib/platform/win32/direct2d/d2dgraphicscontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,48 +166,19 @@ struct D2DGraphicsDeviceContext::Impl
auto transform = convert (tmGuard.matrix) * globalTM * state.tm;
transform.scale (scaleFactor, scaleFactor);
transform.translate (transformOffset);
bool useLayer = transform.m12 != 0. || transform.m21 != 0.;
if (useLayer)
{ // we have a rotated matrix, we need to use a layer
COM::Ptr<ID2D1Factory> factory {};
deviceContext->GetFactory (factory.adoptPtr ());
COM::Ptr<ID2D1RectangleGeometry> geometry;
if (SUCCEEDED (
factory->CreateRectangleGeometry (convert (state.clip), geometry.adoptPtr ())))
{
if (applyClip.isEmpty () == false)
deviceContext->PopAxisAlignedClip ();
deviceContext->PushLayer (D2D1::LayerParameters (D2D1::InfiniteRect (),
geometry.get (),
D2D1_ANTIALIAS_MODE_ALIASED),
nullptr);
applyClip = state.clip;
}
else
{
useLayer = false;
}
}
if (!useLayer)
auto newClip = state.clip;
globalTM.transform (newClip);
if (applyClip != newClip)
{
auto newClip = state.clip;
globalTM.transform (newClip);
if (applyClip != newClip)
{
if (applyClip.isEmpty () == false)
deviceContext->PopAxisAlignedClip ();
if (newClip.isEmpty () == false)
deviceContext->PushAxisAlignedClip (convert (newClip),
D2D1_ANTIALIAS_MODE_ALIASED);
applyClip = newClip;
}
if (applyClip.isEmpty () == false)
deviceContext->PopAxisAlignedClip ();
if (newClip.isEmpty () == false)
deviceContext->PushAxisAlignedClip (convert (newClip), D2D1_ANTIALIAS_MODE_ALIASED);
applyClip = newClip;
}
deviceContext->SetTransform (convert (transform));

p (deviceContext.get ());

if (useLayer)
deviceContext->PopLayer ();
}

//-----------------------------------------------------------------------------
Expand Down
25 changes: 24 additions & 1 deletion vstgui/plugin-bindings/vst3editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,30 @@ void VST3Editor::save (bool saveAs)
}
if (savePath.empty ())
return;
if (description->save (savePath.c_str (), VST3EditorInternal::getUIDescriptionSaveOptions (frame)))

// filter out attributes we will always override with the values from the parameters
auto filter = [] (CView* view, const std::string& name) -> bool {
if (auto control = dynamic_cast<CControl*> (view))
{
if (control->getTag () != -1)
{
if (name == UIViewCreator::kAttrMinValue)
return false;
if (name == UIViewCreator::kAttrMaxValue)
return false;
if (name == UIViewCreator::kAttrDefaultValue)
return false;
if (name == UIViewCreator::kAttrMouseEnabled)
return false;
if (name == UIViewCreator::kAttrTitle && dynamic_cast<CTextLabel*> (control))
return false;
}
}
return true;
};

if (description->save (savePath.c_str (),
VST3EditorInternal::getUIDescriptionSaveOptions (frame), filter))
description->setFilePath (savePath.c_str ());
}

Expand Down
Loading

0 comments on commit 61a44e6

Please sign in to comment.