Skip to content

Commit

Permalink
Reworked UI
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Jun 8, 2024
1 parent db15d36 commit f213394
Show file tree
Hide file tree
Showing 9 changed files with 7,213 additions and 6 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ LV2_DIR ?= $(LIBDIR)/lv2
VST2_DIR ?= $(LIBDIR)/vst
VST3_DIR ?= $(LIBDIR)/vst3
CLAP_DIR ?= $(LIBDIR)/clap
AU_DIR ?= $(LIBDIR)/AU
endif
ifeq ($(MACOS),true)
LV2_DIR ?= /Library/Audio/Plug-Ins/LV2
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ StompTuner come in the following plug-in formats:
* [VST2]
* [VST3]
* [CLAP]
* [AU]

## Compiling

Expand Down Expand Up @@ -52,6 +53,7 @@ dedicated makefile variable.
* VST2: `VST3_DIR` (`<prefix>/lib/vst2`)
* VST3: `VST3_DIR` (`<prefix>/lib/vst3`)
* CLAP: `CLAP_DIR` (`<prefix>/lib/clap`)
* AU: `AU_DIR` (`/Library/Audio/Plug-Ins/Components`)

Example:

Expand All @@ -72,6 +74,7 @@ a dedicated makefile variable.
* VST2: `USER_VST2_DIR` (`$HOME/.vst2`)
* VST3: `USER_VST3_DIR` (`$HOME/.vst3`)
* CLAP: `USER_CLAP_DIR` (`$HOME/.clap`)
* AU: `AU_DIR` (`$HOME/Library/Audio/Plug-Ins/Components`)

*Note: The given default values for all of the above listed environment
variables differ depending on the target OS.*
Expand Down Expand Up @@ -107,3 +110,4 @@ This project is built using the DISTRHO Plugin Framework ([DPF])
[VST2]: https://en.wikipedia.org/wiki/Virtual_Studio_Technology
[VST3]: https://en.wikipedia.org/wiki/Virtual_Studio_Technology
[CLAP]:https://en.wikipedia.org/wiki/CLever_Audio_Plug-in
[AU]:https://en.wikipedia.org/wiki/Audio_Unit
Binary file modified StompTuner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions plugins/CairoWidgets/CairoColourTheme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ class CairoColourTheme
double a;
};

typedef struct {
const unsigned char * data;
long int position;
} binary_stream;

cairo_surface_t *cairo_image_surface_create_from_stream ( const unsigned char* name)
{
binary_stream png_stream;
png_stream.data = name;
png_stream.position = 0;
return cairo_image_surface_create_from_png_stream(&png_stream_reader, (void *)&png_stream);
}

void setCairoColour(cairo_t* const cr, const CairoColour idColour, float darker = 0.8f)
{
cairo_set_source_rgba(cr, idColour.r * darker, idColour.g * darker,
Expand Down Expand Up @@ -218,6 +231,14 @@ class CairoColourTheme

protected:

static cairo_status_t png_stream_reader (void *_stream, unsigned char *data, unsigned int length)
{
binary_stream * stream = (binary_stream *) _stream;
memcpy(data, &stream->data[stream->position],length);
stream->position += length;
return CAIRO_STATUS_SUCCESS;
}

void init()
{
setIdColour(idColourBackground, 0.13, 0.13, 0.13, 1);
Expand Down
40 changes: 37 additions & 3 deletions plugins/CairoWidgets/CairoPushButton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "CairoColourTheme.hpp"
#include "CairoLed.hpp"
#include "scratch.c"

START_NAMESPACE_DGL

Expand Down Expand Up @@ -55,6 +56,10 @@ class CairoPushButton : public CairoSubWidget, public Runner
init();
}

~CairoPushButton() {
cairo_surface_destroy(texture);
}

void setValue(float v)
{
value = v;
Expand All @@ -68,6 +73,7 @@ class CairoPushButton : public CairoSubWidget, public Runner
value = 0.0f;
state = 0;
fontSize = getFontSize();
texture = theme.cairo_image_surface_create_from_stream (scratch_png);
prelight = false;
setState.store(false, std::memory_order_release);
}
Expand Down Expand Up @@ -114,15 +120,29 @@ class CairoPushButton : public CairoSubWidget, public Runner
cairo_set_line_width(cr,2);
theme.setCairoColour(cr, theme.idColourBackgroundNormal);
cairo_stroke(cr);

cairo_rectangle(cr, 2, 2, w -4, h -4);
cairo_translate (cr, 2,2);
cairo_pattern_t *pat = cairo_pattern_create_for_surface(texture);
cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
cairo_set_source(cr, pat);
cairo_fill (cr);

cairo_set_line_width(cr,1);
cairo_move_to(cr, 1,h);
cairo_line_to(cr, 1, 1);
cairo_line_to(cr, w-2, 1);
theme.setCairoColour(cr, theme.idColourBoxShadow);
cairo_stroke(cr);
}
else
cairo_pattern_destroy (pat);
} else {
cairo_pattern_t *pat = cairo_pattern_create_for_surface(texture);
cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
cairo_set_source(cr, pat);
cairo_paint (cr);
cairo_pattern_destroy (pat);
theme.boxShadow(cr, w, h, 5, 5);
}

int offset = 0;
cairo_text_extents_t extents;
Expand All @@ -134,7 +154,20 @@ class CairoPushButton : public CairoSubWidget, public Runner
CAIRO_FONT_WEIGHT_BOLD);
cairo_text_extents(cr, label , &extents);

theme.setCairoColour(cr, theme.idColourForgroundNormal);
cairo_move_to (cr, (w-extents.width)*0.5 +offset-1, (h+extents.height)*0.72 +offset-1);
cairo_text_path(cr, label);
cairo_set_line_width(cr, 1);
cairo_set_source_rgba(cr, 0.1, 0.1, 0.1, 1);
cairo_stroke (cr);

cairo_move_to (cr, (w-extents.width)*0.5 +offset+1, (h+extents.height)*0.72 +offset+1);
cairo_text_path(cr, label);
cairo_set_line_width(cr, 1);
cairo_set_source_rgba(cr, 0.33, 0.33, 0.33, 1);
cairo_stroke (cr);

//theme.setCairoColour(cr, theme.idColourForgroundNormal);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1);
cairo_move_to (cr, (w-extents.width)*0.5 +offset, (h+extents.height)*0.72 +offset);
cairo_show_text(cr, label);

Expand Down Expand Up @@ -200,6 +233,7 @@ class CairoPushButton : public CairoSubWidget, public Runner

private:
CairoColourTheme &theme;
cairo_surface_t *texture;
bool *blocked;
ScopedPointer<CairoLed>& led;
std::function<void(const uint32_t, float) > setParameterValue;
Expand Down
Loading

0 comments on commit f213394

Please sign in to comment.