Browse Source

Correctly center Carla, HostAudio and HostCV panel content

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 3 years ago
parent
commit
f697f692cd
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 11 additions and 13 deletions
  1. +2
    -3
      plugins/Cardinal/src/Carla.cpp
  2. +7
    -7
      plugins/Cardinal/src/HostAudio.cpp
  3. +2
    -3
      plugins/Cardinal/src/HostCV.cpp

+ 2
- 3
plugins/Cardinal/src/Carla.cpp View File

@@ -447,7 +447,7 @@ struct CarlaModuleWidget : ModuleWidget, IdleCallback {
static constexpr const float startX_Out = 96.0f;
static constexpr const float startY = 74.0f;
static constexpr const float padding = 29.0f;
static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f + padding * 0.25f;
static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f + padding * 0.35f;

CarlaModule* const module;
bool idleCallbackActive = false;
@@ -584,10 +584,9 @@ struct CarlaModuleWidget : ModuleWidget, IdleCallback {
nvgFontFaceId(args.vg, 0);
nvgFontSize(args.vg, 11);
nvgTextAlign(args.vg, NVG_ALIGN_CENTER);
// nvgTextBounds(vg, 0, 0, text, nullptr, nullptr);

nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, startX_Out - 4.0f, startY - 2.0f, padding, padding * CarlaModule::NUM_INPUTS, 4);
nvgRoundedRect(args.vg, startX_Out - 2.5f, startY - 2.0f, padding, padding * CarlaModule::NUM_INPUTS, 4);
nvgFillColor(args.vg, nvgRGB(0xd0, 0xd0, 0xd0));
nvgFill(args.vg);



+ 7
- 7
plugins/Cardinal/src/HostAudio.cpp View File

@@ -132,7 +132,7 @@ struct HostAudioWidget : ModuleWidget {
static constexpr const float startX_Out = 96.0f;
static constexpr const float startY = 74.0f;
static constexpr const float padding = 29.0f;
static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f + padding * 0.25f;
static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f + padding * 0.35f;

HostAudio<numIO>* const module;

@@ -159,12 +159,12 @@ struct HostAudioWidget : ModuleWidget {
}
}

void drawTextLine(NVGcontext* const vg, const float offsetX, const uint posY, const char* const text)
void drawTextLine(NVGcontext* const vg, const uint posY, const char* const text)
{
const float y = startY + posY * padding;
nvgBeginPath(vg);
nvgFillColor(vg, color::WHITE);
nvgText(vg, middleX + offsetX, y + 16, text, nullptr);
nvgText(vg, middleX, y + 16, text, nullptr);
}

void draw(const DrawArgs& args) override
@@ -180,21 +180,21 @@ struct HostAudioWidget : ModuleWidget {
nvgTextAlign(args.vg, NVG_ALIGN_CENTER);

nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, startX_Out - 4.0f, startY - 2.0f, padding, padding * numIO, 4);
nvgRoundedRect(args.vg, startX_Out - 2.5f, startY - 2.0f, padding, padding * numIO, 4);
nvgFillColor(args.vg, nvgRGB(0xd0, 0xd0, 0xd0));
nvgFill(args.vg);

if (numIO == 2)
{
drawTextLine(args.vg, 3.0f, 0, "Left/Mono");
drawTextLine(args.vg, 0.0f, 1, "Right");
drawTextLine(args.vg, 0, "Left/Mono");
drawTextLine(args.vg, 1, "Right");
}
else
{
for (int i=0; i<numIO; ++i)
{
char text[] = {'A','u','d','i','o',' ',static_cast<char>('0'+i+1),'\0'};
drawTextLine(args.vg, 0.0f, i, text);
drawTextLine(args.vg, i, text);
}
}



+ 2
- 3
plugins/Cardinal/src/HostCV.cpp View File

@@ -103,7 +103,7 @@ struct HostCVWidget : ModuleWidget {
static constexpr const float startX_Out = 96.0f;
static constexpr const float startY = 74.0f;
static constexpr const float padding = 29.0f;
static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f + padding * 0.25f;
static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f + padding * 0.35f;

HostCVWidget(HostCV* const module)
{
@@ -141,10 +141,9 @@ struct HostCVWidget : ModuleWidget {
nvgFontFaceId(args.vg, 0);
nvgFontSize(args.vg, 11);
nvgTextAlign(args.vg, NVG_ALIGN_CENTER);
// nvgTextBounds(vg, 0, 0, text, nullptr, nullptr);

nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, startX_Out - 4.0f, startY - 2.0f, padding, padding * HostCV::NUM_INPUTS, 4);
nvgRoundedRect(args.vg, startX_Out - 2.5f, startY - 2.0f, padding, padding * HostCV::NUM_INPUTS, 4);
nvgFillColor(args.vg, nvgRGB(0xd0, 0xd0, 0xd0));
nvgFill(args.vg);



Loading…
Cancel
Save