Skip to content

Commit

Permalink
Add Skin Colors to the Infowindow (surge-synthesizer#2252)
Browse files Browse the repository at this point in the history
The infowindow gets skin colors
The test skin demonstrates them
The step sequencer uses them as defaults but still has independent overrides

Closes surge-synthesizer#2211
  • Loading branch information
baconpaul authored Jun 30, 2020
1 parent 9469059 commit 23d8ecb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
<image id="alt-slider-h-hover" resource="SVG/altHoverHandle.svg"/>
<image id="alt-slider-h-ts" resource="SVG/altTSHandle.svg"/>
<image id="ab-1530" resource="SVG/AB_15x30.svg"/>

<color id="infowindow.border" value="#ff0000"/>
<color id="infowindow.background" value="#ffcccc"/>
<color id="infowindow.foreground" value="#0000ff"/>
<color id="infowindow.foreground.modulationpositive" value="#00ff00"/>
<color id="infowindow.foreground.modulationnegative" value="#ff0000"/>
<color id="infowindow.foreground.modulationvaluepositive" value="#00ffff"/>
<color id="infowindow.foreground.modulationvaluenegative" value="#ffff00"/>
</globals>
<component-classes>
<class name="boompoop" parent="CSurgeSlider" handle_image="alt-slider-h" handle_hover_image="alt-slider-h-hover" handle_temposync_image="alt-slider-h-ts"/>
Expand Down
18 changes: 11 additions & 7 deletions src/common/gui/CLFOGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,8 @@ void CLFOGui::drawStepSeq(VSTGUI::CDrawContext *dc, VSTGUI::CRect &maindisp, VST
}
}

int dragX, dragY;
int dragW = (prec > 4 ? 60 : 40), dragH = (keyModMult ? 22 : 12);
float dragX, dragY;
float dragW = (prec > 4 ? 60 : 40), dragH = (keyModMult ? 22 : 12);

auto sr = steprect[draggedStep];

Expand All @@ -952,12 +952,12 @@ void CLFOGui::drawStepSeq(VSTGUI::CDrawContext *dc, VSTGUI::CRect &maindisp, VST
if (lfodata->unipolar.val.b)
{
auto sv = std::max(ss->steps[draggedStep], 0.f);
yTop = sr.bottom - (int)(sr.getHeight() * sv);
yTop = sr.bottom - (sr.getHeight() * sv);
}
else
{
yTop = sr.bottom -
(int)((float)0.5f + sr.getHeight() * (0.5f + 0.5f * ss->steps[draggedStep]));
((float)0.5f + sr.getHeight() * (0.5f + 0.5f * ss->steps[draggedStep]));
}

if (yTop > sr.getHeight() / 2)
Expand All @@ -973,17 +973,21 @@ void CLFOGui::drawStepSeq(VSTGUI::CDrawContext *dc, VSTGUI::CRect &maindisp, VST

CRect labelR(dragX, dragY, dragX + dragW, dragY + dragH);

fillr(labelR, skin->getColor("lfo.stepseq.popup.border", kBlackCColor));
auto iwbrc = skin->getColor( "infowindow.border", kBlackCColor );
auto iwbgc = skin->getColor( "infowindow.background", kWhiteCColor );
auto iwfgc = skin->getColor( "infowindow.foreground", kBlackCColor );

fillr(labelR, skin->getColor("lfo.stepseq.popup.border", iwbrc));
labelR.inset(1, 1);
fillr(labelR, skin->getColor("lfo.stepseq.popup.background", kWhiteCColor));
fillr(labelR, skin->getColor("lfo.stepseq.popup.background", iwbgc ));

labelR.left += 1;
labelR.top -= (keyModMult > 0 ? 9 : 0);

char txt[256];
sprintf(txt, "%.*f %%", prec, ss->steps[draggedStep] * 100.f);

dc->setFontColor(skin->getColor("lfo.stepseq.popup.foreground", kBlackCColor));
dc->setFontColor(skin->getColor("lfo.stepseq.popup.foreground", iwfgc ) );
dc->setFont(lfoTypeFont);
dc->drawString(txt, labelR, VSTGUI::kLeftText, true);

Expand Down
47 changes: 24 additions & 23 deletions src/common/gui/CParameterTooltip.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "vstcontrols.h"
#include "Parameter.h"
#include <iostream>
#include "UserDefaults.h"
#include "SkinSupport.h"

class CParameterTooltip : public VSTGUI::CControl
class CParameterTooltip : public VSTGUI::CControl, public Surge::UI::SkinConsumingComponnt
{
public:
CParameterTooltip(const VSTGUI::CRect& size) : VSTGUI::CControl(size, 0, 0, 0)
Expand Down Expand Up @@ -69,34 +69,30 @@ class CParameterTooltip : public VSTGUI::CControl
{
if (visible)
{
// COffscreenContext *dc =
// COffscreenContext::create(getFrame(),size.width(),size.height());
dc->setFont(VSTGUI::kNormalFontSmall);

dc->setFont(VSTGUI::kNormalFontSmall);

VSTGUI::CRect smaller = getViewSize();
int shrink = 0;
/*if(!label[0][0])
{
int width = dc->getStringWidth(label[1]);
shrink = limit_range(150 - width,0,75);
}
//smaller.inset(shrink>>1,0);'
smaller.x += shrink;*/
auto frameCol = skin->getColor( "infowindow.border", VSTGUI::kBlackCColor );
auto bgCol = skin->getColor( "infowindow.background", VSTGUI::kWhiteCColor );

auto txtCol = skin->getColor( "infowindow.foreground", VSTGUI::kBlackCColor );
auto mpCol = skin->getColor( "infowindow.foreground.modulationpositive", txtCol );
auto mnCol = skin->getColor( "infowindow.foreground.modulationnegative", txtCol );
auto mpValCol = skin->getColor( "infowindow.foreground.modulationvaluepositive", mpCol );
auto mnValCol = skin->getColor( "infowindow.foreground.modulationvaluenegative", mnCol );



auto size = getViewSize();
size = size.inset(0.75, 0.75);
dc->setFrameColor(VSTGUI::kBlackCColor);
dc->setFrameColor(frameCol);
dc->drawRect(size);
VSTGUI::CRect sizem1(size);
sizem1.inset(1, 1);
dc->setFillColor(VSTGUI::kWhiteCColor);
dc->setFillColor(bgCol);
dc->drawRect(sizem1, VSTGUI::kDrawFilled);
dc->setFontColor(VSTGUI::kBlackCColor);
dc->setFontColor(txtCol);
VSTGUI::CRect trect(size);
trect.inset(4, 1);
trect.right -= shrink;
VSTGUI::CRect tupper(trect), tlower(trect);
tupper.bottom = tupper.top + 13;
tlower.top = tlower.bottom - 15;
Expand All @@ -118,16 +114,23 @@ class CParameterTooltip : public VSTGUI::CControl
if( ! extendedwsstrings )
{
dc->drawString( iwstrings.val.c_str(), tmid, VSTGUI::kLeftText, true );
dc->setFontColor( mpCol );
dc->drawString( iwstrings.dvalplus.c_str(), tmid, VSTGUI::kRightText, true );
dc->setFontColor( txtCol );
}
else
{
dc->drawString( iwstrings.val.c_str(), tmid, VSTGUI::kCenterText, true );
dc->setFontColor( mpCol );
dc->drawString( iwstrings.dvalplus.c_str(), tmid, VSTGUI::kRightText, true );
dc->setFontColor( mnCol );
dc->drawString( iwstrings.dvalminus.c_str(), tmid, VSTGUI::kLeftText, true );


dc->setFontColor( mpValCol );
dc->drawString( iwstrings.valplus.c_str(), tlower, VSTGUI::kRightText, true );
dc->setFontColor( mnValCol );
dc->drawString( iwstrings.valminus.c_str(), tlower, VSTGUI::kLeftText, true );
dc->setFontColor( txtCol );
}
}
else
Expand All @@ -144,8 +147,6 @@ class CParameterTooltip : public VSTGUI::CControl
dc->drawString(label2left, tlower, VSTGUI::kLeftText, true);
}
}
// dc->copyFrom(dc1,smaller);
// dc->forget();
}
setDirty(false);
}
Expand Down
1 change: 1 addition & 0 deletions src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,7 @@ void SurgeGUIEditor::openOrRecreateEditor()
frame->addView(b_settingsMenu);

infowindow = new CParameterTooltip(CRect(0, 0, 0, 0));
((CParameterTooltip *)infowindow)->setSkin( currentSkin );
frame->addView(infowindow);

CRect wsize(0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y);
Expand Down

0 comments on commit 23d8ecb

Please sign in to comment.