Skip to content

Commit

Permalink
redesign layout dimension change window
Browse files Browse the repository at this point in the history
  • Loading branch information
garakmon committed Nov 12, 2024
1 parent c969552 commit c83474b
Show file tree
Hide file tree
Showing 13 changed files with 854 additions and 107 deletions.
276 changes: 276 additions & 0 deletions forms/resizelayoutpopup.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ResizeLayoutPopup</class>
<widget class="QDialog" name="ResizeLayoutPopup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>598</width>
<height>378</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Resize Layout</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>8</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QGraphicsView" name="graphicsView"/>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<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>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Width</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="NoScrollSpinBox" name="spinBox_width">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Height</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="NoScrollSpinBox" name="spinBox_height">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<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>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="frame_border">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<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>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Border Width</string>
</property>
</widget>
</item>
<item>
<widget class="NoScrollSpinBox" name="spinBox_borderWidth">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Border Height</string>
</property>
</widget>
</item>
<item>
<widget class="NoScrollSpinBox" name="spinBox_borderHeight">
<property name="minimumSize">
<size>
<width>64</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<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>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>NoScrollSpinBox</class>
<extends>QSpinBox</extends>
<header>noscrollspinbox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ResizeLayoutPopup</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ResizeLayoutPopup</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
11 changes: 8 additions & 3 deletions include/core/editcommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QUndoCommand>
#include <QList>
#include <QPointer>
#include <QMargins>

class Map;
class Layout;
Expand Down Expand Up @@ -203,7 +204,12 @@ class ShiftMetatiles : public QUndoCommand {
/// Implements a command to commit a map or border resize action.
class ResizeLayout : public QUndoCommand {
public:
ResizeLayout(Layout *layout, QSize oldLayoutDimensions, QSize newLayoutDimensions,
// ResizeLayout(Layout *layout, QSize oldLayoutDimensions, QSize newLayoutDimensions,
// const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
// QSize oldBorderDimensions, QSize newBorderDimensions,
// const Blockdata &oldBorder, const Blockdata &newBorder,
// QUndoCommand *parent = nullptr);
ResizeLayout(Layout *layout, QSize oldLayoutDimensions, QMargins newLayoutMargins,
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
QSize oldBorderDimensions, QSize newBorderDimensions,
const Blockdata &oldBorder, const Blockdata &newBorder,
Expand All @@ -220,8 +226,7 @@ class ResizeLayout : public QUndoCommand {

int oldLayoutWidth;
int oldLayoutHeight;
int newLayoutWidth;
int newLayoutHeight;
QMargins newLayoutMargins;

int oldBorderWidth;
int oldBorderHeight;
Expand Down
1 change: 1 addition & 0 deletions include/core/maplayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class Layout : public QObject {
void setBlock(int x, int y, Block block, bool enableScriptCallback = false);
void setBlockdata(Blockdata blockdata, bool enableScriptCallback = false);

void adjustDimensions(QMargins margins, bool setNewBlockdata = true, bool enableScriptCallback = false);
void setDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);
void setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);

Expand Down
Loading

0 comments on commit c83474b

Please sign in to comment.