Smooth out scrolling for graphics views nested in scroll areas

This commit is contained in:
GriffinR 2024-01-28 14:15:45 -05:00
parent d7f25f9ae5
commit 13f14757be
4 changed files with 31 additions and 9 deletions

View file

@ -14,6 +14,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
### Fixed ### Fixed
- Fix some minor visual issues with the various zoom sliders. - Fix some minor visual issues with the various zoom sliders.
- Smooth out scrolling when mouse is over tile/metatile images.
- Fix the Tileset Editor selectors getting extra white space when changing tilesets. - Fix the Tileset Editor selectors getting extra white space when changing tilesets.
- Fix a crash when adding disabled events with the Pencil tool. - Fix a crash when adding disabled events with the Pencil tool.

View file

@ -803,7 +803,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QGraphicsView" name="graphicsView_BorderMetatile"> <widget class="NoScrollGraphicsView" name="graphicsView_BorderMetatile">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -922,7 +922,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QGraphicsView" name="graphicsView_currentMetatileSelection"> <widget class="NoScrollGraphicsView" name="graphicsView_currentMetatileSelection">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -1032,7 +1032,7 @@
</spacer> </spacer>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QGraphicsView" name="graphicsView_Metatiles"> <widget class="NoScrollGraphicsView" name="graphicsView_Metatiles">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -1227,7 +1227,7 @@
</spacer> </spacer>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QGraphicsView" name="graphicsView_Collision"> <widget class="NoScrollGraphicsView" name="graphicsView_Collision">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -3435,6 +3435,11 @@
<extends>QWidget</extends> <extends>QWidget</extends>
<header>mapview.h</header> <header>mapview.h</header>
</customwidget> </customwidget>
<customwidget>
<class>NoScrollGraphicsView</class>
<extends>QGraphicsView</extends>
<header>mapview.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../resources/images.qrc"/> <include location="../resources/images.qrc"/>

View file

@ -86,7 +86,7 @@
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGraphicsView" name="graphicsView_Metatiles"> <widget class="NoScrollGraphicsView" name="graphicsView_Metatiles">
<property name="verticalScrollBarPolicy"> <property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum> <enum>Qt::ScrollBarAlwaysOff</enum>
</property> </property>
@ -560,7 +560,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGraphicsView" name="graphicsView_Tiles"> <widget class="NoScrollGraphicsView" name="graphicsView_Tiles">
<property name="verticalScrollBarPolicy"> <property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum> <enum>Qt::ScrollBarAlwaysOff</enum>
</property> </property>
@ -806,6 +806,11 @@
<extends>QComboBox</extends> <extends>QComboBox</extends>
<header>noscrollcombobox.h</header> <header>noscrollcombobox.h</header>
</customwidget> </customwidget>
<customwidget>
<class>NoScrollGraphicsView</class>
<extends>QGraphicsView</extends>
<header>mapview.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../resources/images.qrc"/> <include location="../resources/images.qrc"/>

View file

@ -4,12 +4,23 @@
#include <QGraphicsView> #include <QGraphicsView>
#include <QMouseEvent> #include <QMouseEvent>
class ClickableGraphicsView : public QGraphicsView class NoScrollGraphicsView : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
ClickableGraphicsView() : QGraphicsView() {} NoScrollGraphicsView(QWidget *parent = nullptr) : QGraphicsView(parent) {}
ClickableGraphicsView(QWidget *parent) : QGraphicsView(parent) {}
protected:
void wheelEvent(QWheelEvent *event) {
event->ignore();
}
};
class ClickableGraphicsView : public NoScrollGraphicsView
{
Q_OBJECT
public:
ClickableGraphicsView(QWidget *parent = nullptr) : NoScrollGraphicsView(parent) {}
public: public:
void mouseReleaseEvent(QMouseEvent *event) override { void mouseReleaseEvent(QMouseEvent *event) override {