Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 157-cue-support
  • 352-cover-fetchers-remove-metrolyrics-and-add-sonichits-instead
  • 367-add-channel-mode
  • 380-not-entire-filename-is-shown-in-controls
  • 414-disable-spectrum-when-invisible
  • 454-parse-relative-tracks-in-playlist
  • create-simple-pipeline
  • fix-gitlab-ci
  • in-progress
  • master
  • qt6
  • wip-create-ssl-settings
  • working
  • 0.8.2-git0-20160214
  • 0.8.2-git0-20160424
  • 0.8.2-git1-20160218
  • 0.8.2-git1-20160219
  • 0.8.2-git2-20160226
  • 0.8.2-git2-20160421
  • 0.8.3-git0-20160424
  • 0.8.3-git1-20160425
  • 0.8.3-git2-20160501
  • 0.8.3-git3-20160509
  • 0.8.3-git3-20160510
  • 0.8.3-git4-20160510
  • 0.9.0-git0-20160514
  • 0.9.0-git1-20160516
  • 0.9.0-git2-20160517
  • 0.9.0-git3-20160606
  • 0.9.0-git3-20160607
  • 0.9.1-git0-20160912
  • 0.9.1-git0-20160913
  • 0.9.1-git1-20160913
  • 0.9.1-git2-20160913
  • 0.9.2-git0-20160913
  • 0.9.2-git0-20160919
  • 0.9.2-git0-20161009
  • 0.9.2-git1-20160919
  • 0.9.2-git10-20161025
  • 0.9.2-git11-20161030
  • 0.9.2-git2-20160920
  • 0.9.2-git3-20160920
  • 0.9.2-git4-20160920
  • 0.9.2-git5-20161009
  • 0.9.2-git6-20161010
  • 0.9.2-git7-20161013
  • 0.9.2-git8-20161013
  • 0.9.2-git8-20161018
  • 0.9.2-git9-20170417
  • 0.9.3-git0-20170109
  • 0.9.3-git0-20170501
  • 0.9.3-git1-20170502
  • 0.9.3-git2-20170509
  • 0.9.3-git3-20171018
  • 0.9.3-git4-20171105
  • 1.0.0-git0-20171228
  • 1.0.0-git0-20171230
  • 1.0.0-git0-20180705
  • 1.0.0-git1-20171231
  • 1.0.0-git1-20180105
  • 1.0.0-git2-20180105
  • 1.0.0-git3-20180106
  • 1.0.0-git4-20180112
  • 1.0.0-git5-20180115
  • 1.1.0-git0-20180705
  • 1.1.0-git1-20180705
  • 1.1.0-git2-20180720
  • 1.1.0-git3-20180806
  • 1.1.0-git3-20180819
  • 1.1.0-git4-20180819
  • 1.1.0-git5-20180822
  • 1.1.0-git6-20180826
  • 1.1.1-git0-20180826
  • 1.1.1-git1-20180828
  • 1.1.1-git2-20180830
  • 1.1.1-git3-20180905
  • 1.1.2-git0-20180916
  • 1.10.0-beta1
  • 1.10.0-beta2
  • 1.10.0-stable1
  • 1.11.0-beta1
  • 1.11.0-stable1
  • 1.11.0-stable2
  • 1.2.0-git0-20181216
  • 1.2.0-git1-20181216
  • 1.2.0-git2-20190427
  • 1.3.0-beta1
  • 1.3.0-stable1
  • 1.3.0-stable2
  • 1.3.1-beta1
  • 1.4.0-stable1
  • 1.4.1-stable1
  • 1.5.0-beta1
  • 1.5.0-beta2
  • 1.5.1-stable1
  • 1.5.1-stable2
  • 1.5.1-stable3
  • 1.5.1-stable4
  • 1.5.1-stable5
  • 1.5.2-beta1
  • 1.5.2-beta2
  • 1.5.2-beta3
  • 1.6.0-beta3
  • 1.6.0-beta4
  • 1.6.0-beta5
  • 1.6.0-beta6
  • 1.6.0-beta7
  • 1.7.0-stable1
  • 1.7.0-stable2
  • 1.7.0-stable3
  • 1.8.0-beta1
  • 1.9.0-beta1
  • 1.9.0-stable1
113 results

Target

Select target project
  • kokoye2007/sayonara-player
  • luciocarreras/sayonara-player
  • evertiro/sayonara-player
  • maxkoryukov/sayonara-player
  • sgnls/sayonara-player
  • melizas/sayonara-player
  • LordLunix/sayonara-player
  • marequ/sayonara-player
  • tschlaeppi/sayonara-player
  • Logarithmus/sayonara-player
  • hosiet/sayonara-player
  • trancexpress/sayonara-player
  • timchenkomo/sayonara-player
  • Metzger100/sayonara-player-mirrored
  • Animax-Dev/sayonara-player
  • adriaandegroot/sayonara-player
  • amitkr/sayonara-player
17 results
Select Git revision
  • 157-cue-support
  • 352-cover-fetchers-remove-metrolyrics-and-add-sonichits-instead
  • 367-add-channel-mode
  • 380-not-entire-filename-is-shown-in-controls
  • 414-disable-spectrum-when-invisible
  • 454-parse-relative-tracks-in-playlist
  • create-simple-pipeline
  • fix-gitlab-ci
  • in-progress
  • master
  • qt6
  • wip-create-ssl-settings
  • working
  • 0.8.2-git0-20160214
  • 0.8.2-git0-20160424
  • 0.8.2-git1-20160218
  • 0.8.2-git1-20160219
  • 0.8.2-git2-20160226
  • 0.8.2-git2-20160421
  • 0.8.3-git0-20160424
  • 0.8.3-git1-20160425
  • 0.8.3-git2-20160501
  • 0.8.3-git3-20160509
  • 0.8.3-git3-20160510
  • 0.8.3-git4-20160510
  • 0.9.0-git0-20160514
  • 0.9.0-git1-20160516
  • 0.9.0-git2-20160517
  • 0.9.0-git3-20160606
  • 0.9.0-git3-20160607
  • 0.9.1-git0-20160912
  • 0.9.1-git0-20160913
  • 0.9.1-git1-20160913
  • 0.9.1-git2-20160913
  • 0.9.2-git0-20160913
  • 0.9.2-git0-20160919
  • 0.9.2-git0-20161009
  • 0.9.2-git1-20160919
  • 0.9.2-git10-20161025
  • 0.9.2-git11-20161030
  • 0.9.2-git2-20160920
  • 0.9.2-git3-20160920
  • 0.9.2-git4-20160920
  • 0.9.2-git5-20161009
  • 0.9.2-git6-20161010
  • 0.9.2-git7-20161013
  • 0.9.2-git8-20161013
  • 0.9.2-git8-20161018
  • 0.9.2-git9-20170417
  • 0.9.3-git0-20170109
  • 0.9.3-git0-20170501
  • 0.9.3-git1-20170502
  • 0.9.3-git2-20170509
  • 0.9.3-git3-20171018
  • 0.9.3-git4-20171105
  • 1.0.0-git0-20171228
  • 1.0.0-git0-20171230
  • 1.0.0-git0-20180705
  • 1.0.0-git1-20171231
  • 1.0.0-git1-20180105
  • 1.0.0-git2-20180105
  • 1.0.0-git3-20180106
  • 1.0.0-git4-20180112
  • 1.0.0-git5-20180115
  • 1.1.0-git0-20180705
  • 1.1.0-git1-20180705
  • 1.1.0-git2-20180720
  • 1.1.0-git3-20180806
  • 1.1.0-git3-20180819
  • 1.1.0-git4-20180819
  • 1.1.0-git5-20180822
  • 1.1.0-git6-20180826
  • 1.1.1-git0-20180826
  • 1.1.1-git1-20180828
  • 1.1.1-git2-20180830
  • 1.1.1-git3-20180905
  • 1.1.2-git0-20180916
  • 1.10.0-beta1
  • 1.10.0-beta2
  • 1.10.0-stable1
  • 1.11.0-beta1
  • 1.11.0-stable1
  • 1.11.0-stable2
  • 1.2.0-git0-20181216
  • 1.2.0-git1-20181216
  • 1.2.0-git2-20190427
  • 1.3.0-beta1
  • 1.3.0-stable1
  • 1.3.0-stable2
  • 1.3.1-beta1
  • 1.4.0-stable1
  • 1.4.1-stable1
  • 1.5.0-beta1
  • 1.5.0-beta2
  • 1.5.1-stable1
  • 1.5.1-stable2
  • 1.5.1-stable3
  • 1.5.1-stable4
  • 1.5.1-stable5
  • 1.5.2-beta1
  • 1.5.2-beta2
  • 1.5.2-beta3
  • 1.6.0-beta3
  • 1.6.0-beta4
  • 1.6.0-beta5
  • 1.6.0-beta6
  • 1.6.0-beta7
  • 1.7.0-stable1
  • 1.7.0-stable2
  • 1.7.0-stable3
  • 1.8.0-beta1
  • 1.9.0-beta1
  • 1.9.0-stable1
113 results
Show changes
Commits on Source (10)
Showing
with 1122 additions and 669 deletions
No preview for this file type
......@@ -381,12 +381,12 @@ namespace Engine
return m_levelValues;
}
void setVisualizerEnabled(bool levelEnabled, bool spectrumEnabled) override
void setVisualizerEnabled(const bool isLevelActive, const bool isSpectrumActive) override
{
m_pipeline->setVisualizerEnabled(levelEnabled, spectrumEnabled);
m_pipeline->setVisualizerEnabled(isLevelActive, isSpectrumActive);
if(m_otherPipeline)
{
m_otherPipeline->setVisualizerEnabled(levelEnabled, spectrumEnabled);
m_otherPipeline->setVisualizerEnabled(false, false);
}
}
......
......@@ -93,7 +93,7 @@ namespace Engine
virtual void setLevel(float left, float right) = 0;
[[nodiscard]] virtual QPair<float, float> level() const = 0;
virtual void setVisualizerEnabled(bool levelEnabled, bool spectrumEnabled) = 0;
virtual void setVisualizerEnabled(bool isLevelActive, bool isSpectrumActive) = 0;
virtual void setBroadcastEnabled(bool b) = 0;
virtual void setEqualizer(int band, int value) = 0;
......
......@@ -144,6 +144,8 @@ void Handler::playstateChanged(PlayState state)
default:
return;
}
reloadReceivers();
}
void Handler::registerSpectrumReceiver(SpectrumDataReceiver* receiver)
......@@ -202,8 +204,8 @@ void Engine::Handler::setLevelData(float left, float right)
void Handler::levelChanged()
{
QPair<float, float> level = m->engine->level();
setLevelData(level.first, level.second);
const auto [left, right] = m->engine->level();
setLevelData(left, right);
}
void Handler::levelActiveChanged(bool /*b*/)
......@@ -213,15 +215,15 @@ void Handler::levelActiveChanged(bool /*b*/)
void Handler::reloadReceivers()
{
bool s = Util::Algorithm::contains(m->spectrumReceivers, [](SpectrumDataReceiver* spectrumReceiver) {
return (spectrumReceiver->isActive());
const auto isSpectrumActive = Util::Algorithm::contains(m->spectrumReceivers, [](auto* receiver) {
return receiver->isActive();
});
bool l = Util::Algorithm::contains(m->levelReceivers, [](LevelDataReceiver* levelReceiver) {
return (levelReceiver->isActive());
const auto isLevelActive = Util::Algorithm::contains(m->levelReceivers, [](auto* receiver) {
return receiver->isActive();
});
m->engine->setVisualizerEnabled(l, s);
m->engine->setVisualizerEnabled(isLevelActive, isSpectrumActive);
}
void Handler::setEqualizer(int band, int value)
......
......@@ -322,9 +322,9 @@ namespace Engine
Utils::setValue(G_OBJECT(m->playbackVolume), "mute", muted);
}
void Pipeline::setVisualizerEnabled(bool levelEnabled, bool spectrumEnabled)
void Pipeline::setVisualizerEnabled(const bool isLevelActive, const bool isSpectrumActive)
{
m->visualizer->setEnabled(levelEnabled, spectrumEnabled);
m->visualizer->setEnabled(isLevelActive, isSpectrumActive);
}
bool Pipeline::isLevelVisualizerEnabled() const { return m->visualizer->isLevelEnabled(); }
......
......@@ -62,7 +62,7 @@ namespace Engine
void checkPosition();
void checkAboutToFinish();
void setVisualizerEnabled(bool levelEnabled, bool spectrumEnabled);
void setVisualizerEnabled(bool isLevelActive, bool isSpectrumActive);
[[nodiscard]] bool isLevelVisualizerEnabled() const;
[[nodiscard]] bool isSpectrumVisualizerEnabled() const;
......
......@@ -25,7 +25,10 @@
namespace
{
GstPadProbeReturn onDeactivated(GstPad*, GstPadProbeInfo*, gpointer) { return GST_PAD_PROBE_DROP; }
GstPadProbeReturn onDeactivated(GstPad* /*pad*/, GstPadProbeInfo* /*info*/, gpointer /*data*/)
{
return GST_PAD_PROBE_DROP;
}
}
class VisualizerBinImpl :
......@@ -38,21 +41,21 @@ class VisualizerBinImpl :
~VisualizerBinImpl() override = default;
bool setEnabled(const bool levelEnabled, const bool spectrumEnabled) override
bool setEnabled(const bool isLevelActive, const bool isSpectrumActive) override
{
if(!init())
{
return false;
}
m_isLevelEnabled = levelEnabled;
m_isSpectrumEnabled = spectrumEnabled;
m_isLevelActive = isLevelActive;
m_isSpectrumActive = isSpectrumActive;
const auto isRunning = (levelEnabled || spectrumEnabled);
const auto isRunning = (m_isLevelActive || m_isSpectrumActive);
if(isRunning == m_isRunning)
{
Engine::Utils::setValue(G_OBJECT(m_level), "post-messages", levelEnabled);
Engine::Utils::setValue(G_OBJECT(m_spectrum), "post-messages", spectrumEnabled);
Engine::Utils::setValue(G_OBJECT(m_level), "post-messages", m_isLevelActive);
Engine::Utils::setValue(G_OBJECT(m_spectrum), "post-messages", m_isSpectrumActive);
return true;
}
......@@ -62,15 +65,15 @@ class VisualizerBinImpl :
m_probingData.queue = m_queue;
PipelineExtensions::Probing::handleProbe(&m_probingData, onDeactivated);
Engine::Utils::setValue(G_OBJECT(m_level), "post-messages", levelEnabled);
Engine::Utils::setValue(G_OBJECT(m_spectrum), "post-messages", spectrumEnabled);
Engine::Utils::setValue(G_OBJECT(m_level), "post-messages", m_isLevelActive);
Engine::Utils::setValue(G_OBJECT(m_spectrum), "post-messages", m_isSpectrumActive);
return true;
}
[[nodiscard]] bool isLevelEnabled() const override { return m_isLevelEnabled; }
[[nodiscard]] bool isLevelEnabled() const override { return m_isLevelActive; }
[[nodiscard]] bool isSpectrumEnabled() const override { return m_isSpectrumEnabled; }
[[nodiscard]] bool isSpectrumEnabled() const override { return m_isSpectrumActive; }
private:
bool createElements()
......@@ -145,8 +148,8 @@ class VisualizerBinImpl :
PipelineExtensions::Probing::GenericProbingData m_probingData;
bool m_isRunning {false};
bool m_isSpectrumEnabled {false};
bool m_isLevelEnabled {false};
bool m_isSpectrumActive {false};
bool m_isLevelActive {false};
};
namespace PipelineExtensions
......
......@@ -31,7 +31,7 @@ namespace PipelineExtensions
public:
virtual ~VisualizerBin();
virtual bool setEnabled(bool levelEnabled, bool spectrumEnabled) = 0;
virtual bool setEnabled(bool isLevelActive, bool isSpectrumActive) = 0;
[[nodiscard]] virtual bool isLevelEnabled() const = 0;
[[nodiscard]] virtual bool isSpectrumEnabled() const = 0;
......
/* StyleSettings.cpp, (Created on 10.11.2024) */
/* Copyright (C) 2011-2024 Michael Lugmair
*
* This file is part of Sayonara Player
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "StyleSettings.h"
#include "VisualStyleTypes.h"
#include "Database/Connector.h"
#include "Database/VisualStyles.h"
#include "Utils/Algorithm.h"
#include "Utils/Logger/Logger.h"
#include "Utils/Language/Language.h"
#include <QMap>
#include <optional>
namespace
{
RawColorStyle createEmptyStyle()
{
auto emptyStyle = RawColorStyle {};
for(int i = 0; i < 4; i++)
{
emptyStyle.colorList.colors << QColor(0, 0, 0, 0);
}
return emptyStyle;
}
QList<RawColorStyle> prependEmptyStyle(QList<RawColorStyle> styles)
{
styles.push_front(createEmptyStyle());
return styles;
}
}
struct StyleSettings::Private
{
DB::VisualStyles* db {DB::Connector::instance()->visualStyleConnector()};
QList<RawColorStyle> styles {prependEmptyStyle(db->getRawColorStyles())};
std::optional<RawColorStyle> temporaryStyle {std::nullopt};
int currentIndex {-1};
};
StyleSettings::StyleSettings(QObject* parent) :
QObject(parent),
m {Pimpl::make<Private>()} {}
StyleSettings::~StyleSettings() = default;
void StyleSettings::select(const int index) { m->currentIndex = index; }
int StyleSettings::currentIndex() const { return m->currentIndex; }
QString StyleSettings::nameProposal() const
{
auto names = QStringList {};
Util::Algorithm::transform(m->styles, names, [](const auto& style) {
return style.colorList.name;
});
for(int i = 1; i < 100; i++) // NOLINT(*-magic-numbers)
{
const auto newName = QString("%1 %2")
.arg(Lang::get(Lang::New))
.arg(i);
if(!names.contains(newName, Qt::CaseInsensitive))
{
return newName;
}
}
return {};
}
QList<RawColorStyle> StyleSettings::styles() const { return m->styles; }
std::optional<RawColorStyle> StyleSettings::currentStyle() const { return style(m->currentIndex); }
std::optional<RawColorStyle> StyleSettings::style(const int index) const
{
return (index >= 0) && (index < m->styles.count())
? std::optional {m->styles[index]}
: std::nullopt;
}
int StyleSettings::count() const { return m->styles.count(); }
bool StyleSettings::saveCurrent(const RawColorStyle& style)
{
if((m->currentIndex < 0) || (m->currentIndex >= m->styles.count()))
{
return false;
}
const auto name = style.colorList.name;
if(name.isEmpty())
{
return false;
}
spLog(Log::Info, this) << "Save values to " << name;
const auto success = (m->db->rawColorStyleExists(name))
? m->db->updateRawColorStyle(style)
: m->db->insertRawColorStyle(style);
if(success)
{
m->styles = prependEmptyStyle(m->db->getRawColorStyles());
emit sigStylesChanged();
}
return success;
}
bool StyleSettings::deleteCurrent()
{
if((m->currentIndex < 0) || (m->currentIndex >= m->styles.count()))
{
return false;
}
const auto success = m->db->deleteRawColorStyle(m->styles[m->currentIndex].colorList.name);
if(success)
{
m->styles = prependEmptyStyle(m->db->getRawColorStyles());
emit sigStylesChanged();
}
return success;
}
/* StyleSettings.h, (Created on 10.11.2024) */
/* Copyright (C) 2011-2024 Michael Lugmair
*
* This file is part of Sayonara Player
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SAYONARA_PLAYER_STYLESETTINGS_H
#define SAYONARA_PLAYER_STYLESETTINGS_H
#include "Utils/Pimpl.h"
#include <QList>
#include <QObject>
#include <optional>
struct RawColorStyle;
class StyleSettings :
public QObject
{
Q_OBJECT
PIMPL(StyleSettings)
signals:
void sigStylesChanged();
public:
explicit StyleSettings(QObject* parent);
~StyleSettings() override;
[[nodiscard]] QList<RawColorStyle> styles() const;
[[nodiscard]] std::optional<RawColorStyle> currentStyle() const;
[[nodiscard]] int count() const;
void select(int index);
[[nodiscard]] int currentIndex() const;
[[nodiscard]] QString nameProposal() const;
bool saveCurrent(const RawColorStyle& style);
bool deleteCurrent();
private:
[[nodiscard]] std::optional<RawColorStyle> style(int index) const;
};
#endif //SAYONARA_PLAYER_STYLESETTINGS_H
/* VisualColorStyleChooser.cpp */
/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
*
* This file is part of sayonara player
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "VisualColorStyleChooser.h"
#include "Components/Visualization/VisualStyleTypes.h"
#include "Database/Connector.h"
#include "Database/VisualStyles.h"
#include "Utils/Mutex.h"
#include "Utils/Algorithm.h"
namespace
{
std::mutex mtx; // NOLINT(*-avoid-non-const-global-variables)
}
struct VisualColorStyleChooser::Private
{
QList<RawColorStyle> styles;
};
VisualColorStyleChooser::VisualColorStyleChooser() :
m {Pimpl::make<Private>()}
{
reload();
}
VisualColorStyleChooser::~VisualColorStyleChooser() noexcept = default;
RawColorStyle VisualColorStyleChooser::style(int i) const
{
i = std::max(i, 0);
i = std::min(m->styles.size() - 1, i);
return m->styles[i];
}
int VisualColorStyleChooser::count() const { return m->styles.size(); }
void VisualColorStyleChooser::reload()
{
LOCK_GUARD(mtx) // NOLINT(*-const-correctness)
auto* db = DB::Connector::instance()->visualStyleConnector();
m->styles = db->getRawColorStyles();
if(m->styles.isEmpty())
{
const auto rgbStyle = Util::createRgbStyle();
const auto bwStyle = Util::createBwStyle();
db->insertRawColorStyle(rgbStyle);
db->insertRawColorStyle(bwStyle);
m->styles << rgbStyle << bwStyle;
}
}
......@@ -26,31 +26,23 @@
#include <QHash>
#include <QColor>
#include "VisualStyleTypes.h"
#include "Utils/Pimpl.h"
struct RawColorStyle;
class VisualColorStyleChooser :
public QObject
{
Q_OBJECT
signals:
void sig_use_style(int, const ColorStyle&);
PIMPL(VisualColorStyleChooser)
public:
VisualColorStyleChooser(int widget_width, int widget_height);
ColorStyle get_color_scheme_spectrum(int i);
ColorStyle get_color_scheme_level(int i);
int get_num_color_schemes();
void reload(int widget_width, int widget_height);
VisualColorStyleChooser();
~VisualColorStyleChooser() noexcept override;
private:
void insertColorOfRect(int bin, int n_bins, const ColorList& colors, QHash<int, QColor>& map);
void create_colorstyle(ColorStyle& style, const ColorList& colors_active, int n_rects, int n_fading_steps);
void init();
[[nodiscard]] RawColorStyle style(int index) const;
[[nodiscard]] int count() const;
QList<ColorStyle> _styles_spectrum;
QList<ColorStyle> _styles_level;
void reload();
};
#endif // ENGINECOLORSTYLECHOOSER_H
/* VisualStyleTypes.cpp, (Created on 14.12.2024) */
/* Copyright (C) 2011-2024 Michael Lugmair
*
* This file is part of Sayonara Player
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "VisualStyleTypes.h"
#include <QHash>
#include <QList>
#include <QColor>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma ide diagnostic ignored "readability-magic-numbers"
namespace
{
const auto offColor = QColor(0, 0, 0, 50);
QList<float> getBordersByColorList(const ColorList& colorList)
{
static const auto borders4 = QList<float> {} << 0 << 0.33F << 0.66F << 1.0F;
static const auto borders3 = QList<float> {} << 0 << 0.5F << 1.0F;
static const auto borders2 = QList<float> {} << 0 << 1.0F;
if(colorList.colors.size() == 4)
{
return borders4;
}
if(colorList.colors.size() == 3)
{
return borders3;
}
if(colorList.colors.size() == 2)
{
return borders2;
}
return borders4;
}
int intermediateColor(const float percent, const int previousColorValue, const int currentColorValue,
const float previousBorder, const float currentBorder)
{
const auto dx = currentBorder - previousBorder; // difference between two borders e.g. 0.33
const auto dy = currentColorValue - previousColorValue; // difference between the red values e.g. 100
const auto scale = percent - previousBorder; // 0.93 - 0.33: 0.6
return static_cast<int>((scale * dy) / dx + previousColorValue); // NOLINT(*-narrowing-conversions)
}
QColor getColorByIndex(const int index, const int count, const ColorList& colorlist)
{
if(index == 0)
{
return colorlist.colors[0];
}
auto i = 0;
const auto borders = getBordersByColorList(colorlist);
const auto percent = (index * 1.0F) / count;
while(percent > borders[i])
{
i++;
}
const auto previousColor = colorlist.colors[i - 1];
const auto currentColor = colorlist.colors[i];
return {
intermediateColor(percent, previousColor.red(), currentColor.red(), borders[i - 1], borders[i]),
intermediateColor(percent, previousColor.green(), currentColor.green(), borders[i - 1], borders[i]),
intermediateColor(percent, previousColor.blue(), currentColor.blue(), borders[i - 1], borders[i]),
intermediateColor(percent, previousColor.alpha(), currentColor.alpha(), borders[i - 1], borders[i])
};
}
QHash<int, QColor> getColorMap(const int rectCount, const ColorList& colorList)
{
auto result = QHash<int, QColor> {};
for(int i = 0; i < rectCount; i++)
{
result[i] = getColorByIndex(i, rectCount, colorList);
}
return result;
}
ColorStyle::ColorInfo
createColorInfo(const ColorList& activeColorList, const int rectCount, const int fadingSteps)
{
auto result = ColorStyle::ColorInfo {};
const auto activeColorMap = getColorMap(rectCount, activeColorList);
for(int rectIndex = 0; rectIndex < rectCount; rectIndex++)
{
const auto activeColor = activeColorMap[rectIndex];
auto fadingColors = ColorList {};
fadingColors.colors << offColor << activeColor.darker();
auto fadingMap = getColorMap(fadingSteps + 1, fadingColors);
fadingMap.insert(-1, activeColor);
result.push_back(fadingMap);
}
return result;
}
}
namespace Util
{
ColorStyle createLevelStyle(const RawColorStyle& style, const int widgetWidth)
{
auto result = ColorStyle {};
result.name = style.colorList.name;
result.fadingSteps = style.fadingStepsLevel;
result.horSpacing = style.horSpacingLevel;
result.verSpacing = style.verSpacingLevel;
result.colorList = style.colorList;
result.rectWidth = style.rectWidthLevel;
result.rectHeight = style.rectHeightLevel;
result.rectCount = widgetWidth / (result.rectWidth + result.horSpacing);
result.style = createColorInfo(style.colorList, result.rectCount, style.fadingStepsLevel);
result.name = style.colorList.name;
return result;
}
ColorStyle createSpectrumStyle(const RawColorStyle& style, const int widgetHeight)
{
auto result = ColorStyle {};
result.name = style.colorList.name;
result.fadingSteps = style.fadingStepsSpectrum;
result.horSpacing = style.horSpacingSpectrum;
result.verSpacing = style.verSpacingSpectrum;
result.colorList = style.colorList;
result.rectHeight = style.rectHeightSpectrum;
result.rectCount = widgetHeight / (result.rectHeight + result.verSpacing);
result.style = createColorInfo(style.colorList, result.rectCount, style.fadingStepsSpectrum);
result.name = style.colorList.name;
return result;
}
RawColorStyle createRgbStyle()
{
auto result = RawColorStyle {};
result.colorList.colors << QColor(0, 216, 0)
<< QColor(216, 216, 0)
<< QColor(216, 0, 0)
<< QColor(216, 0, 0);
result.colorList.name = "Fancy";
result.horSpacingLevel = 2;
result.horSpacingLevel = 2;
result.verSpacingSpectrum = 1;
result.horSpacingSpectrum = 1;
result.spectrumBins = 50;
result.fadingStepsLevel = 20;
result.fadingStepsSpectrum = 20;
result.rectHeightSpectrum = 2;
result.rectWidthLevel = 5;
result.rectHeightLevel = 6;
return result;
}
RawColorStyle createBwStyle()
{
auto result = RawColorStyle {};
result.colorList.colors << QColor(27, 32, 47)
<< QColor(134, 134, 134)
<< QColor(216, 216, 216)
<< QColor(255, 255, 255);
result.colorList.name = "B/W";
result.horSpacingLevel = 2;
result.horSpacingLevel = 2;
result.verSpacingSpectrum = 1;
result.horSpacingSpectrum = 1;
result.spectrumBins = 50;
result.fadingStepsLevel = 20;
result.fadingStepsSpectrum = 20;
result.rectHeightSpectrum = 2;
result.rectWidthLevel = 3;
result.rectHeightLevel = 3;
return result;
}
}
QString RawColorStyle::toString() const
{
QString ret;
ret += colorList.name + "";
ret += ", n_bins_sp: " + QString::number(spectrumBins);
ret += ", rect_h_sp: " + QString::number(rectHeightSpectrum);
ret += ", fad_s_sp: " + QString::number(fadingStepsSpectrum);
ret += ", rect_w_lv: " + QString::number(rectWidthLevel);
ret += ", rect_h_lv: " + QString::number(rectHeightLevel);
ret += ", fad_s_lv: " + QString::number(fadingStepsLevel);
ret += ", hor_s_lv: " + QString::number(horSpacingLevel);
ret += ", ver_s_lv: " + QString::number(verSpacingLevel);
ret += ", hor_s_sp: " + QString::number(horSpacingSpectrum);
ret += ", ver_s_sp: " + QString::number(verSpacingSpectrum);
return ret;
}
bool ColorStyle::isValid() const
{
return (rectCount > 0) && ((rectHeight > 0) || (rectWidth > 0));
}
#pragma clang diagnostic pop
......@@ -35,77 +35,58 @@ struct ColorList
struct ColorStyle
{
using ColorInfo = std::vector<QHash<int, QColor>>;
QString name;
// list size is number or rectangles
// int is the step index
std::vector<QHash<int, QColor> > style;
ColorList col_list;
ColorInfo style;
ColorList colorList;
int rect_height;
int rect_width;
int rectHeight {-1};
int rectWidth {-1};
int n_rects;
int n_fading_steps;
int hor_spacing;
int ver_spacing;
int rectCount {-1};
int fadingSteps {-1};
int horSpacing {-1};
int verSpacing {-1};
[[nodiscard]] bool isValid() const;
};
struct RawColorStyle
{
ColorList col_list;
ColorList colorList;
int n_bins_spectrum;
int spectrumBins {20};
int rect_height_spectrum;
int rect_width_level;
int rect_height_level;
int n_rects_level;
int rectHeightSpectrum {2};
int rectWidthLevel {3};
int rectHeightLevel {6};
int levelRects {0};
int n_fading_steps_spectrum;
int n_fading_steps_level;
int fadingStepsSpectrum {20};
int fadingStepsLevel {20};
int hor_spacing_level;
int ver_spacing_level;
int horSpacingLevel {2};
int verSpacingLevel {2};
int hor_spacing_spectrum;
int ver_spacing_spectrum;
int horSpacingSpectrum {2};
int verSpacingSpectrum {1};
RawColorStyle()
{
col_list.name = "";
n_rects_level = 0;
n_bins_spectrum = 20;
rect_height_spectrum = 2;
rect_width_level = 3;
rect_height_level = 6;
n_fading_steps_level = 20;
n_fading_steps_spectrum = 20;
hor_spacing_level = 2;
hor_spacing_spectrum = 2;
ver_spacing_level = 2;
ver_spacing_spectrum = 1;
}
[[nodiscard]] QString toString() const;
};
QString toString() const
namespace Util
{
QString ret;
ret += col_list.name + "";
ret += ", n_bins_sp: " + QString::number(n_bins_spectrum);
ret += ", rect_h_sp: " + QString::number(rect_height_spectrum);
ret += ", fad_s_sp: " + QString::number(n_fading_steps_spectrum);
ret += ", rect_w_lv: " + QString::number(rect_width_level);
ret += ", rect_h_lv: " + QString::number(rect_height_level);
ret += ", fad_s_lv: " + QString::number(n_fading_steps_level);
ret += ", hor_s_lv: " + QString::number(hor_spacing_level);
ret += ", ver_s_lv: " + QString::number(ver_spacing_level);
ret += ", hor_s_sp: " + QString::number(hor_spacing_spectrum);
ret += ", ver_s_sp: " + QString::number(ver_spacing_spectrum);
return ret;
}
[[nodiscard]] RawColorStyle
convertToRawColorStyle(const ColorStyle& levelStyle, const ColorStyle& spectrumStyle);
};
[[nodiscard]] ColorStyle createSpectrumStyle(const RawColorStyle& rawColorStyle, int widgetHeight);
[[nodiscard]] ColorStyle createLevelStyle(const RawColorStyle& rawColorStyle, int widgetWidth);
[[nodiscard]] RawColorStyle createRgbStyle();
[[nodiscard]] RawColorStyle createBwStyle();
}
#endif // STYLETYPES_H
......@@ -21,7 +21,7 @@
#include "Database/Query.h"
#include "Database/VisualStyles.h"
#include "Gui/Plugins/Engine/VisualStyleTypes.h"
#include "Components/Visualization/VisualStyleTypes.h"
#include "Utils/Utils.h"
#include <QColor>
......@@ -87,7 +87,7 @@ QList<RawColorStyle> VisualStyles::getRawColorStyles()
{
RawColorStyle rcs;
rcs.col_list.name = q.value(0).toString();
rcs.colorList.name = q.value(0).toString();
QColor col1, col2, col3, col4;
bool col3v, col4v;
colFromString(q.value(1).toString(), col1);
......@@ -95,20 +95,20 @@ QList<RawColorStyle> VisualStyles::getRawColorStyles()
col3v = colFromString(q.value(3).toString(), col3);
col4v = colFromString(q.value(4).toString(), col4);
rcs.col_list.colors << col1;
rcs.col_list.colors << col2;
if(col3v) { rcs.col_list.colors << col3; }
if(col4v) { rcs.col_list.colors << col4; }
rcs.n_bins_spectrum = q.value(5).toInt();
rcs.rect_height_spectrum = q.value(6).toInt();
rcs.n_fading_steps_spectrum = q.value(7).toInt();
rcs.hor_spacing_spectrum = q.value(8).toInt();
rcs.ver_spacing_spectrum = q.value(9).toInt();
rcs.rect_width_level = q.value(10).toInt();
rcs.rect_height_level = q.value(11).toInt();
rcs.hor_spacing_level = q.value(12).toInt();
rcs.ver_spacing_level = q.value(13).toInt();
rcs.n_fading_steps_level = q.value(14).toInt();
rcs.colorList.colors << col1;
rcs.colorList.colors << col2;
if(col3v) { rcs.colorList.colors << col3; }
if(col4v) { rcs.colorList.colors << col4; }
rcs.spectrumBins = q.value(5).toInt();
rcs.rectHeightSpectrum = q.value(6).toInt();
rcs.fadingStepsSpectrum = q.value(7).toInt();
rcs.horSpacingSpectrum = q.value(8).toInt();
rcs.verSpacingSpectrum = q.value(9).toInt();
rcs.rectWidthLevel = q.value(10).toInt();
rcs.rectHeightLevel = q.value(11).toInt();
rcs.horSpacingLevel = q.value(12).toInt();
rcs.verSpacingLevel = q.value(13).toInt();
rcs.fadingStepsLevel = q.value(14).toInt();
ret_val << rcs;
}
......@@ -118,7 +118,7 @@ QList<RawColorStyle> VisualStyles::getRawColorStyles()
bool VisualStyles::insertRawColorStyle(const RawColorStyle& rcs)
{
if(rawColorStyleExists(rcs.col_list.name))
if(rawColorStyleExists(rcs.colorList.name))
{
return updateRawColorStyle(rcs);
}
......@@ -147,13 +147,13 @@ bool VisualStyles::insertRawColorStyle(const RawColorStyle& rcs)
")";
q.prepare(sql_str);
q.bindValue(":name", Util::convertNotNull(rcs.col_list.name));
q.bindValue(":col1", col2String(rcs.col_list.colors[0]));
q.bindValue(":col2", col2String(rcs.col_list.colors[1]));
q.bindValue(":name", Util::convertNotNull(rcs.colorList.name));
q.bindValue(":col1", col2String(rcs.colorList.colors[0]));
q.bindValue(":col2", col2String(rcs.colorList.colors[1]));
if(rcs.col_list.colors.size() > 2)
if(rcs.colorList.colors.size() > 2)
{
q.bindValue(":col3", col2String(rcs.col_list.colors[2]));
q.bindValue(":col3", col2String(rcs.colorList.colors[2]));
}
else
......@@ -161,23 +161,23 @@ bool VisualStyles::insertRawColorStyle(const RawColorStyle& rcs)
q.bindValue(":col3", QString(""));
}
if(rcs.col_list.colors.size() > 3)
if(rcs.colorList.colors.size() > 3)
{
q.bindValue(":col4", col2String(rcs.col_list.colors[3]));
q.bindValue(":col4", col2String(rcs.colorList.colors[3]));
}
else { q.bindValue(":col4", QString("")); }
q.bindValue(":n_bins_sp", rcs.n_bins_spectrum);
q.bindValue(":rect_height_sp", rcs.rect_height_spectrum);
q.bindValue(":fading_steps_sp", rcs.n_fading_steps_spectrum);
q.bindValue(":h_spacing_sp", rcs.hor_spacing_spectrum);
q.bindValue(":v_spacing_sp", rcs.ver_spacing_spectrum);
q.bindValue(":rect_width_lv", rcs.rect_width_level);
q.bindValue(":rect_height_lv", rcs.rect_height_level);
q.bindValue(":h_spacing_lv", rcs.hor_spacing_level);
q.bindValue(":v_spacing_lv", rcs.ver_spacing_level);
q.bindValue(":fading_steps_lv", rcs.n_fading_steps_level);
q.bindValue(":n_bins_sp", rcs.spectrumBins);
q.bindValue(":rect_height_sp", rcs.rectHeightSpectrum);
q.bindValue(":fading_steps_sp", rcs.fadingStepsSpectrum);
q.bindValue(":h_spacing_sp", rcs.horSpacingSpectrum);
q.bindValue(":v_spacing_sp", rcs.verSpacingSpectrum);
q.bindValue(":rect_width_lv", rcs.rectWidthLevel);
q.bindValue(":rect_height_lv", rcs.rectHeightLevel);
q.bindValue(":h_spacing_lv", rcs.horSpacingLevel);
q.bindValue(":v_spacing_lv", rcs.verSpacingLevel);
q.bindValue(":fading_steps_lv", rcs.fadingStepsLevel);
if(!q.exec())
{
......@@ -190,7 +190,7 @@ bool VisualStyles::insertRawColorStyle(const RawColorStyle& rcs)
bool VisualStyles::updateRawColorStyle(const RawColorStyle& rcs)
{
if(!rawColorStyleExists(rcs.col_list.name))
if(!rawColorStyleExists(rcs.colorList.name))
{
return insertRawColorStyle(rcs);
}
......@@ -219,42 +219,42 @@ bool VisualStyles::updateRawColorStyle(const RawColorStyle& rcs)
" WHERE name=:name";
q.prepare(sql_str);
q.bindValue(":name", Util::convertNotNull(rcs.col_list.name));
q.bindValue(":col1", Util::convertNotNull(col2String(rcs.col_list.colors[0])));
q.bindValue(":col2", Util::convertNotNull(col2String(rcs.col_list.colors[1])));
q.bindValue(":name", Util::convertNotNull(rcs.colorList.name));
q.bindValue(":col1", Util::convertNotNull(col2String(rcs.colorList.colors[0])));
q.bindValue(":col2", Util::convertNotNull(col2String(rcs.colorList.colors[1])));
if(rcs.col_list.colors.size() > 2)
if(rcs.colorList.colors.size() > 2)
{
q.bindValue(":col3", col2String(rcs.col_list.colors[2]));
q.bindValue(":col3", col2String(rcs.colorList.colors[2]));
}
else
{
q.bindValue(":col3", QString(""));
}
if(rcs.col_list.colors.size() > 3)
if(rcs.colorList.colors.size() > 3)
{
q.bindValue(":col4", col2String(rcs.col_list.colors[3]));
q.bindValue(":col4", col2String(rcs.colorList.colors[3]));
}
else
{
q.bindValue(":col4", QString(""));
}
q.bindValue(":n_bins_sp", rcs.n_bins_spectrum);
q.bindValue(":rect_height_sp", rcs.rect_height_spectrum);
q.bindValue(":fading_steps_sp", rcs.n_fading_steps_spectrum);
q.bindValue(":h_spacing_sp", rcs.hor_spacing_spectrum);
q.bindValue(":v_spacing_sp", rcs.ver_spacing_spectrum);
q.bindValue(":rect_width_lv", rcs.rect_width_level);
q.bindValue(":rect_height_lv", rcs.rect_height_level);
q.bindValue(":h_spacing_lv", rcs.hor_spacing_level);
q.bindValue(":v_spacing_lv", rcs.ver_spacing_level);
q.bindValue(":fading_steps_lv", rcs.n_fading_steps_level);
q.bindValue(":n_bins_sp", rcs.spectrumBins);
q.bindValue(":rect_height_sp", rcs.rectHeightSpectrum);
q.bindValue(":fading_steps_sp", rcs.fadingStepsSpectrum);
q.bindValue(":h_spacing_sp", rcs.horSpacingSpectrum);
q.bindValue(":v_spacing_sp", rcs.verSpacingSpectrum);
q.bindValue(":rect_width_lv", rcs.rectWidthLevel);
q.bindValue(":rect_height_lv", rcs.rectHeightLevel);
q.bindValue(":h_spacing_lv", rcs.horSpacingLevel);
q.bindValue(":v_spacing_lv", rcs.verSpacingLevel);
q.bindValue(":fading_steps_lv", rcs.fadingStepsLevel);
if(!q.exec())
{
showError(q, QString("Could not update style ") + rcs.col_list.name);
showError(q, QString("Could not update style ") + rcs.colorList.name);
return false;
}
......
......@@ -18,98 +18,83 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GUI_LevelPainter.h"
#include "VisualColorStyleChooser.h"
#include "Gui/Plugins/ui_GUI_LevelPainter.h"
#include "Interfaces/AudioDataProvider.h"
#include "Utils/Logger/Logger.h"
#include "Utils/Algorithm.h"
#include "Utils/Settings/Settings.h"
#include <QPainter>
#include <QBrush>
#include <cassert>
#include <cstring>
#include <array>
#include <vector>
#include <atomic>
static const size_t Channels = 2;
namespace
{
constexpr const auto LookupTableSize = 40U;
constexpr const auto Channels = 2U;
using LookupTable = std::array<float, LookupTableSize>;
using Step = uint_fast8_t;
using ChannelArray = std::array<float, Channels>;
using ChannelSteps = std::vector<Step>;
using StepArray = std::array<ChannelSteps, Channels>;
struct GUI_LevelPainter::Private
{
ChannelArray level;
StepArray steps;
float* expFunctionLookupTable = nullptr;
LevelDataProvider* dataProvider;
std::atomic_flag lock = ATOMIC_FLAG_INIT;
Private(LevelDataProvider* dataProvider) :
dataProvider(dataProvider) {}
LookupTable initLookupTable()
{ // we want an interval [1.0 ... 0]
auto result = LookupTable {};
void resizeSteps(int n_rects)
{
for(size_t c = 0; c < level.size(); c++)
for(auto i = 0U; i < LookupTableSize; i++)
{
steps[c].resize(size_t(n_rects));
std::fill(steps[c].begin(), steps[c].end(), 0);
}
result[i] = -(static_cast<float>(i) / (LookupTableSize - 1U)) + 1.0F;
}
void initLookupTable()
{
size_t n = 40;
expFunctionLookupTable = new float[n];
for(size_t i = 0; i < n; i++)
{
expFunctionLookupTable[i] = -(i / 40.0f) + 1.0f;
}
return result;
}
float scale(float value)
[[nodiscard]] float scale(const LookupTable& lookupTable, const float value)
{
int v = int(-value);
// [-39, 0]
int idx = std::min(v, 39);
idx = std::max(0, idx);
assert(value <= 0);
const auto iVal = static_cast<uint32_t>(-value);
return expFunctionLookupTable[idx];
const auto index = std::clamp(iVal, 0U, LookupTableSize - 1U);
return lookupTable[index];
}
void setLevel(float left, float right)
void resizeStepArray(StepArray& steps, const int rects)
{
level[0] = scale(left);
level[1] = scale(right);
}
void decreaseStep(size_t channel, size_t step)
for(auto& channel: steps)
{
steps[channel][step] = steps[channel][step] - 1;
channel.resize(rects);
std::fill(channel.begin(), channel.end(), 0);
}
}
}
void setStep(size_t channel, size_t step, Step value)
struct GUI_LevelPainter::Private
{
steps[channel][step] = value;
}
ChannelArray level {0, 0};
StepArray steps;
LookupTable lookupTable {0};
LevelDataProvider* dataProvider;
bool isFadeoutCompleted {true};
std::atomic_flag lock = ATOMIC_FLAG_INIT;
explicit Private(LevelDataProvider* dataProvider) :
dataProvider(dataProvider) {}
};
GUI_LevelPainter::GUI_LevelPainter(LevelDataProvider* dataProvider, PlayManager* playManager, QWidget* parent) :
VisualPlugin(playManager, parent),
Engine::LevelDataReceiver()
{
m = Pimpl::make<Private>(dataProvider);
SetSetting(Set::Engine_ShowLevel, false);
}
Engine::LevelDataReceiver(),
m {Pimpl::make<Private>(dataProvider)} {}
GUI_LevelPainter::~GUI_LevelPainter()
{
......@@ -124,43 +109,32 @@ GUI_LevelPainter::~GUI_LevelPainter()
void GUI_LevelPainter::initUi()
{
if(isUiInitialized())
{
return;
}
m->initLookupTable();
VisualPlugin::initUi();
setupParent(this, &ui);
}
void GUI_LevelPainter::finalizeInitialization()
{
VisualPlugin::initUi();
m->lookupTable = initLookupTable();
m->resizeSteps(currentStyle().n_rects);
m->setLevel(0, 0);
resizeStepArray(m->steps, currentStyle().rectCount);
constexpr const auto InitialValue = -100.0F;
m->level[0] = scale(m->lookupTable, InitialValue);
m->level[1] = scale(m->lookupTable, InitialValue);
PlayerPlugin::Base::finalizeInitialization();
m->dataProvider->registerLevelReceiver(this);
reload();
}
QString GUI_LevelPainter::name() const
{
return "Level";
}
QString GUI_LevelPainter::name() const { return "Level"; }
QString GUI_LevelPainter::displayName() const
{
return tr("Level");
}
QString GUI_LevelPainter::displayName() const { return tr("Level"); }
bool GUI_LevelPainter::isActive() const
{
return this->isVisible();
}
bool GUI_LevelPainter::isActive() const { return isProcessing(); }
void GUI_LevelPainter::retranslate()
{
......@@ -169,125 +143,78 @@ void GUI_LevelPainter::retranslate()
void GUI_LevelPainter::setLevel(float left, float right)
{
if(!isUiInitialized() || !isVisible())
if(!isUiInitialized() || !isProcessing() || m->lock.test_and_set())
{
return;
}
if(m->lock.test_and_set())
{
return;
}
m->setLevel(left, right);
stop_fadeout_timer();
update();
m->level[0] = scale(m->lookupTable, left);
m->level[1] = scale(m->lookupTable, right);
m->lock.clear();
update();
}
void GUI_LevelPainter::paintEvent(QPaintEvent* e)
void GUI_LevelPainter::paint()
{
Q_UNUSED(e)
QPainter painter(this);
auto painter = QPainter(this);
const auto& style = currentStyle();
ColorStyle style = currentStyle();
int n_rects = style.n_rects;
int border_x = style.hor_spacing;
int border_y = style.ver_spacing;
int n_fading_steps = style.n_fading_steps;
int h_rect = style.rect_height;
int w_rect = style.rect_width;
constexpr const auto InitialY = 10;
const auto yOffset = std::array<int, Channels> {InitialY, InitialY + style.rectHeight + style.verSpacing};
const auto initialX = (style.rectWidth + style.horSpacing);
int y = 10;
size_t num_zero = 0;
int x_init = (w_rect + border_x);
auto zeroCount = 0U;
for(size_t c = 0; c < Channels; c++)
for(auto c = 0U; c < Channels; c++)
{
size_t n_colored_rects = size_t(n_rects * m->level[c]);
QRect rect(0, y, w_rect, h_rect);
// NOLINTNEXTLINE(*-narrowing-conversions)
const auto coloredRects = static_cast<int>(style.rectCount * m->level[c]);
for(size_t r = 0; r < size_t(n_rects); r++)
auto rect = QRect(0, yOffset[c], style.rectWidth, style.rectHeight);
for(auto r = 0; r < style.rectCount; r++)
{
if(r < n_colored_rects)
{
if(!style.style[r].contains(-1))
{
spLog(Log::Debug, this) << "Style does not contain -1";
}
const auto colorHash = (r < coloredRects) ? -1 : m->steps[c][r];
const auto color = style.style[r][colorHash];
painter.fillRect(rect, color);
painter.fillRect(rect, style.style[r].value(-1));
m->setStep(c, r, Step(n_fading_steps - 1));
}
else
{
if(!style.style[r].contains(m->steps[c][r]))
if(r < coloredRects)
{
spLog(Log::Debug, this) << "2 Style does not contain " << m->steps[c][r] << ", " << c << ", " << r;
m->steps[c][r] = static_cast<Step>(style.fadingSteps - 1);
}
painter.fillRect(rect, style.style[r].value(m->steps[c][r]));
if(m->steps[c][r] > 0)
else
{
m->decreaseStep(c, r);
m->steps[c][r] = std::max(m->steps[c][r] - 1, 0);
}
if(m->steps[c][r] == 0)
{
num_zero++;
}
zeroCount++;
}
rect.translate(x_init, 0);
}
if(num_zero == Channels * size_t(n_rects))
{
// all rectangles where fade out
stop_fadeout_timer();
rect.translate(initialX, 0);
}
y += h_rect + border_y;
m->isFadeoutCompleted = (zeroCount == (Channels * style.rectCount));
}
}
void GUI_LevelPainter::doFadeoutStep()
{
for(float& l: m->level)
{
l -= 2.0f;
}
update();
}
bool GUI_LevelPainter::isFadeoutCompleted() const { return m->isFadeoutCompleted; }
void GUI_LevelPainter::update_style(int new_index)
void GUI_LevelPainter::doFadeoutStep()
{
SetSetting(Set::Level_Style, new_index);
m_ecsc->reload(width(), height());
m->resizeSteps(currentStyle().n_rects);
update();
Util::Algorithm::transform(m->level, [](const auto& val) {
return val - 0.1F; // NOLINT(*-magic-numbers)
});
}
void GUI_LevelPainter::reload()
{
ColorStyle style = currentStyle();
int new_height = style.rect_height * 2 + style.ver_spacing + 12;
setMinimumHeight(0);
setMaximumHeight(100);
const auto newHeight = (currentStyle().rectHeight * 2) + (currentStyle().verSpacing + 12);
setMinimumHeight(new_height);
setMaximumHeight(new_height);
setMinimumHeight(newHeight);
setMaximumHeight(newHeight);
if(isVisible())
{
......@@ -297,39 +224,33 @@ void GUI_LevelPainter::reload()
void GUI_LevelPainter::showEvent(QShowEvent* e)
{
SetSetting(Set::Engine_ShowLevel, true);
m->dataProvider->levelActiveChanged(true);
VisualPlugin::showEvent(e);
}
void GUI_LevelPainter::closeEvent(QCloseEvent* e)
{
SetSetting(Set::Engine_ShowLevel, false);
m->dataProvider->levelActiveChanged(false);
VisualPlugin::closeEvent(e);
}
void GUI_LevelPainter::hideEvent(QHideEvent* e)
{
VisualPlugin::hideEvent(e);
}
QWidget* GUI_LevelPainter::widget() { return this; }
QWidget* GUI_LevelPainter::widget()
{
return this;
}
bool GUI_LevelPainter::hasSmallButtons() const { return true; }
bool GUI_LevelPainter::hasSmallButtons() const
{
return true;
}
int GUI_LevelPainter::loadStyleIndex() const { return GetSetting(Set::Level_Style); }
void GUI_LevelPainter::saveStyleIndex(const int index) const { SetSetting(Set::Level_Style, index); }
ColorStyle GUI_LevelPainter::currentStyle() const
bool GUI_LevelPainter::applyStyle(const ColorStyle& colorStyle)
{
return m_ecsc->get_color_scheme_level(currentStyleIndex());
resizeStepArray(m->steps, colorStyle.rectCount);
update();
return true;
}
int GUI_LevelPainter::currentStyleIndex() const
ColorStyle GUI_LevelPainter::extractStyle(const RawColorStyle& rawColorStyle) const
{
return GetSetting(Set::Level_Style);
return Util::createLevelStyle(rawColorStyle, width());
}
......@@ -41,30 +41,32 @@ class GUI_LevelPainter :
GUI_LevelPainter(LevelDataProvider* dataProvider, PlayManager* playManager, QWidget* parent = nullptr);
~GUI_LevelPainter() override;
QString name() const override;
QString displayName() const override;
bool isActive() const override;
public slots:
void update_style(int new_index) override;
[[nodiscard]] QString name() const override;
[[nodiscard]] QString displayName() const override;
[[nodiscard]] bool isActive() const override;
protected:
void paintEvent(QPaintEvent* e) override;
void showEvent(QShowEvent*) override;
void closeEvent(QCloseEvent*) override;
void hideEvent(QHideEvent* e) override;
void showEvent(QShowEvent* e) override;
void closeEvent(QCloseEvent* e) override;
void initUi() override;
void retranslate() override;
QWidget* widget() override;
bool hasSmallButtons() const override;
ColorStyle currentStyle() const override;
int currentStyleIndex() const override;
[[nodiscard]] QWidget* widget() override;
[[nodiscard]] bool hasSmallButtons() const override;
void finalizeInitialization() override;
protected slots:
[[nodiscard]] ColorStyle extractStyle(const RawColorStyle& rawColorStyle) const override;
bool applyStyle(const ColorStyle& colorStyle) override;
[[nodiscard]] int loadStyleIndex() const override;
void saveStyleIndex(int index) const override;
void paint() override;
[[nodiscard]] bool isFadeoutCompleted() const override;
protected slots: // NOLINT(*-redundant-access-specifiers)
void doFadeoutStep() override;
void setLevel(float, float) override;
void setLevel(float left, float right) override;
private:
void reload();
......
......@@ -23,11 +23,9 @@
#include "Interfaces/AudioDataProvider.h"
#include "VisualColorStyleChooser.h"
#include "Utils/globals.h"
#include "Utils/Algorithm.h"
#include "Utils/Settings/Settings.h"
#include "Utils/Logger/Logger.h"
#include "Utils/globals.h"
#include <QPainter>
#include <QList>
......@@ -38,10 +36,73 @@
#include <algorithm>
#include <mutex>
using Step = uint_fast8_t;
namespace
{
using Step = int8_t;
using BinSteps = std::vector<Step>;
using StepArray = std::vector<BinSteps>;
constexpr const auto MinBinCount = 50U;
std::vector<float> createLookupTable(const unsigned int bins)
{
auto result = std::vector<float> {};
result.reserve(bins);
// make bass value smaller than high frequencies
// log_lu[0] = 0.0.01666667
// log_lu[50] = 0.37930765
for(unsigned int i = 0; i < bins; i++)
{
constexpr const auto logBase = 10.0F;
const auto exponent = (i / 140.0F) + 1.0F;
const auto value = std::pow(logBase, exponent);
constexpr const auto scaleFactor = (8.0F * 75.0F);
result.push_back(value / scaleFactor);
}
return result;
}
int getColoredItemsForBar(const float percent, const int widgetHeight, const int itemHeight, const int spacing)
{
const auto coloredHeight = percent * widgetHeight; // NOLINT(*-narrowing-conversions)
// NOLINTNEXTLINE(*-narrowing-conversions)
return std::max<int>(0, static_cast<int>(coloredHeight / (itemHeight + spacing) - 1.0F));
}
int getItemHeightByCount(const int rectCount, const int widgetHeight, const int spacing)
{
return static_cast<int>((widgetHeight / rectCount) - spacing);
}
struct FadingInfo
{
QColor color;
Step brightness;
};
FadingInfo fadeRectangle(const ColorStyle& colorStyle, const int itemIndex, const bool isFullBrightness,
const Step currentBrightness, const Step maxBrightness)
{
const auto colorHash = isFullBrightness ? -1 : currentBrightness;
const auto newBrightness = isFullBrightness
? maxBrightness
: std::max<Step>(0, currentBrightness - 1); // NOLINT(*-narrowing-conversions)
return {colorStyle.style[itemIndex].value(colorHash), newBrightness};
}
int getBinWidth(const int widgetWidth, const int binCount, const int horOffset, const int spacing)
{
const auto spacings = (binCount - 1) * spacing;
const auto coloredSpace = widgetWidth - spacings - horOffset;
constexpr const auto RoundingTolerance = 10;
return (coloredSpace + RoundingTolerance) / binCount;
}
}
struct GUI_Spectrum::Private
{
std::atomic_flag locked = ATOMIC_FLAG_INIT;
......@@ -49,24 +110,12 @@ struct GUI_Spectrum::Private
std::vector<float> spec;
StepArray steps;
SpectrumDataProvider* dataProvider;
float* logarithmLookupTable = nullptr;
std::vector<float> logarithmLookupTable;
bool isFadeoutCompleted {true};
explicit Private(SpectrumDataProvider* dataProvider) :
dataProvider(dataProvider) {}
void initLookupTable(int bins)
{
logarithmLookupTable = new float[bins];
// make bass value smaller than high frequencies
// log_lu[0] = 0.0.01666667
// log_lu[50] = 0.37930765
for(int i = 0; i < bins; i++)
{
logarithmLookupTable[i] = (std::pow(10.0f, (i / 140.0f) + 1.0f) / 8.0f) / 75.0f;
}
}
void setSpectrum(const std::vector<float>& spectrum)
{
// s: [-75, 0]
......@@ -75,24 +124,24 @@ struct GUI_Spectrum::Private
spec.clear();
spec.reserve(spectrum.size());
isFadeoutCompleted = true;
for(size_t i = 0; i < spectrum.size(); i++)
{
float f = (spectrum[i] + 75.0) * logarithmLookupTable[i];
const auto f = (spectrum[i] + 75.0F) * logarithmLookupTable[i];
spec.push_back(f);
}
}
void resizeSteps(int binCount, int rects)
void resizeSteps(unsigned int binCount, const int rects)
{
binCount = std::max(50, binCount);
if(binCount != (int) steps.size())
binCount = std::max(MinBinCount, binCount);
if(binCount != steps.size())
{
steps.resize(binCount);
}
for(BinSteps& step: steps)
for(auto& step: steps)
{
step.resize(rects);
std::fill(step.begin(), step.end(), 0);
......@@ -102,12 +151,8 @@ struct GUI_Spectrum::Private
GUI_Spectrum::GUI_Spectrum(SpectrumDataProvider* dataProvider, PlayManager* playManager, QWidget* parent) :
VisualPlugin(playManager, parent),
Engine::SpectrumDataReceiver()
{
m = Pimpl::make<Private>(dataProvider);
SetSetting(Set::Engine_ShowSpectrum, false);
}
Engine::SpectrumDataReceiver(),
m {Pimpl::make<Private>(dataProvider)} {}
GUI_Spectrum::~GUI_Spectrum()
{
......@@ -122,97 +167,52 @@ GUI_Spectrum::~GUI_Spectrum()
void GUI_Spectrum::initUi()
{
if(isUiInitialized())
{
return;
}
VisualPlugin::initUi();
setupParent(this, &ui);
}
void GUI_Spectrum::finalizeInitialization()
{
VisualPlugin::initUi();
const auto bins = static_cast<unsigned int>(GetSetting(Set::Engine_SpectrumBins));
int bins = GetSetting(Set::Engine_SpectrumBins);
m->logarithmLookupTable = createLookupTable(bins);
m->initLookupTable(bins);
m->resizeSteps(bins, currentStyle().n_rects);
m->spec.resize((size_t) bins, -100.0f);
constexpr const auto InitialValue = -100.0F;
m->spec.resize(bins, InitialValue);
PlayerPlugin::Base::finalizeInitialization();
m->dataProvider->registerSpectrumReceiver(this);
update();
m->dataProvider->registerSpectrumReceiver(this);
}
QString GUI_Spectrum::name() const
{
return "Spectrum";
}
QString GUI_Spectrum::name() const { return "Spectrum"; }
QString GUI_Spectrum::displayName() const
{
return tr("Spectrum");
}
QString GUI_Spectrum::displayName() const { return tr("Spectrum"); }
bool GUI_Spectrum::isActive() const
{
return GetSetting(Set::Engine_ShowSpectrum);
}
bool GUI_Spectrum::isActive() const { return isProcessing(); }
void GUI_Spectrum::retranslate() {}
void GUI_Spectrum::setSpectrum(const std::vector<float>& spectrum)
{
if(!isUiInitialized() || !isVisible())
if(isUiInitialized() && isProcessing())
{
return;
}
m->setSpectrum(spectrum);
stop_fadeout_timer();
update();
}
void GUI_Spectrum::doFadeoutStep()
{
for(auto it = m->spec.begin(); it != m->spec.end(); it++)
{
*it = (*it - 1.5f);
}
update();
}
void GUI_Spectrum::update_style(int new_index)
{
if(!isUiInitialized())
{
return;
}
bool GUI_Spectrum::isFadeoutCompleted() const { return m->isFadeoutCompleted; }
if(m->locked.test_and_set())
void GUI_Spectrum::doFadeoutStep()
{
spLog(Log::Debug, this) << "Cannot update stylde";
return;
}
m_ecsc->reload(width(), height());
SetSetting(Set::Spectrum_Style, new_index);
int bins = GetSetting(Set::Engine_SpectrumBins);
m->resizeSteps(bins, currentStyle().n_rects);
update();
m->locked.clear();
Util::Algorithm::transform(m->spec, [](const auto v) {
return v - 0.1F; // NOLINT(*-magic-numbers)
});
}
void GUI_Spectrum::showEvent(QShowEvent* e)
{
SetSetting(Set::Engine_ShowSpectrum, true);
m->dataProvider->spectrumActiveChanged(true);
VisualPlugin::showEvent(e);
}
......@@ -220,87 +220,51 @@ void GUI_Spectrum::showEvent(QShowEvent* e)
void GUI_Spectrum::closeEvent(QCloseEvent* e)
{
VisualPlugin::closeEvent(e);
SetSetting(Set::Engine_ShowSpectrum, false);
m->dataProvider->spectrumActiveChanged(false);
}
void GUI_Spectrum::paintEvent(QPaintEvent* e)
void GUI_Spectrum::paint()
{
Q_UNUSED(e)
QPainter painter(this);
constexpr const auto FirstBinOfInterest = 0;
constexpr const auto BinsOfInterest = 35;
constexpr const auto HorizontalOffset = 3;
float widget_height = height() * 1.0f;
const auto& style = currentStyle();
const auto itemHeight = getItemHeightByCount(style.rectCount, height(), style.verSpacing);
const auto binWidth = getBinWidth(width(), BinsOfInterest, HorizontalOffset, style.horSpacing);
ColorStyle style = currentStyle();
int n_rects = style.n_rects;
int n_fading_steps = style.n_fading_steps;
int h_rect = int((widget_height / n_rects) - style.ver_spacing);
int border_y = style.ver_spacing;
int border_x = style.hor_spacing;
auto painter = QPainter(this);
auto x = HorizontalOffset;
auto emptyItems = 0;
const int ninety = 35;
const int offset = 0;
int n_zero = 0;
int x = 3;
int w_bin = ((width() + 10) / (ninety - offset)) - border_x;
// run through all bins
for(int i = offset; i < ninety + 1; i++)
{
// if this is one bar, how tall would it be?
int h = int(m->spec.at(i) * widget_height);
// how many colored rectangles would fit into this bar?
int colored_rects = h / (h_rect + border_y) - 1;
colored_rects = std::max(colored_rects, 0);
// we start from bottom with painting
int y = int(widget_height - h_rect);
// run vertical
QRect rect(x, y, w_bin, h_rect);
QColor col;
for(int r = 0; r < n_rects; r++)
{
// 100%
if(r < colored_rects)
for(int bin = FirstBinOfInterest; bin <= (FirstBinOfInterest + BinsOfInterest); bin++)
{
col = currentStyle().style[r].value(-1);
m->steps[i][r] = n_fading_steps;
}
const auto coloredRectCount = getColoredItemsForBar(m->spec[bin], height(), itemHeight, style.verSpacing);
const auto y = height() - itemHeight;
// fading out
else
auto rect = QRect(x, y, binWidth, itemHeight);
for(int itemIndex = 0; itemIndex < style.rectCount; itemIndex++)
{
col = currentStyle().style[r].value(m->steps[i][r]);
const auto hasFullBrightness = (itemIndex < coloredRectCount);
const auto fadeInfo = fadeRectangle(style, itemIndex, hasFullBrightness, m->steps[bin][itemIndex],
style.fadingSteps); // NOLINT(*-narrowing-conversions)
if(m->steps[i][r] > 0)
m->steps[bin][itemIndex] = fadeInfo.brightness;
if(fadeInfo.brightness == 0)
{
m->steps[i][r]--;
}
else
{
n_zero++;
}
emptyItems++;
}
painter.fillRect(rect, col);
painter.fillRect(rect, fadeInfo.color);
rect.translate(0, -(h_rect + border_y));
rect.translate(0, -(itemHeight + style.verSpacing));
}
x += w_bin + border_x;
x += binWidth + style.horSpacing;
}
if(n_zero == (ninety - offset) * n_rects)
{
stop_fadeout_timer();
}
const auto numRectangles = BinsOfInterest * style.rectCount;
m->isFadeoutCompleted = (emptyItems >= numRectangles);
}
QWidget* GUI_Spectrum::widget()
......@@ -313,12 +277,27 @@ bool GUI_Spectrum::hasSmallButtons() const
return false;
}
ColorStyle GUI_Spectrum::currentStyle() const
ColorStyle GUI_Spectrum::extractStyle(const RawColorStyle& rawColorStyle) const
{
return m_ecsc->get_color_scheme_spectrum(currentStyleIndex());
return Util::createSpectrumStyle(rawColorStyle, height());
}
int GUI_Spectrum::currentStyleIndex() const
bool GUI_Spectrum::applyStyle(const ColorStyle& colorStyle)
{
if(m->locked.test_and_set())
{
return GetSetting(Set::Spectrum_Style);
return false;
}
const auto bins = static_cast<unsigned int>(GetSetting(Set::Engine_SpectrumBins));
m->resizeSteps(bins, colorStyle.rectCount);
update();
m->locked.clear();
return true;
}
int GUI_Spectrum::loadStyleIndex() const { return GetSetting(Set::Spectrum_Style); }
void GUI_Spectrum::saveStyleIndex(const int index) const { SetSetting(Set::Spectrum_Style, index); }
......@@ -43,29 +43,34 @@ class GUI_Spectrum :
explicit GUI_Spectrum(SpectrumDataProvider* dataProvider, PlayManager* playManager, QWidget* parent = nullptr);
~GUI_Spectrum() override;
QString name() const override;
QString displayName() const override;
bool isActive() const override;
[[nodiscard]] QString name() const override;
[[nodiscard]] QString displayName() const override;
[[nodiscard]] bool isActive() const override;
void setSpectrum(const std::vector<float>& spectrum) override;
protected:
void paintEvent(QPaintEvent* e) override;
void showEvent(QShowEvent* e) override;
void closeEvent(QCloseEvent* e) override;
void initUi() override;
void retranslate() override;
QWidget* widget() override;
bool hasSmallButtons() const override;
ColorStyle currentStyle() const override;
int currentStyleIndex() const override;
[[nodiscard]] QWidget* widget() override;
[[nodiscard]] bool hasSmallButtons() const override;
void finalizeInitialization() override;
void paint() override;
protected slots:
void doFadeoutStep() override;
[[nodiscard]] ColorStyle extractStyle(const RawColorStyle& rawColorStyle) const override;
bool applyStyle(const ColorStyle& colorStyle) override;
public slots:
void setSpectrum(const std::vector<float>& spectrum) override;
void update_style(int new_index) override;
[[nodiscard]] int loadStyleIndex() const override;
void saveStyleIndex(int index) const override;
[[nodiscard]] bool isFadeoutCompleted() const override;
protected slots: // NOLINT(*-redundant-access-specifiers)
void doFadeoutStep() override;
};
#endif // GUI_SPECTRUM_H
......@@ -44,7 +44,7 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_close">
<widget class="QPushButton" name="btnClose">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
......@@ -54,14 +54,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_apply">
<property name="text">
<string notr="true">Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_ok">
<widget class="QPushButton" name="btnOk">
<property name="text">
<string notr="true">Ok</string>
</property>
......@@ -78,7 +71,7 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="6" column="1">
<widget class="QSpinBox" name="sb_rect_height_sp">
<widget class="QSpinBox" name="sbRectHeightSpec">
<property name="minimum">
<number>1</number>
</property>
......@@ -102,7 +95,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="sb_fading_steps_sp">
<widget class="QSpinBox" name="sbFadingStepsSpec">
<property name="minimum">
<number>0</number>
</property>
......@@ -122,7 +115,7 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="sb_v_spacing_sp">
<widget class="QSpinBox" name="sbVerSpacingSpec">
<property name="maximum">
<number>20</number>
</property>
......@@ -136,7 +129,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="sb_h_spacing_sp">
<widget class="QSpinBox" name="sbHorSpacingSpec">
<property name="maximum">
<number>20</number>
</property>
......@@ -166,7 +159,7 @@
</widget>
</item>
<item row="12" column="1">
<widget class="QSpinBox" name="sb_rect_height_lv">
<widget class="QSpinBox" name="sbRectHeightLvl">
<property name="minimum">
<number>1</number>
</property>
......@@ -197,7 +190,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="sb_v_spacing_lv">
<widget class="QSpinBox" name="sbVerSpacingLvl">
<property name="maximum">
<number>20</number>
</property>
......@@ -211,21 +204,21 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="sb_fading_steps_lv">
<widget class="QSpinBox" name="sbFadingStepsLvl">
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="sb_h_spacing_lv">
<widget class="QSpinBox" name="sbHorSpacingLvl">
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QSpinBox" name="sb_rect_width_lv">
<widget class="QSpinBox" name="sbRectWidthLvl">
<property name="minimum">
<number>1</number>
</property>
......@@ -237,7 +230,7 @@
</layout>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="lab_title">
<widget class="QLabel" name="labTitle">
<property name="font">
<font>
<pointsize>11</pointsize>
......@@ -253,7 +246,7 @@
<item row="2" column="0" colspan="6">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="combo_styles">
<widget class="Gui::ComboBox" name="comboStyles">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -266,40 +259,68 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_undo">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
<widget class="Gui::MenuToolButton" name="btnMenu">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
<string notr="true">Menu</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_save">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</layout>
</item>
<item row="3" column="0" colspan="6">
<layout class="QGridLayout" name="gridLayout_4">
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="0" column="9">
<widget class="QCheckBox" name="cbColor4">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
<string>Color 4</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_delete">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
<string>Color 1</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<item row="0" column="8">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="6">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="7">
<item row="0" column="5">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -312,25 +333,24 @@
</property>
</spacer>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lab_col_2">
<property name="text">
<string>Color 2</string>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lab_col_1">
<property name="text">
<string>Color 1</string>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="btn_col2">
<item row="0" column="4">
<widget class="QPushButton" name="btnColor2">
<property name="maximumSize">
<size>
<width>25</width>
<width>32</width>
<height>16777215</height>
</size>
</property>
......@@ -342,8 +362,8 @@
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checked">
......@@ -351,61 +371,38 @@
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QLabel" name="lab_col_3">
<property name="text">
<string>Color 3</string>
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QLabel" name="lab_col_4">
<property name="text">
<string>Color 4</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="enabled">
<bool>false</bool>
</property>
<item row="0" column="10">
<widget class="QPushButton" name="btnColor4">
<property name="maximumSize">
<size>
<width>20</width>
<width>32</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="0" column="5">
<item row="0" column="3">
<widget class="QCheckBox" name="checkBox_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
<string>Color 2</string>
</property>
<property name="checkable">
<bool>true</bool>
......@@ -415,43 +412,11 @@
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QCheckBox" name="cb_col3">
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="13">
<widget class="QCheckBox" name="cb_col4">
<property name="maximumSize">
<size>
<width>20</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="btn_col1">
<item row="0" column="7">
<widget class="QPushButton" name="btnColor3">
<property name="maximumSize">
<size>
<width>25</width>
<width>32</width>
<height>16777215</height>
</size>
</property>
......@@ -463,20 +428,17 @@
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QPushButton" name="btn_col3">
<item row="0" column="1">
<widget class="QPushButton" name="btnColor1">
<property name="maximumSize">
<size>
<width>25</width>
<width>32</width>
<height>16777215</height>
</size>
</property>
......@@ -488,93 +450,67 @@
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="14">
<widget class="QPushButton" name="btn_col4">
<property name="maximumSize">
<size>
<width>25</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
<item row="0" column="6">
<widget class="QCheckBox" name="cbColor3">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
<string>Color 3</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="11">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::ComboBox</class>
<extends>QComboBox</extends>
<header>Gui/Utils/Widgets/ComboBox.h</header>
</customwidget>
<customwidget>
<class>Gui::MenuToolButton</class>
<extends>QPushButton</extends>
<header location="global">Gui/Utils/MenuTool/MenuToolButton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>combo_styles</tabstop>
<tabstop>btn_undo</tabstop>
<tabstop>btn_save</tabstop>
<tabstop>btn_delete</tabstop>
<tabstop>comboStyles</tabstop>
<tabstop>checkBox</tabstop>
<tabstop>btn_col1</tabstop>
<tabstop>btnColor1</tabstop>
<tabstop>checkBox_2</tabstop>
<tabstop>btn_col2</tabstop>
<tabstop>cb_col3</tabstop>
<tabstop>btn_col3</tabstop>
<tabstop>cb_col4</tabstop>
<tabstop>btn_col4</tabstop>
<tabstop>sb_fading_steps_sp</tabstop>
<tabstop>sb_h_spacing_sp</tabstop>
<tabstop>sb_v_spacing_sp</tabstop>
<tabstop>sb_rect_height_sp</tabstop>
<tabstop>sb_fading_steps_lv</tabstop>
<tabstop>sb_h_spacing_lv</tabstop>
<tabstop>sb_v_spacing_lv</tabstop>
<tabstop>sb_rect_height_lv</tabstop>
<tabstop>sb_rect_width_lv</tabstop>
<tabstop>btnColor2</tabstop>
<tabstop>cbColor3</tabstop>
<tabstop>btnColor3</tabstop>
<tabstop>cbColor4</tabstop>
<tabstop>btnColor4</tabstop>
<tabstop>sbFadingStepsSpec</tabstop>
<tabstop>sbHorSpacingSpec</tabstop>
<tabstop>sbVerSpacingSpec</tabstop>
<tabstop>sbRectHeightSpec</tabstop>
<tabstop>sbFadingStepsLvl</tabstop>
<tabstop>sbHorSpacingLvl</tabstop>
<tabstop>sbVerSpacingLvl</tabstop>
<tabstop>sbRectHeightLvl</tabstop>
<tabstop>sbRectWidthLvl</tabstop>
</tabstops>
<resources>
<include location="../../Resources/Icons.qrc"/>
</resources>
<connections>
<connection>
<sender>btn_close</sender>
<sender>btnClose</sender>
<signal>clicked()</signal>
<receiver>GUI_Style</receiver>
<slot>close()</slot>
......@@ -590,9 +526,9 @@
</hints>
</connection>
<connection>
<sender>cb_col3</sender>
<sender>cbColor3</sender>
<signal>toggled(bool)</signal>
<receiver>btn_col3</receiver>
<receiver>btnColor3</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
......@@ -606,9 +542,9 @@
</hints>
</connection>
<connection>
<sender>cb_col4</sender>
<sender>cbColor4</sender>
<signal>toggled(bool)</signal>
<receiver>btn_col4</receiver>
<receiver>btnColor4</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
......