BackGround_Colour_Selector

This commit is contained in:
1 2017-10-05 12:04:13 +01:00 committed by citra
parent 9dd09cb60d
commit 219bf6d2c2
4 changed files with 40 additions and 2 deletions

View File

@ -7,6 +7,8 @@
#include "core/settings.h"
#include "ui_configure_graphics.h"
#include <QColorDialog>
ConfigureGraphics::ConfigureGraphics(QWidget* parent)
: QWidget(parent), ui(new Ui::ConfigureGraphics) {
@ -16,10 +18,20 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)
ui->toggle_vsync->setEnabled(!Core::System::GetInstance().IsPoweredOn());
ui->layoutBox->setEnabled(!Settings::values.custom_layout);
connect(ui->layout_bg, SIGNAL (released()), this, SLOT (showLayoutBackgroundDialog()));
}
ConfigureGraphics::~ConfigureGraphics() {}
void ConfigureGraphics::showLayoutBackgroundDialog() {
QColor new_color = QColorDialog::getColor(bg_color, this);
if (new_color.isValid()) {
bg_color = new_color;
ui->layout_bg->setStyleSheet("QPushButton { background-color: " + bg_color.name() + ";}");
}
}
enum class Resolution : int {
Auto,
Scale1x,
@ -96,6 +108,10 @@ void ConfigureGraphics::setConfiguration() {
ui->resolution_factor_combobox->setCurrentIndex(
static_cast<int>(FromResolutionFactor(Settings::values.resolution_factor)));
ui->toggle_vsync->setChecked(Settings::values.use_vsync);
{
bg_color.setRgbF(Settings::values.bg_red, Settings::values.bg_green, Settings::values.bg_blue);
ui->layout_bg->setStyleSheet("QPushButton { background-color: " + bg_color.name() + ";}");
}
ui->toggle_framelimit->setChecked(Settings::values.toggle_framelimit);
ui->layout_combobox->setCurrentIndex(static_cast<int>(Settings::values.layout_option));
ui->swap_screen->setChecked(Settings::values.swap_screen);
@ -107,6 +123,9 @@ void ConfigureGraphics::applyConfiguration() {
Settings::values.resolution_factor =
ToResolutionFactor(static_cast<Resolution>(ui->resolution_factor_combobox->currentIndex()));
Settings::values.use_vsync = ui->toggle_vsync->isChecked();
Settings::values.bg_red = bg_color.redF();
Settings::values.bg_green = bg_color.greenF();
Settings::values.bg_blue = bg_color.blueF();
Settings::values.toggle_framelimit = ui->toggle_framelimit->isChecked();
Settings::values.layout_option =
static_cast<Settings::LayoutOption>(ui->layout_combobox->currentIndex());

View File

@ -23,6 +23,10 @@ public:
private:
void setConfiguration();
private slots:
void showLayoutBackgroundDialog();
private:
QColor bg_color;
std::unique_ptr<Ui::ConfigureGraphics> ui;
};

View File

@ -133,6 +133,21 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label2">
<property name="text">
<string>Background color:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="layout_bg">
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>

View File

@ -234,8 +234,6 @@ void RendererOpenGL::LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color
* Initializes the OpenGL state and creates persistent objects.
*/
void RendererOpenGL::InitOpenGLObjects() {
glClearColor(Settings::values.bg_red, Settings::values.bg_green, Settings::values.bg_blue,
0.0f);
// Link shaders and get variable locations
shader.Create(vertex_shader, fragment_shader);
@ -383,6 +381,8 @@ void RendererOpenGL::DrawScreens() {
const auto& bottom_screen = layout.bottom_screen;
glViewport(0, 0, layout.width, layout.height);
glClearColor(Settings::values.bg_red, Settings::values.bg_green, Settings::values.bg_blue,
0.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Set projection matrix