Show grid bounds/visibility in Preferences dialog

We've received several support requests to change the default grid
settings. This change should make this more user-friendly.
This commit is contained in:
David Capello 2016-12-05 11:58:26 -03:00
parent a29503aef9
commit c54f95a440
2 changed files with 76 additions and 18 deletions

View File

@ -156,21 +156,46 @@
<!-- Grid -->
<vbox id="section_grid">
<combobox id="grid_scope" />
<separator text="Grid" horizontal="true" />
<grid columns="3">
<label text="Grid Color:" />
<hbox>
<check id="grid_visible" text="Visible Grid" />
<separator horizontal="true" expansive="true" />
</hbox>
<grid columns="3">
<label text="X:" />
<hbox cell_hspan="2">
<entry id="grid_x" text="" maxsize="4" />
<label text="Y:" />
<entry id="grid_y" text="" maxsize="4" />
</hbox>
<label text="Width:" />
<hbox cell_hspan="2">
<entry id="grid_w" text="" maxsize="4" />
<label text="Height:" />
<entry id="grid_h" text="" maxsize="4" />
</hbox>
<label text="Color:" />
<box id="grid_color_placeholder" /><!-- custom widget -->
<hbox />
<label text="Grid Opacity:" />
<slider grid_hspan="1" id="grid_opacity" min="1" max="255" width="128" />
<label text="Opacity:" />
<slider id="grid_opacity" min="1" max="255" width="128" />
<check id="grid_auto_opacity" text="Auto" />
</grid>
<label text="Pixel Grid Color:" />
<hbox>
<check id="pixel_grid_visible" text="Visible Pixel Grid" />
<separator horizontal="true" expansive="true" />
</hbox>
<grid columns="3">
<label text="Color:" />
<box id="pixel_grid_color_placeholder" /><!-- custom widget -->
<hbox />
<label text="Pixel Grid Opacity:" />
<label text="Opacity:" />
<slider id="pixel_grid_opacity" min="1" max="255" width="128" />
<check id="pixel_grid_auto_opacity" text="Auto" />
</grid>

View File

@ -30,6 +30,8 @@
namespace app {
static const char* kSectionBgId = "section_bg";
static const char* kSectionGridId = "section_grid";
static const char* kSectionThemeId = "section_theme";
using namespace ui;
@ -163,14 +165,14 @@ public:
autoScroll()->setSelected(true);
// Scope
bgScope()->addItem("New Documents");
gridScope()->addItem("New Documents");
bgScope()->addItem("Background for New Documents");
gridScope()->addItem("Grid for New Documents");
if (context->activeDocument()) {
bgScope()->addItem("Active Document");
bgScope()->addItem("Background for the Active Document");
bgScope()->setSelectedItemIndex(1);
bgScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeBgScope, this));
gridScope()->addItem("Active Document");
gridScope()->addItem("Grid for the Active Document");
gridScope()->setSelectedItemIndex(1);
gridScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeGridScope, this));
}
@ -301,12 +303,17 @@ public:
m_pref.selection.autoOpaque(autoOpaque()->isSelected());
m_pref.selection.keepSelectionAfterClear(keepSelectionAfterClear()->isSelected());
m_curPref->show.grid(gridVisible()->isSelected());
m_curPref->grid.bounds(gridBounds());
m_curPref->grid.color(m_gridColor->getColor());
m_curPref->grid.opacity(gridOpacity()->getValue());
m_curPref->grid.autoOpacity(gridAutoOpacity()->isSelected());
m_curPref->show.pixelGrid(pixelGridVisible()->isSelected());
m_curPref->pixelGrid.color(m_pixelGridColor->getColor());
m_curPref->pixelGrid.opacity(pixelGridOpacity()->getValue());
m_curPref->pixelGrid.autoOpacity(pixelGridAutoOpacity()->isSelected());
m_curPref->bg.type(app::gen::BgType(checkedBgSize()->getSelectedItemIndex()));
m_curPref->bg.zoom(checkedBgZoom()->isSelected());
m_curPref->bg.color1(m_checked_bg_color1->getColor());
@ -382,8 +389,12 @@ private:
panel()->showChild(findChild(item->getValue().c_str()));
m_curSection = sectionListbox()->getSelectedIndex();
if (item->getValue() == kSectionBgId)
onChangeBgScope();
else if (item->getValue() == kSectionGridId)
onChangeGridScope();
// Load themes
if (item->getValue() == kSectionThemeId)
else if (item->getValue() == kSectionThemeId)
loadThemes();
}
@ -409,20 +420,27 @@ private:
case 1: m_curPref = &m_docPref; break;
}
gridVisible()->setSelected(m_curPref->show.grid());
gridX()->setTextf("%d", m_curPref->grid.bounds().x);
gridY()->setTextf("%d", m_curPref->grid.bounds().y);
gridW()->setTextf("%d", m_curPref->grid.bounds().w);
gridH()->setTextf("%d", m_curPref->grid.bounds().h);
m_gridColor->setColor(m_curPref->grid.color());
gridOpacity()->setValue(m_curPref->grid.opacity());
gridAutoOpacity()->setSelected(m_curPref->grid.autoOpacity());
pixelGridVisible()->setSelected(m_curPref->show.pixelGrid());
m_pixelGridColor->setColor(m_curPref->pixelGrid.color());
pixelGridOpacity()->setValue(m_curPref->pixelGrid.opacity());
pixelGridAutoOpacity()->setSelected(m_curPref->pixelGrid.autoOpacity());
}
void onResetBg() {
DocumentPreferences& pref = m_globPref;
// Reset global preferences (use default values specified in pref.xml)
if (m_curPref == &m_globPref) {
DocumentPreferences& pref = m_globPref;
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type.defaultValue()));
checkedBgZoom()->setSelected(pref.bg.zoom.defaultValue());
m_checked_bg_color1->setColor(pref.bg.color1.defaultValue());
@ -430,8 +448,6 @@ private:
}
// Reset document preferences with global settings
else {
DocumentPreferences& pref = m_globPref;
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type()));
checkedBgZoom()->setSelected(pref.bg.zoom());
m_checked_bg_color1->setColor(pref.bg.color1());
@ -440,26 +456,38 @@ private:
}
void onResetGrid() {
DocumentPreferences& pref = m_globPref;
// Reset global preferences (use default values specified in pref.xml)
if (m_curPref == &m_globPref) {
DocumentPreferences& pref = m_globPref;
gridVisible()->setSelected(pref.show.grid.defaultValue());
gridX()->setTextf("%d", pref.grid.bounds.defaultValue().x);
gridY()->setTextf("%d", pref.grid.bounds.defaultValue().y);
gridW()->setTextf("%d", pref.grid.bounds.defaultValue().w);
gridH()->setTextf("%d", pref.grid.bounds.defaultValue().h);
m_gridColor->setColor(pref.grid.color.defaultValue());
gridOpacity()->setValue(pref.grid.opacity.defaultValue());
gridAutoOpacity()->setSelected(pref.grid.autoOpacity.defaultValue());
pixelGridVisible()->setSelected(pref.show.pixelGrid.defaultValue());
m_pixelGridColor->setColor(pref.pixelGrid.color.defaultValue());
pixelGridOpacity()->setValue(pref.pixelGrid.opacity.defaultValue());
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity.defaultValue());
}
// Reset document preferences with global settings
else {
DocumentPreferences& pref = m_globPref;
gridVisible()->setSelected(pref.show.grid());
gridX()->setTextf("%d", pref.grid.bounds().x);
gridY()->setTextf("%d", pref.grid.bounds().y);
gridW()->setTextf("%d", pref.grid.bounds().w);
gridH()->setTextf("%d", pref.grid.bounds().h);
m_gridColor->setColor(pref.grid.color());
gridOpacity()->setValue(pref.grid.opacity());
gridAutoOpacity()->setSelected(pref.grid.autoOpacity());
pixelGridVisible()->setSelected(pref.show.pixelGrid());
m_pixelGridColor->setColor(pref.pixelGrid.color());
pixelGridOpacity()->setValue(pref.pixelGrid.opacity());
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity());
@ -545,6 +573,11 @@ private:
layout();
}
gfx::Rect gridBounds() const {
return gfx::Rect(gridX()->textInt(), gridY()->textInt(),
gridW()->textInt(), gridH()->textInt());
}
static std::string userThemeFolder() {
ResourceFinder rf;
rf.includeDataDir("skins");