Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/panel/widgets/mixer/mixer-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
#include <gtkmm.h>

#include "mixer-control.hpp"
#include "icon-select.hpp"

#define ICON(volume) icon_from_range(volume_icons, volume)

MixerControl::MixerControl(WpPipewireObject *obj, WayfireMixer *parent_widget)
MixerControl::MixerControl(WpPipewireObject *obj, WayfireMixer *parent_widget, const std::map<double,
std::vector<std::string>> _icon_set)
{
object = obj;
parent = parent_widget;
object = obj;
parent = parent_widget;
icon_set = _icon_set;
}

MixerControl::~MixerControl()
Expand Down Expand Up @@ -145,12 +144,17 @@ void MixerControl::update_icon()
if (button.get_active())
{
add_css_class("muted");
volume_icon.set_from_icon_name(ICON(0)); // mute
volume_icon.set_from_icon_name(icon_from_range(icon_set, 0)); // mute
return;
}

remove_css_class("muted");
volume_icon.set_from_icon_name(ICON(get_scale_target_value()));
volume_icon.set_from_icon_name(icon_from_range(icon_set, get_scale_target_value()));
}

std::string MixerControl::get_icon_name()
{
return volume_icon.get_icon_name();
}

double MixerControl::get_scale_target_value()
Expand Down Expand Up @@ -214,7 +218,7 @@ void MixerControl::handle_config_reload()
// used to make a copy to the face of the widget
std::unique_ptr<MixerControl> MixerControl::copy()
{
return std::make_unique<MixerControl>(object, parent);
return std::make_unique<MixerControl>(object, parent, icon_set);
}

MixerControlDevice::~MixerControlDevice()
Expand Down
10 changes: 7 additions & 3 deletions src/panel/widgets/mixer/mixer-control.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include <gtkmm.h>
#include <mutex>

#include "mixer.hpp"
#include "animated-scale.hpp"
#include "icon-select.hpp"

class WayfireMixer;

Expand All @@ -22,10 +22,12 @@ class MixerControl : public Gtk::Grid
std::vector<sigc::connection> signals;
void update_gestures();
virtual void update_icons_pos();
std::map<double, std::vector<std::string>> icon_set;
WfOption<int> slider_length{"panel/mixer_slider_length"};

public:
MixerControl(WpPipewireObject *obj, WayfireMixer *parent_widget);
MixerControl(WpPipewireObject *obj, WayfireMixer *parent_widget, const std::map<double,
std::vector<std::string>> icon_set = volume_icons);
~MixerControl();
virtual void init();

Expand All @@ -36,6 +38,7 @@ class MixerControl : public Gtk::Grid
void set_scale_target_value(double volume);
double get_scale_target_value();
void update_icon();
std::string get_icon_name();
// used to mark the control as the source of changes and stop useless/counterproductive updates
bool ignore = false; // set when volume changes because of it to ignore refresh of ui

Expand All @@ -57,7 +60,8 @@ class MixerControlDevice : public MixerControl
void update_icons_pos();

public:
MixerControlDevice(WpPipewireObject *obj, WayfireMixer *parent_widget) : MixerControl(obj, parent_widget)
MixerControlDevice(WpPipewireObject *obj, WayfireMixer *parent_widget, const std::map<double,
std::vector<std::string>> icon_set = volume_icons) : MixerControl(obj, parent_widget, icon_set)
{}
~MixerControlDevice();
void init();
Expand Down
13 changes: 2 additions & 11 deletions src/panel/widgets/mixer/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include "mixer-control.hpp"
#include "icon-select.hpp"

#define ICON(volume) icon_from_range(volume_icons, volume)


void WayfireMixer::reload_config()
{
// adjust margins and spacing
Expand Down Expand Up @@ -281,17 +278,11 @@ void WayfireMixer::update_icon()
// depends on quick_target widget
if (!quick_target)
{
main_image.set_from_icon_name(ICON(-1)); // OOR
return;
}

if (quick_target->button.get_active())
{
main_image.set_from_icon_name(ICON(0)); // mute
main_image.set_from_icon_name(icon_from_range(volume_icons, -1)); // OOR
return;
}

main_image.set_from_icon_name(ICON(quick_target->get_scale_target_value()));
main_image.set_from_icon_name(quick_target->get_icon_name());
}

void WayfireMixer::set_quick_target_from(MixerControl *from)
Expand Down
2 changes: 1 addition & 1 deletion src/panel/widgets/mixer/wp-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void WpCommon::add_object_to_widget(WpPipewireObject *object, WayfireMixer *widg
} else if (type == "Audio/Source")
{
which_box = &(widget->sources_box);
control = new MixerControlDevice(object, widget);
control = new MixerControlDevice(object, widget, mic_volume_icons);
recheck_default = true;
} else if (type == "Stream/Output/Audio")
{
Expand Down
11 changes: 11 additions & 0 deletions src/util/icon-select.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <map>
#include <vector>
#include <string>
Expand All @@ -20,6 +22,15 @@ const std::map<double, std::vector<std::string>> volume_icons = {
{std::numeric_limits<double>::max(), {"audio-volume-high-danger", "dialog-warning"}}
};

const std::map<double, std::vector<std::string>> mic_volume_icons = {
{std::numeric_limits<double>::min(), {"emblem-unreadable"}},
{0.0, {"microphone-sensitivity-muted", "audio-volume-muted"}},
{0.33, {"microphone-sensitivity-low", "audio-volume-low"}},
{0.66, {"microphone-sensitivity-medium", "audio-volume-medium"}},
{1.0, {"microphone-sensitivity-high", "audio-volume-high"}},
{std::numeric_limits<double>::max(), {"audio-volume-high-danger", "dialog-warning"}}
};

const std::map<double, std::vector<std::string>> brightness_display_icons = {
{std::numeric_limits<double>::min(), {"display-brightness-invalid", "emblem-unreadable"}},
{0, {"display-brightness-low-symbolic", "display-brightness-low"}},
Expand Down