Skip to content

Commit

Permalink
Selection Color can be changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jowin202 committed Jun 8, 2024
1 parent bfa8714 commit bffe59a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 44 deletions.
7 changes: 7 additions & 0 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ MainWindow::MainWindow(QWidget *parent)
this->opt.background = col;
this->ui->graphicsView->redraw();
});
connect(this->ui->button_selection_color, &QPushButton::clicked, [=]() {
QColor col = QColorDialog::getColor(opt.selection_color, 0, "Selection Color");
if (col.isValid())
this->opt.selection_color = col;
this->ui->graphicsView->redraw();
});
}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -826,3 +832,4 @@ void MainWindow::on_actionRotate_triggered()
dialog->show();
connect(dialog, &RotationDialog::finished, [=]() { this->ui->graphicsView->redraw(); });
}

104 changes: 62 additions & 42 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -524,61 +524,59 @@
</item>
<item row="13" column="0">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<widget class="QSpinBox" name="spin_horizontal_spacing">
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>30</number>
<property name="text">
<string>Horizontal Spacing:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_14">
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show Sprites per Line</string>
<string>Vertical Spacing:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spin_vertical_spacing">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
<item row="4" column="1">
<widget class="QSpinBox" name="spin_sprites_per_line">
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>30</number>
<number>4</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<item row="2" column="1">
<widget class="QPushButton" name="button_spacing_color">
<property name="text">
<string>Choose Color</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_14">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Horizontal Spacing:</string>
<string>Show Sprites per Line</string>
</property>
</widget>
</item>
Expand All @@ -595,13 +593,35 @@
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="spin_sprites_per_line">
<property name="minimum">
<number>1</number>
<item row="1" column="1">
<widget class="QSpinBox" name="spin_vertical_spacing">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>4</number>
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spin_horizontal_spacing">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
Expand All @@ -618,23 +638,23 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="button_spacing_color">
<property name="text">
<string>Choose Color</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_12">
<item row="3" column="0">
<widget class="QLabel" name="label_21">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Vertical Spacing:</string>
<string>Selection Color:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="button_selection_color">
<property name="text">
<string>Choose Color</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -675,7 +695,7 @@
<x>0</x>
<y>0</y>
<width>609</width>
<height>786</height>
<height>814</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
Expand Down Expand Up @@ -706,7 +726,7 @@
<x>0</x>
<y>0</y>
<width>1026</width>
<height>30</height>
<height>18</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down
4 changes: 2 additions & 2 deletions sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ void Sprite::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
if (id >= opt->selection_from && id <= opt->selection_to)
{
QPen pen;
pen.setWidth(2);
pen.setColor(Qt::green);
pen.setWidth(5);
pen.setColor(opt->selection_color);
painter->setPen(pen);
painter->setOpacity(1);
painter->drawRect(this->boundingRect());
Expand Down
1 change: 1 addition & 0 deletions sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct options {
QList<QJsonObject> undoDB;

QColor background = QColor(0xd9,0xd6,0xc8);
QColor selection_color = QColor(0x00,0xff,0x00);
QStringList col_names = {"Black","White","Red","Cyan","Purple","Green","Blue","Yellow","Orange","Brown",
"Pink", "Dark Grey", "Grey","Light Green","Light Blue","Light Grey"};
QList<QColor> col_list = { QColor(0,0,0),
Expand Down

0 comments on commit bffe59a

Please sign in to comment.