这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions app/src/preferencesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ GeneralPage::GeneralPage(QWidget* parent) :
connect(ui->curveSmoothingLevel, &QSlider::valueChanged, this, &GeneralPage::curveSmoothingChange);
connect(ui->highResBox, &QCheckBox::stateChanged, this, &GeneralPage::highResCheckboxStateChanged);
connect(ui->dottedCursorBox, &QCheckBox::stateChanged, this, &GeneralPage::dottedCursorCheckboxStateChanged);
connect(ui->gridSizeInput, spinValueChanged, this, &GeneralPage::gridSizeChange);
connect(ui->gridSizeInputW, spinValueChanged, this, &GeneralPage::gridSizeChangeW);
connect(ui->gridSizeInputH, spinValueChanged, this, &GeneralPage::gridSizeChangeH);
connect(ui->gridCheckBox, &QCheckBox::stateChanged, this, &GeneralPage::gridCheckBoxStateChanged);
}

Expand Down Expand Up @@ -181,8 +182,10 @@ void GeneralPage::updateValues()
ui->antialiasingBox->setChecked(mManager->isOn(SETTING::ANTIALIAS));
SignalBlocker b6(ui->dottedCursorBox);
ui->dottedCursorBox->setChecked(mManager->isOn(SETTING::DOTTED_CURSOR));
SignalBlocker b7(ui->gridSizeInput);
ui->gridSizeInput->setValue(mManager->getInt(SETTING::GRID_SIZE));
SignalBlocker b7(ui->gridSizeInputW);
ui->gridSizeInputW->setValue(mManager->getInt(SETTING::GRID_SIZE_W));
SignalBlocker b11(ui->gridSizeInputH);
ui->gridSizeInputH->setValue(mManager->getInt(SETTING::GRID_SIZE_H));
SignalBlocker b8(ui->gridCheckBox);
ui->gridCheckBox->setChecked(mManager->isOn(SETTING::GRID));

Expand Down Expand Up @@ -259,9 +262,14 @@ void GeneralPage::dottedCursorCheckboxStateChanged(int b)
mManager->set( SETTING::DOTTED_CURSOR, b != Qt::Unchecked );
}

void GeneralPage::gridSizeChange(int value)
void GeneralPage::gridSizeChangeW(int value)
{
mManager->set(SETTING::GRID_SIZE, value);
mManager->set(SETTING::GRID_SIZE_W, value);
}

void GeneralPage::gridSizeChangeH(int value)
{
mManager->set(SETTING::GRID_SIZE_H, value);
}

void GeneralPage::gridCheckBoxStateChanged(int b)
Expand Down
3 changes: 2 additions & 1 deletion app/src/preferencesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class GeneralPage : public QWidget

public slots:
void updateValues();
void gridSizeChange(int value);
void gridSizeChangeW(int value);
void gridSizeChangeH(int value);

signals:
void windowOpacityChange(int value);
Expand Down
73 changes: 61 additions & 12 deletions app/ui/generalpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>377</height>
<width>337</width>
<height>465</height>
</rect>
</property>
<layout class="QVBoxLayout" name="outerLay">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="minimumSize">
<size>
Expand All @@ -38,9 +38,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>510</height>
<y>-202</y>
<width>303</width>
<height>647</height>
</rect>
</property>
<layout class="QVBoxLayout" name="lay">
Expand Down Expand Up @@ -239,8 +239,35 @@
<string comment="groupBox title in Preference">Grid</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QSpinBox" name="gridSizeInput">
<item row="2" column="0">
<widget class="QLabel" name="labGridH">
<property name="text">
<string>Grid Heigth</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labGridW">
<property name="text">
<string>Grid Width</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="gridSizeInputH">
<property name="minimum">
<number>5</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="gridSizeInputW">
<property name="minimumSize">
<size>
<width>80</width>
Expand All @@ -254,14 +281,17 @@
</size>
</property>
<property name="minimum">
<number>1</number>
<number>5</number>
</property>
<property name="maximum">
<number>512</number>
<number>9999</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="gridCheckBox">
<property name="text">
<string>Enable Grid</string>
Expand All @@ -277,6 +307,25 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>scrollArea</tabstop>
<tabstop>languageCombo</tabstop>
<tabstop>windowOpacityLevel</tabstop>
<tabstop>shadowsBox</tabstop>
<tabstop>toolCursorsBox</tabstop>
<tabstop>dottedCursorBox</tabstop>
<tabstop>checkerBackgroundButton</tabstop>
<tabstop>whiteBackgroundButton</tabstop>
<tabstop>greyBackgroundButton</tabstop>
<tabstop>dotsBackgroundButton</tabstop>
<tabstop>weaveBackgroundButton</tabstop>
<tabstop>antialiasingBox</tabstop>
<tabstop>curveSmoothingLevel</tabstop>
<tabstop>highResBox</tabstop>
<tabstop>gridCheckBox</tabstop>
<tabstop>gridSizeInputW</tabstop>
<tabstop>gridSizeInputH</tabstop>
</tabstops>
<resources/>
<connections/>
<slots>
Expand Down
17 changes: 10 additions & 7 deletions core_lib/src/canvaspainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,16 @@ int round100(double f, int gridSize)

void CanvasPainter::paintGrid(QPainter& painter)
{
int gridSize = mOptions.nGridSize;
int gridSizeW = mOptions.nGridSizeW;
int gridSizeH = mOptions.nGridSizeH;

QRectF rect = painter.viewport();
QRectF boundingRect = mViewTransform.inverted().mapRect(rect);

int left = round100(boundingRect.left(), gridSize) - gridSize;
int right = round100(boundingRect.right(), gridSize) + gridSize;
int top = round100(boundingRect.top(), gridSize) - gridSize;
int bottom = round100(boundingRect.bottom(), gridSize) + gridSize;
int left = round100(boundingRect.left(), gridSizeW) - gridSizeW;
int right = round100(boundingRect.right(), gridSizeW) + gridSizeW;
int top = round100(boundingRect.top(), gridSizeH) - gridSizeH;
int bottom = round100(boundingRect.bottom(), gridSizeH) + gridSizeH;

QPen pen(Qt::lightGray);
pen.setCosmetic(true);
Expand All @@ -407,12 +408,14 @@ void CanvasPainter::paintGrid(QPainter& painter)
painter.setBrush(Qt::NoBrush);
QPainter::RenderHints previous_renderhints = painter.renderHints();
painter.setRenderHint(QPainter::Antialiasing, false);
for (int x = left; x < right; x += gridSize)
// draw vertical gridlines
for (int x = left; x < right; x += gridSizeW)
{
painter.drawLine(x, top, x, bottom);
}

for (int y = top; y < bottom; y += gridSize)
// draw horizontal gridlines
for (int y = top; y < bottom; y += gridSizeH)
{
painter.drawLine(left, y, right, y);
}
Expand Down
3 changes: 2 additions & 1 deletion core_lib/src/canvaspainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ struct CanvasPainterOptions
bool bColorizeNextOnion = false;
bool bAntiAlias = false;
bool bGrid = false;
int nGridSize = 50; /* This is the grid size IN PIXELS. The grid will scale with the image, though */
int nGridSizeW = 50; /* This is the grid Width IN PIXELS. The grid will scale with the image, though */
int nGridSizeH = 50; /* This is the grid Heigth IN PIXELS. The grid will scale with the image, though */
bool bAxis = false;
bool bThinLines = false;
bool bOutlines = false;
Expand Down
6 changes: 4 additions & 2 deletions core_lib/src/interface/scribblearea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ void ScribbleArea::settingUpdated(SETTING setting)
case SETTING::ONION_MAX_OPACITY:
case SETTING::ANTIALIAS:
case SETTING::GRID:
case SETTING::GRID_SIZE:
case SETTING::GRID_SIZE_W:
case SETTING::GRID_SIZE_H:
case SETTING::PREV_ONION:
case SETTING::NEXT_ONION:
case SETTING::ONION_BLUE:
Expand Down Expand Up @@ -1148,7 +1149,8 @@ void ScribbleArea::drawCanvas(int frame, QRect rect)
o.fOnionSkinMinOpacity = mPrefs->getInt(SETTING::ONION_MIN_OPACITY);
o.bAntiAlias = mPrefs->isOn(SETTING::ANTIALIAS);
o.bGrid = mPrefs->isOn(SETTING::GRID);
o.nGridSize = mPrefs->getInt(SETTING::GRID_SIZE);
o.nGridSizeW = mPrefs->getInt(SETTING::GRID_SIZE_W);
o.nGridSizeH = mPrefs->getInt(SETTING::GRID_SIZE_H);
o.bAxis = false;
o.bThinLines = mPrefs->isOn(SETTING::INVISIBLE_LINES);
o.bOutlines = mPrefs->isOn(SETTING::OUTLINES);
Expand Down
10 changes: 7 additions & 3 deletions core_lib/src/managers/preferencemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ void PreferenceManager::loadPrefs()
set(SETTING::OUTLINES, settings.value(SETTING_OUTLINES, false).toBool());

// Grid
set(SETTING::GRID_SIZE, settings.value(SETTING_GRID_SIZE, 50).toInt());
set(SETTING::GRID_SIZE_W, settings.value(SETTING_GRID_SIZE_W, 100).toInt());
set(SETTING::GRID_SIZE_H, settings.value(SETTING_GRID_SIZE_H, 100).toInt());

// General
set(SETTING::ANTIALIAS, settings.value(SETTING_ANTIALIAS, true).toBool());
Expand Down Expand Up @@ -210,8 +211,11 @@ void PreferenceManager::set(SETTING option, int value)
case SETTING::ONION_NEXT_FRAMES_NUM:
settings.setValue(SETTING_ONION_NEXT_FRAMES_NUM, value);
break;
case SETTING::GRID_SIZE:
settings.setValue(SETTING_GRID_SIZE, value);
case SETTING::GRID_SIZE_W:
settings.setValue(SETTING_GRID_SIZE_W, value);
break;
case SETTING::GRID_SIZE_H:
settings.setValue(SETTING_GRID_SIZE_H, value);
break;
case SETTING::DRAW_ON_EMPTY_FRAME_ACTION:
settings.setValue( SETTING_DRAW_ON_EMPTY_FRAME_ACTION, value);
Expand Down
3 changes: 2 additions & 1 deletion core_lib/src/managers/preferencemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ enum class SETTING
ONION_NEXT_FRAMES_NUM,
ONION_WHILE_PLAYBACK,
ONION_TYPE,
GRID_SIZE,
GRID_SIZE_W,
GRID_SIZE_H,
QUICK_SIZING,
MULTILAYER_ONION,
LANGUAGE,
Expand Down
3 changes: 2 additions & 1 deletion core_lib/src/util/pencildef.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ enum StabilizationLevel
#define SETTING_ONION_BLUE "OnionBlue"
#define SETTING_ONION_RED "OnionRed"

#define SETTING_GRID_SIZE "GridSize"
#define SETTING_GRID_SIZE_W "GridSizeW"
#define SETTING_GRID_SIZE_H "GridSizeH"

#define SETTING_ONION_MAX_OPACITY "OnionMaxOpacity"
#define SETTING_ONION_MIN_OPACITY "OnionMinOpacity"
Expand Down