mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Qt: initial shader parameter support
This commit is contained in:
parent
4a9ef99759
commit
572c1ea2d3
@ -3500,6 +3500,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW,
|
||||
"表示(&V)")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS,
|
||||
"閉じたドック")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_SHADER_PARAMS,
|
||||
"シェーダーのパラメータ")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS,
|
||||
"設定(&O)...")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_DOCK_POSITIONS,
|
||||
|
@ -3756,6 +3756,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW,
|
||||
"&View")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS,
|
||||
"Closed Docks")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_SHADER_PARAMS,
|
||||
"Shader Parameters")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS,
|
||||
"&Options...")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_DOCK_POSITIONS,
|
||||
|
@ -1886,6 +1886,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW,
|
||||
MENU_ENUM_LABEL_VALUE_QT_MENU_SEARCH_CLEAR,
|
||||
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_CLOSED_DOCKS,
|
||||
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_SHADER_PARAMS,
|
||||
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS,
|
||||
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_DOCK_POSITIONS,
|
||||
MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_OPTIONS_SAVE_GEOMETRY,
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QDropEvent>
|
||||
#include <QtConcurrentRun>
|
||||
#include <QtNetwork>
|
||||
#include <cmath>
|
||||
|
||||
#include "../ui_qt.h"
|
||||
#include "ui_qt_load_core_window.h"
|
||||
@ -927,6 +928,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
,m_allPlaylistsGridMaxCount(0)
|
||||
,m_playlistEntryDialog(NULL)
|
||||
,m_statusMessageElapsedTimer()
|
||||
,m_shaderParamsDialog(NULL)
|
||||
,m_networkManager(new QNetworkAccessManager(this))
|
||||
,m_updateProgressDialog(new QProgressDialog())
|
||||
,m_updateFile()
|
||||
@ -1214,6 +1216,247 @@ void MainWindow::removeUpdateTempFiles()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShaderParamsClicked()
|
||||
{
|
||||
QFormLayout *form = new QFormLayout();
|
||||
video_shader_ctx_t shader_info;
|
||||
unsigned i;
|
||||
|
||||
video_shader_driver_get_current_shader(&shader_info);
|
||||
|
||||
if (!shader_info.data || shader_info.data->num_parameters > GFX_MAX_PARAMETERS)
|
||||
return;
|
||||
|
||||
/* shader might have changed, so re-create the entire window */
|
||||
if (m_shaderParamsDialog)
|
||||
delete m_shaderParamsDialog;
|
||||
|
||||
m_shaderParamsDialog = new QDialog();
|
||||
m_shaderParamsDialog->setLayout(form);
|
||||
m_shaderParamsDialog->setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PARAMETERS));
|
||||
|
||||
for (i = 0; i < shader_info.data->num_parameters; i++)
|
||||
{
|
||||
struct video_shader_parameter *param = &shader_info.data->parameters[i];
|
||||
QString desc = param->desc;
|
||||
|
||||
if ((param->minimum == 0.0)
|
||||
&& (param->maximum
|
||||
== (param->minimum
|
||||
+ param->step)))
|
||||
{
|
||||
/* option is basically a bool, so use a checkbox */
|
||||
QCheckBox *checkBox = new QCheckBox(m_shaderParamsDialog);
|
||||
checkBox->setChecked(param->current == param->maximum ? true : false);
|
||||
checkBox->setProperty("param", QVariant::fromValue(param));
|
||||
|
||||
connect(checkBox, SIGNAL(clicked()), this, SLOT(onShaderParamCheckBoxClicked()));
|
||||
|
||||
form->addRow(desc, checkBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
QDoubleSpinBox *doubleSpinBox = NULL;
|
||||
QSpinBox *spinBox = NULL;
|
||||
QHBoxLayout *box = new QHBoxLayout();
|
||||
QSlider *slider = new QSlider(Qt::Horizontal, m_shaderParamsDialog);
|
||||
double value = lerp(param->minimum, param->maximum, 0, 100, param->current);
|
||||
double intpart = 0;
|
||||
bool stepIsFractional = modf(param->step, &intpart);
|
||||
|
||||
slider->setRange(0, 100);
|
||||
slider->setSingleStep(1);
|
||||
slider->setValue(value);
|
||||
slider->setProperty("param", QVariant::fromValue(param));
|
||||
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onShaderParamSliderValueChanged(int)));
|
||||
|
||||
box->addWidget(slider);
|
||||
|
||||
if (stepIsFractional)
|
||||
{
|
||||
doubleSpinBox = new QDoubleSpinBox(m_shaderParamsDialog);
|
||||
doubleSpinBox->setRange(param->minimum, param->maximum);
|
||||
doubleSpinBox->setSingleStep(param->step);
|
||||
doubleSpinBox->setValue(param->current);
|
||||
doubleSpinBox->setProperty("slider", QVariant::fromValue(slider));
|
||||
slider->setProperty("doubleSpinBox", QVariant::fromValue(doubleSpinBox));
|
||||
|
||||
connect(doubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(onShaderParamDoubleSpinBoxValueChanged(double)));
|
||||
|
||||
box->addWidget(doubleSpinBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
spinBox = new QSpinBox(m_shaderParamsDialog);
|
||||
spinBox->setRange(param->minimum, param->maximum);
|
||||
spinBox->setSingleStep(param->step);
|
||||
spinBox->setValue(param->current);
|
||||
spinBox->setProperty("slider", QVariant::fromValue(slider));
|
||||
slider->setProperty("spinBox", QVariant::fromValue(spinBox));
|
||||
|
||||
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(onShaderParamSpinBoxValueChanged(int)));
|
||||
|
||||
box->addWidget(spinBox);
|
||||
}
|
||||
|
||||
form->addRow(desc, box);
|
||||
}
|
||||
}
|
||||
|
||||
m_shaderParamsDialog->resize(720, 480);
|
||||
m_shaderParamsDialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::onShaderParamCheckBoxClicked()
|
||||
{
|
||||
QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender());
|
||||
QVariant paramVariant;
|
||||
struct video_shader_parameter *param = NULL;
|
||||
|
||||
if (!checkBox)
|
||||
return;
|
||||
|
||||
paramVariant = checkBox->property("param");
|
||||
|
||||
if (paramVariant.isValid())
|
||||
{
|
||||
param = paramVariant.value<struct video_shader_parameter*>();
|
||||
|
||||
if (param)
|
||||
param->current = (checkBox->isChecked() ? param->maximum : param->minimum);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShaderParamSliderValueChanged(int value)
|
||||
{
|
||||
QVariant spinBoxVariant;
|
||||
QVariant paramVariant;
|
||||
QSlider *slider = qobject_cast<QSlider*>(sender());
|
||||
struct video_shader_parameter *param = NULL;
|
||||
double newValue = 0.0;
|
||||
|
||||
if (!slider)
|
||||
return;
|
||||
|
||||
spinBoxVariant = slider->property("spinBox");
|
||||
|
||||
if (spinBoxVariant.isValid())
|
||||
{
|
||||
QSpinBox *spinBox = spinBoxVariant.value<QSpinBox*>();
|
||||
|
||||
if (!spinBox)
|
||||
return;
|
||||
|
||||
spinBox->blockSignals(true);
|
||||
spinBox->setValue(slider->value());
|
||||
spinBox->blockSignals(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
QVariant doubleSpinBoxVariant = slider->property("doubleSpinBox");
|
||||
QDoubleSpinBox *doubleSpinBox = doubleSpinBoxVariant.value<QDoubleSpinBox*>();
|
||||
|
||||
if (!doubleSpinBox)
|
||||
return;
|
||||
|
||||
doubleSpinBox->blockSignals(true);
|
||||
doubleSpinBox->setValue(slider->value());
|
||||
doubleSpinBox->blockSignals(false);
|
||||
}
|
||||
|
||||
paramVariant = slider->property("param");
|
||||
|
||||
if (paramVariant.isValid())
|
||||
{
|
||||
param = paramVariant.value<struct video_shader_parameter*>();
|
||||
|
||||
if (param)
|
||||
{
|
||||
newValue = lerp(0, 100, param->minimum, param->maximum, slider->value());
|
||||
param->current = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShaderParamSpinBoxValueChanged(int value)
|
||||
{
|
||||
QSpinBox *spinBox = qobject_cast<QSpinBox*>(sender());
|
||||
QVariant sliderVariant;
|
||||
QVariant paramVariant;
|
||||
QSlider *slider = NULL;
|
||||
struct video_shader_parameter *param = NULL;
|
||||
double newValue = 0.0;
|
||||
|
||||
if (!spinBox)
|
||||
return;
|
||||
|
||||
sliderVariant = spinBox->property("slider");
|
||||
|
||||
if (!sliderVariant.isValid())
|
||||
return;
|
||||
|
||||
slider = sliderVariant.value<QSlider*>();
|
||||
|
||||
if (!slider)
|
||||
return;
|
||||
|
||||
paramVariant = slider->property("param");
|
||||
|
||||
if (paramVariant.isValid())
|
||||
{
|
||||
param = paramVariant.value<struct video_shader_parameter*>();
|
||||
|
||||
if (param)
|
||||
{
|
||||
param->current = value;
|
||||
newValue = lerp(param->minimum, param->maximum, 0, 100, param->current);
|
||||
slider->blockSignals(true);
|
||||
slider->setValue(newValue);
|
||||
slider->blockSignals(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShaderParamDoubleSpinBoxValueChanged(double value)
|
||||
{
|
||||
QDoubleSpinBox *doubleSpinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
||||
QVariant sliderVariant;
|
||||
QVariant paramVariant;
|
||||
QSlider *slider = NULL;
|
||||
struct video_shader_parameter *param = NULL;
|
||||
double newValue = 0.0;
|
||||
|
||||
if (!doubleSpinBox)
|
||||
return;
|
||||
|
||||
sliderVariant = doubleSpinBox->property("slider");
|
||||
|
||||
if (!sliderVariant.isValid())
|
||||
return;
|
||||
|
||||
slider = sliderVariant.value<QSlider*>();
|
||||
|
||||
if (!slider)
|
||||
return;
|
||||
|
||||
paramVariant = slider->property("param");
|
||||
|
||||
if (paramVariant.isValid())
|
||||
{
|
||||
param = paramVariant.value<struct video_shader_parameter*>();
|
||||
|
||||
if (param)
|
||||
{
|
||||
param->current = value;
|
||||
newValue = lerp(param->minimum, param->maximum, 0, 100, param->current);
|
||||
slider->blockSignals(true);
|
||||
slider->setValue(newValue);
|
||||
slider->blockSignals(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onPlaylistFilesDropped(QStringList files)
|
||||
{
|
||||
addFilesToPlaylist(files);
|
||||
|
@ -321,6 +321,8 @@ static void* ui_companion_qt_init(void)
|
||||
|
||||
QObject::connect(viewClosedDocksMenu, SIGNAL(aboutToShow()), mainwindow, SLOT(onViewClosedDocksAboutToShow()));
|
||||
|
||||
viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_MENU_VIEW_SHADER_PARAMS), mainwindow, SLOT(onShaderParamsClicked()));
|
||||
|
||||
viewMenu->addSeparator();
|
||||
viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS), mainwindow, SLOT(onIconViewClicked()));
|
||||
viewMenu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST), mainwindow, SLOT(onListViewClicked()));
|
||||
|
@ -42,6 +42,7 @@ extern "C" {
|
||||
#include <retro_assert.h>
|
||||
#include <retro_common_api.h>
|
||||
#include "../ui_companion_driver.h"
|
||||
#include "../../gfx/video_driver.h"
|
||||
}
|
||||
|
||||
class QApplication;
|
||||
@ -433,6 +434,7 @@ private slots:
|
||||
void onGridItemDoubleClicked();
|
||||
void onGridItemClicked(ThumbnailWidget *thumbnailWidget = NULL);
|
||||
void onPlaylistFilesDropped(QStringList files);
|
||||
void onShaderParamsClicked();
|
||||
void onUpdateNetworkError(QNetworkReply::NetworkError code);
|
||||
void onUpdateNetworkSslErrors(const QList<QSslError> &errors);
|
||||
void onRetroArchUpdateDownloadFinished();
|
||||
@ -441,6 +443,10 @@ private slots:
|
||||
void onUpdateDownloadCanceled();
|
||||
void onShowErrorMessage(QString msg);
|
||||
void onContributorsClicked();
|
||||
void onShaderParamCheckBoxClicked();
|
||||
void onShaderParamSliderValueChanged(int value);
|
||||
void onShaderParamSpinBoxValueChanged(int value);
|
||||
void onShaderParamDoubleSpinBoxValueChanged(double value);
|
||||
int onExtractArchive(QString path);
|
||||
|
||||
private:
|
||||
@ -514,6 +520,7 @@ private:
|
||||
int m_allPlaylistsGridMaxCount;
|
||||
PlaylistEntryDialog *m_playlistEntryDialog;
|
||||
QElapsedTimer m_statusMessageElapsedTimer;
|
||||
QDialog *m_shaderParamsDialog;
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QProgressDialog *m_updateProgressDialog;
|
||||
QFile m_updateFile;
|
||||
@ -526,6 +533,7 @@ protected:
|
||||
|
||||
Q_DECLARE_METATYPE(ThumbnailWidget)
|
||||
Q_DECLARE_METATYPE(QPointer<ThumbnailWidget>)
|
||||
Q_DECLARE_METATYPE(struct video_shader_parameter*)
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user