Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #6359 from rukai/dolphinQtTAS
Qt TAS input windows
- Loading branch information
Showing
19 changed files
with
1,226 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright 2018 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| // Based on: | ||
| // https://stackoverflow.com/questions/30005540/keeping-the-aspect-ratio-of-a-sub-classed-qwidget-during-resize | ||
|
|
||
| #include "DolphinQt2/QtUtils/AspectRatioWidget.h" | ||
|
|
||
| #include <QBoxLayout> | ||
| #include <QResizeEvent> | ||
|
|
||
| AspectRatioWidget::AspectRatioWidget(QWidget* widget, float width, float height, QWidget* parent) | ||
| : QWidget(parent), m_ar_width(width), m_ar_height(height) | ||
| { | ||
| m_layout = new QBoxLayout(QBoxLayout::LeftToRight, this); | ||
|
|
||
| // add spacer, then your widget, then spacer | ||
| m_layout->addItem(new QSpacerItem(0, 0)); | ||
| m_layout->addWidget(widget); | ||
| m_layout->addItem(new QSpacerItem(0, 0)); | ||
| } | ||
|
|
||
| void AspectRatioWidget::resizeEvent(QResizeEvent* event) | ||
| { | ||
| float aspect_ratio = static_cast<float>(event->size().width()) / event->size().height(); | ||
| int widget_stretch, outer_stretch; | ||
|
|
||
| if (aspect_ratio > (m_ar_width / m_ar_height)) // too wide | ||
| { | ||
| m_layout->setDirection(QBoxLayout::LeftToRight); | ||
| widget_stretch = height() * (m_ar_width / m_ar_height); // i.e., my width | ||
| outer_stretch = (width() - widget_stretch) / 2 + 0.5; | ||
| } | ||
| else // too tall | ||
| { | ||
| m_layout->setDirection(QBoxLayout::TopToBottom); | ||
| widget_stretch = width() * (m_ar_height / m_ar_width); // i.e., my height | ||
| outer_stretch = (height() - widget_stretch) / 2 + 0.5; | ||
| } | ||
|
|
||
| m_layout->setStretch(0, outer_stretch); | ||
| m_layout->setStretch(1, widget_stretch); | ||
| m_layout->setStretch(2, outer_stretch); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright 2018 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <QWidget> | ||
|
|
||
| class QBoxLayout; | ||
|
|
||
| class AspectRatioWidget : public QWidget | ||
| { | ||
| public: | ||
| AspectRatioWidget(QWidget* widget, float width, float height, QWidget* parent = nullptr); | ||
| void resizeEvent(QResizeEvent* event); | ||
|
|
||
| private: | ||
| QBoxLayout* m_layout; | ||
| float m_ar_width; | ||
| float m_ar_height; | ||
| }; |
Oops, something went wrong.