Skip to content

Commit

Permalink
WSliderComposed: Add WSliderComposed::highlight property
Browse files Browse the repository at this point in the history
  • Loading branch information
cr7pt0gr4ph7 committed Oct 17, 2024
1 parent 731ac26 commit 166a627
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions res/skins/LateNight/mixer/channel_4decks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
</WidgetGroup>

<SliderComposed><!-- Volume -->
<ObjectName>ChannelVolume</ObjectName>
<TooltipId>channel_volume</TooltipId>
<Size>42f,107f</Size>
<Handle scalemode="STRETCH_ASPECT">skins:LateNight/<Variable name="SliderScheme"/>/sliders/knob_volume_deck.svg</Handle>
Expand All @@ -122,6 +123,10 @@
<Connection>
<ConfigKey><Variable name="Group"/>,volume</ConfigKey>
</Connection>
<Connection>
<ConfigKey><Variable name="Group"/>,auto_fade_active</ConfigKey>
<BindProperty>highlight</BindProperty>
</Connection>
</SliderComposed>

</Children>
Expand Down
5 changes: 5 additions & 0 deletions res/skins/LateNight/mixer/channel_left.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ vertical layout and a side-by-side layout for two-deck mode -->
<WidgetGroup><Size>1min,4f</Size></WidgetGroup>

<SliderComposed><!-- Volume -->
<ObjectName>ChannelVolume</ObjectName>
<TooltipId>channel_volume</TooltipId>
<Size>42f,107f</Size>
<Handle scalemode="STRETCH_ASPECT">skins:LateNight/<Variable name="SliderScheme"/>/sliders/knob_volume_deck.svg</Handle>
Expand All @@ -89,6 +90,10 @@ vertical layout and a side-by-side layout for two-deck mode -->
<Connection>
<ConfigKey><Variable name="Group"/>,volume</ConfigKey>
</Connection>
<Connection>
<ConfigKey><Variable name="Group"/>,auto_fade_active</ConfigKey>
<BindProperty>highlight</BindProperty>
</Connection>
</SliderComposed>

<WidgetGroup><Size>1min,0me</Size></WidgetGroup>
Expand Down
5 changes: 5 additions & 0 deletions res/skins/LateNight/mixer/channel_right.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ vertical layout and a reversed side-by-side layout for two-deck mode -->
<WidgetGroup><Size>1min,4f</Size></WidgetGroup>

<SliderComposed><!-- Volume -->
<ObjectName>ChannelVolume</ObjectName>
<TooltipId>channel_volume</TooltipId>
<Size>42f,107f</Size>
<Handle scalemode="STRETCH_ASPECT">skins:LateNight/<Variable name="SliderScheme"/>/sliders/knob_volume_deck.svg</Handle>
Expand All @@ -47,6 +48,10 @@ vertical layout and a reversed side-by-side layout for two-deck mode -->
<Connection>
<ConfigKey><Variable name="Group"/>,volume</ConfigKey>
</Connection>
<Connection>
<ConfigKey><Variable name="Group"/>,auto_fade_active</ConfigKey>
<BindProperty>highlight</BindProperty>
</Connection>
</SliderComposed>

<WidgetGroup><Size>1min,0me</Size></WidgetGroup>
Expand Down
1 change: 1 addition & 0 deletions res/skins/LateNight/style_classic.qss
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ WLibrary {

/************** Mixer *********************************************************/

#ChannelVolume[highlight="1"],
#CrossfaderContainer[highlight="1"] {
border: 1px solid #cf9200;
}
Expand Down
1 change: 1 addition & 0 deletions res/skins/LateNight/style_palemoon.qss
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ WBeatSpinBox::down-button,

/************** Mixer ***************************************************/

#ChannelVolume[highlight="1"],
#CrossfaderContainer[highlight="1"] {
border: 1px solid #b2421c;
}
Expand Down
15 changes: 15 additions & 0 deletions src/widget/wslidercomposed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

WSliderComposed::WSliderComposed(QWidget* parent)
: WWidget(parent),
m_highlight(0),
m_dHandleLength(0.0),
m_dSliderLength(0.0),
m_bHorizontal(false),
Expand Down Expand Up @@ -389,3 +390,17 @@ double WSliderComposed::calculateHandleLength() {
void WSliderComposed::inputActivity() {
update();
}

int WSliderComposed::getHighlight() const {
return m_highlight;
}

void WSliderComposed::setHighlight(int highlight) {
if (m_highlight == highlight) {
return;
}
m_highlight = highlight;
style()->polish(this);
update();
emit highlightChanged(m_highlight);
}
14 changes: 14 additions & 0 deletions src/widget/wslidercomposed.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class WSliderComposed : public WWidget {
explicit WSliderComposed(QWidget* parent = nullptr);
~WSliderComposed() override;

// The highlight property is used to restyle the widget with CSS.
// The declaration #MySlider[highlight="1"] { } will define the style
// for the highlighted state. Note: The background property does not
// support color schemes for images, a workaround is to set the background
// image via <BackPath> and <BackPathHighlighted> from the skin.
Q_PROPERTY(int highlight READ getHighlight WRITE setHighlight NOTIFY highlightChanged)

int getHighlight() const;
void setHighlight(int highlight);

void setup(const QDomNode& node, const SkinContext& context);
void setSliderPixmap(
const PixmapSource& sourceSlider,
Expand All @@ -33,6 +43,9 @@ class WSliderComposed : public WWidget {
bool tryParseHorizontal(const QDomNode& node) const;
void inputActivity();

signals:
void highlightChanged(int highlight);

public slots:
void onConnectedControlChanged(double dParameter, double dValue) override;
void fillDebugTooltip(QStringList* debug) override;
Expand All @@ -51,6 +64,7 @@ class WSliderComposed : public WWidget {
double calculateHandleLength();
void unsetPixmaps();

int m_highlight;
// Length of handle in pixels
double m_dHandleLength;
// Length of the slider in pixels.
Expand Down

0 comments on commit 166a627

Please sign in to comment.