Skip to content

Commit

Permalink
Update dpf
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Oct 8, 2023
1 parent 1576b5d commit 45d3bc5
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 87 deletions.
185 changes: 102 additions & 83 deletions plugins/NeuralRecord/CairoWidgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ class CairoColourTheme
double a;
};

void setCairoColour(cairo_t* const cr, const CairoColour idColour, bool darken = false)
void setCairoColour(cairo_t* const cr, const CairoColour idColour, float darker = 0.8f)
{
double darker = 1.0;
if (darken) darker = 0.8;
cairo_set_source_rgba(cr, idColour.r * darker, idColour.g * darker,
idColour.b * darker, idColour.a);
}
Expand All @@ -45,66 +43,30 @@ class CairoColourTheme
idColour = CairoColour {r, g, b, a};
}

CairoColour idColourBackground;
CairoColour idColourBackgroundNormal;
CairoColour idColourBackgroundPrelight;
CairoColour idColourBackgroundActive;
CairoColour idColourBackgroundProgress;

CairoColour idColourForground;
CairoColour idColourForgroundNormal;
CairoColour idColourForgroundActive;

CairoColour idColourFrame;

CairoColour idColourShadow;
CairoColour idColourLight;

protected:

void init()
{
setIdColour(idColourBackground, 0.13, 0.13, 0.13, 1);
setIdColour(idColourBackgroundNormal, 0.13, 0.13, 0.13, 1.0);
setIdColour(idColourBackgroundPrelight, 0.63, 0.63, 0.63, 0.03);
setIdColour(idColourBackgroundActive, 0.63, 0.13, 0.13, 1.0);
setIdColour(idColourBackgroundProgress, 0.4, 0.4, 0.4, 1.0);

setIdColour(idColourForground, 0.63, 0.63, 0.63, 1.0);
setIdColour(idColourForgroundNormal, 0.63, 0.63, 0.63, 1.0);
setIdColour(idColourForgroundActive, 0.93, 0.63, 0.63, 1.0);

setIdColour(idColourFrame, 0.03, 0.03, 0.03, 1.0);

setIdColour(idColourShadow, 0.05, 0.05, 0.05, 1.0);
setIdColour(idColourLight, 0.33, 0.33, 0.33, 1.0);
}

private:
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CairoColourTheme)
};

// -----------------------------------------------------------------------

class CairoShadows
{
public:
void boxShadowInset(cairo_t* const cr, int width, int height)
{
cairo_pattern_t *pat = cairo_pattern_create_linear (0, 0, width, 0);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.33, 0.33, 0.33, 1.0);
cairo_pattern_add_color_stop_rgba (pat, 0.95, 0.2, 0.2, 0.2, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0.1, 0.1, 0.1, 0.1, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.05, 0.05, 0.05, 1.0);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a);
cairo_pattern_add_color_stop_rgba
(pat, 0.95, idColourBoxLight.r * 0.6, idColourBoxLight.g * 0.6, idColourBoxLight.b * 0.6, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0.1, idColourBoxShadow.r * 2.0, idColourBoxShadow.g * 2.0, idColourBoxShadow.b * 2.0, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
pat = NULL;
pat = cairo_pattern_create_linear (0, 0, 0, height);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.33, 0.33, 0.33, 1.0);
cairo_pattern_add_color_stop_rgba (pat, 0.9, 0.2, 0.2, 0.2, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0.1, 0.1, 0.1, 0.1, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.05, 0.05, 0.05, 1.0);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a);
cairo_pattern_add_color_stop_rgba
(pat, 0.9, idColourBoxLight.r * 0.6, idColourBoxLight.g * 0.6, idColourBoxLight.b * 0.6, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0.1, idColourBoxShadow.r * 2.0, idColourBoxShadow.g * 2.0, idColourBoxShadow.b * 2.0, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
Expand All @@ -113,72 +75,129 @@ class CairoShadows
void boxShadowOutset(cairo_t* const cr, int width, int height)
{
cairo_pattern_t *pat = cairo_pattern_create_linear (0, 0, width, 0);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.33, 0.33, 0.33, 1.0);
cairo_pattern_add_color_stop_rgba (pat, 0.05, 0.2, 0.2, 0.2, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0.95, 0.1, 0.1, 0.1, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.05, 0.05, 0.05, 1.0);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a);
cairo_pattern_add_color_stop_rgba
(pat, 0.05, idColourBoxLight.r * 0.6, idColourBoxLight.g * 0.6, idColourBoxLight.b * 0.6, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0.95, idColourBoxShadow.r * 2.0, idColourBoxShadow.g * 2.0, idColourBoxShadow.b * 2.0, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
pat = NULL;
pat = cairo_pattern_create_linear (0, 0, 0, height);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.33, 0.33, 0.33, 1.0);
cairo_pattern_add_color_stop_rgba (pat, 0.1, 0.2, 0.2, 0.2, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0.9, 0.1, 0.1, 0.1, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.05, 0.05, 0.05, 1.0);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a);
cairo_pattern_add_color_stop_rgba
(pat, 0.1, idColourBoxLight.r * 0.6, idColourBoxLight.g * 0.6, idColourBoxLight.b * 0.6, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0.9, idColourBoxShadow.r * 2.0, idColourBoxShadow.g * 2.0, idColourBoxShadow.b * 2.0, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
}

void box_shadow(cairo_t* const cr, int width, int height, int w, int h)
void boxShadow(cairo_t* const cr, int width, int height, int w, int h)
{
cairo_pattern_t *pat = cairo_pattern_create_linear (0, 0, w, 0);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.33, 0.33, 0.33, 0.8);
cairo_pattern_add_color_stop_rgba (pat, 0.4, 0.33, 0.33, 0.33, 0.3);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.33, 0.33, 0.33, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a * 0.8);
cairo_pattern_add_color_stop_rgba
(pat, 0.4, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a * 0.3);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a * 0.0);
cairo_pattern_set_extend(pat, CAIRO_EXTEND_NONE);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
pat = NULL;

pat = cairo_pattern_create_linear (0, 0, 0, h);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.33, 0.33, 0.33, 0.8);
cairo_pattern_add_color_stop_rgba (pat, 0.4, 0.33, 0.33, 0.33, 0.3);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.33, 0.33, 0.33, 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a * 0.8);
cairo_pattern_add_color_stop_rgba
(pat, 0.4, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a * 0.3);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxLight.r, idColourBoxLight.g, idColourBoxLight.b, idColourBoxLight.a * 0.0);
cairo_pattern_set_extend(pat, CAIRO_EXTEND_NONE);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
pat = NULL;

pat = cairo_pattern_create_linear (width - w, 0, width, 0);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.05, 0.05, 0.05, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0.4, 0.05, 0.05, 0.05, 0.3);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.05, 0.05, 0.05, 0.8);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a * 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0.4, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a * 0.3);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a * 0.8);
cairo_pattern_set_extend(pat, CAIRO_EXTEND_NONE);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
pat = NULL;

pat = cairo_pattern_create_linear (0, height - h, 0, height);
cairo_pattern_add_color_stop_rgba (pat, 0, 0.05, 0.05, 0.05, 0.0);
cairo_pattern_add_color_stop_rgba (pat, 0.4, 0.05, 0.05, 0.05, 0.3);
cairo_pattern_add_color_stop_rgba (pat, 1, 0.05, 0.05, 0.05, 0.8);
cairo_pattern_add_color_stop_rgba
(pat, 0, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a * 0.0);
cairo_pattern_add_color_stop_rgba
(pat, 0.4, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a * 0.3);
cairo_pattern_add_color_stop_rgba
(pat, 1, idColourBoxShadow.r, idColourBoxShadow.g, idColourBoxShadow.b, idColourBoxShadow.a * 0.8);
cairo_pattern_set_extend(pat, CAIRO_EXTEND_NONE);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
pat = NULL;
}

CairoColour idColourBackground;
CairoColour idColourBackgroundNormal;
CairoColour idColourBackgroundPrelight;
CairoColour idColourBackgroundActive;
CairoColour idColourBackgroundProgress;

CairoColour idColourForground;
CairoColour idColourForgroundNormal;
CairoColour idColourForgroundActive;

CairoColour idColourFrame;

CairoColour idColourBoxShadow;
CairoColour idColourBoxLight;

protected:

void init()
{
setIdColour(idColourBackground, 0.13, 0.13, 0.13, 1);
setIdColour(idColourBackgroundNormal, 0.13, 0.13, 0.13, 1.0);
setIdColour(idColourBackgroundPrelight, 0.63, 0.63, 0.63, 0.03);
setIdColour(idColourBackgroundActive, 0.63, 0.13, 0.13, 1.0);
setIdColour(idColourBackgroundProgress, 0.4, 0.4, 0.4, 1.0);

setIdColour(idColourForground, 0.63, 0.63, 0.63, 1.0);
setIdColour(idColourForgroundNormal, 0.63, 0.63, 0.63, 1.0);
setIdColour(idColourForgroundActive, 0.93, 0.63, 0.63, 1.0);

setIdColour(idColourFrame, 0.03, 0.03, 0.03, 1.0);

setIdColour(idColourBoxShadow, 0.05, 0.05, 0.05, 1.0);
setIdColour(idColourBoxLight, 0.33, 0.33, 0.33, 1.0);
}

private:
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CairoColourTheme)
};

// -----------------------------------------------------------------------

class CairoButton : public CairoSubWidget, public CairoShadows
class CairoButton : public CairoSubWidget
{
public:

Expand Down Expand Up @@ -241,9 +260,9 @@ class CairoButton : public CairoSubWidget, public CairoShadows
}

if (!state)
boxShadowOutset(cr, w, h);
theme.boxShadowOutset(cr, w, h);
else
boxShadowInset(cr, w, h);
theme.boxShadowInset(cr, w, h);

int offset = 0;
cairo_text_extents_t extents;
Expand Down Expand Up @@ -309,7 +328,7 @@ class CairoButton : public CairoSubWidget, public CairoShadows

// -----------------------------------------------------------------------

class CairoProgressBar : public CairoSubWidget, public CairoShadows
class CairoProgressBar : public CairoSubWidget
{
public:

Expand Down Expand Up @@ -368,7 +387,7 @@ class CairoProgressBar : public CairoSubWidget, public CairoShadows
cairo_show_text(cr, s);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_new_path (cr);
boxShadowInset(cr, width, height);
theme.boxShadowInset(cr, width, height);
cairo_pop_group_to_source (cr);
cairo_paint (cr);
}
Expand All @@ -381,7 +400,7 @@ class CairoProgressBar : public CairoSubWidget, public CairoShadows

// -----------------------------------------------------------------------

class CairoPeekMeter : public CairoSubWidget, public CairoShadows
class CairoPeekMeter : public CairoSubWidget
{
public:

Expand Down Expand Up @@ -583,7 +602,7 @@ class CairoPeekMeter : public CairoSubWidget, public CairoShadows
cairo_rectangle(cr,(width*oldstate)-3, height * 0.5, 3, height * 0.5);
cairo_fill(cr);
drawMeterScale(cr, height, width, height * 0.5);
boxShadowInset(cr, width, height*2);
theme.boxShadowInset(cr, width, height*2);
cairo_pop_group_to_source (cr);
cairo_paint (cr);
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/NeuralRecord/UINeuralCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ UINeuralCapture::UINeuralCapture()
fToolTip = new CairoToolTip(this, theme, "This is a Message");
sizeGroup->addToSizeGroup(fToolTip, 0, 95, 350, 50);

setGeometryConstraints(kInitialWidth, kInitialHeight, true);
}

UINeuralCapture::~UINeuralCapture() {
Expand Down Expand Up @@ -167,7 +166,7 @@ void UINeuralCapture::onCairoDisplay(const CairoGraphicsContext& context) {
cairo_push_group (cr);
theme.setCairoColour(cr, theme.idColourBackground);
cairo_paint(cr);
box_shadow(cr, width, height, 25, 25);
theme.boxShadow(cr, width, height, 25, 25);
cairo_pop_group_to_source (cr);
cairo_paint (cr);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/NeuralRecord/UINeuralCapture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class UiSizeGroup
The main UI class
*/

class UINeuralCapture : public UI, public CairoShadows
class UINeuralCapture : public UI
{
public:
UINeuralCapture();
Expand Down

0 comments on commit 45d3bc5

Please sign in to comment.