Merge branch 'master' into beta

This commit is contained in:
David Capello 2016-12-05 12:36:12 -03:00
commit 54ef2eeb66
6 changed files with 173 additions and 57 deletions

View File

@ -116,6 +116,7 @@
<option id="zoom_from_center_with_wheel" type="bool" default="false" />
<option id="zoom_from_center_with_keys" type="bool" default="false" />
<option id="show_scrollbars" type="bool" default="true" migrate="Options.ShowScrollbars" />
<option id="auto_scroll" type="bool" default="true" />
<option id="right_click_mode" type="RightClickMode" default="RightClickMode::PAINT_BGCOLOR" migrate="Options.RightClickMode" />
<option id="auto_select_layer" type="bool" default="false" migrate="Options.AutoSelectLayer" />
<option id="play_once" type="bool" default="false" />

View File

@ -10,7 +10,8 @@
<listitem text="Editor" value="section_editor" />
<listitem text="Timeline" value="section_timeline" />
<listitem text="Cursors" value="section_cursors" />
<listitem text="Grid &amp;&amp; Background" value="section_grid" />
<listitem text="Background" value="section_bg" />
<listitem text="Grid" value="section_grid" />
<listitem text="Undo" value="section_undo" />
<listitem text="Theme" value="section_theme" />
<listitem text="Experimental" value="section_experimental" />
@ -67,6 +68,7 @@
<check text="Zoom from center with scroll wheel" id="zoom_from_center_with_wheel" />
<check text="Zoom from center with keys" id="zoom_from_center_with_keys" />
<check text="Show scroll-bars in sprite editor" id="show_scrollbars" tooltip="Show scroll-bars in all sprite editors." />
<check text="Auto-scroll on editor edges" id="auto_scroll" />
<hbox>
<label text="Right-click:" />
<combobox id="right_click_behavior" expansive="true" />
@ -129,43 +131,81 @@
</grid>
</vbox>
<!-- Grid & background -->
<!-- Background -->
<vbox id="section_bg">
<combobox id="bg_scope" />
<separator text="Checked Background" horizontal="true" />
<grid columns="2">
<label text="Size:" />
<hbox>
<combobox id="checked_bg_size" />
<check text="Apply Zoom" id="checked_bg_zoom" />
</hbox>
<label text="Colors:" />
<hbox>
<box horizontal="true" id="checked_bg_color1_box" />
<box horizontal="true" id="checked_bg_color2_box" />
</hbox>
</grid>
<hbox>
<hbox expansive="true" />
<button id="reset_bg" text="Reset" width="60" />
</hbox>
</vbox>
<!-- 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>
<separator text="Checked Background" horizontal="true" />
<hbox>
<label text="Size:" />
<combobox id="checked_bg_size" expansive="true" />
</hbox>
<check text="Apply Zoom" id="checked_bg_zoom" />
<hbox>
<label text="Colors:" />
<box horizontal="true" id="checked_bg_color1_box" />
<box horizontal="true" id="checked_bg_color2_box" />
</hbox>
<hbox>
<hbox expansive="true" />
<button id="reset" text="Reset" width="60" />
<button id="reset_grid" text="Reset" width="60" />
</hbox>
</vbox>

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;
@ -161,10 +163,18 @@ public:
if (m_pref.editor.showScrollbars())
showScrollbars()->setSelected(true);
if (m_pref.editor.autoScroll())
autoScroll()->setSelected(true);
// Scope
gridScope()->addItem("New Documents");
bgScope()->addItem("Background for New Documents");
gridScope()->addItem("Grid for New Documents");
if (context->activeDocument()) {
gridScope()->addItem("Active Document");
bgScope()->addItem("Background for the Active Document");
bgScope()->setSelectedItemIndex(1);
bgScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeBgScope, this));
gridScope()->addItem("Grid for the Active Document");
gridScope()->setSelectedItemIndex(1);
gridScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeGridScope, this));
}
@ -223,8 +233,9 @@ public:
checkedBgColor1Box()->addChild(m_checked_bg_color1);
checkedBgColor2Box()->addChild(m_checked_bg_color2);
// Reset button
reset()->Click.connect(base::Bind<void>(&OptionsWindow::onReset, this));
// Reset buttons
resetBg()->Click.connect(base::Bind<void>(&OptionsWindow::onResetBg, this));
resetGrid()->Click.connect(base::Bind<void>(&OptionsWindow::onResetGrid, this));
// Links
locateFile()->Click.connect(base::Bind<void>(&OptionsWindow::onLocateConfigFile, this));
@ -247,6 +258,7 @@ public:
// Apply button
buttonApply()->Click.connect(base::Bind<void>(&OptionsWindow::saveConfig, this));
onChangeBgScope();
onChangeGridScope();
sectionListbox()->selectIndex(m_curSection);
}
@ -279,6 +291,7 @@ public:
m_pref.editor.zoomFromCenterWithWheel(zoomFromCenterWithWheel()->isSelected());
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
m_pref.editor.autoScroll(autoScroll()->isSelected());
m_pref.editor.zoomWithWheel(wheelZoom()->isSelected());
#if __APPLE__
m_pref.editor.zoomWithSlide(slideZoom()->isSelected());
@ -292,12 +305,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());
@ -374,11 +392,29 @@ 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();
}
void onChangeBgScope() {
int item = bgScope()->getSelectedItemIndex();
switch (item) {
case 0: m_curPref = &m_globPref; break;
case 1: m_curPref = &m_docPref; break;
}
checkedBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
checkedBgZoom()->setSelected(m_curPref->bg.zoom());
m_checked_bg_color1->setColor(m_curPref->bg.color1());
m_checked_bg_color2->setColor(m_curPref->bg.color2());
}
void onChangeGridScope() {
int item = gridScope()->getSelectedItemIndex();
@ -387,33 +423,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());
checkedBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
checkedBgZoom()->setSelected(m_curPref->bg.zoom());
m_checked_bg_color1->setColor(m_curPref->bg.color1());
m_checked_bg_color2->setColor(m_curPref->bg.color2());
}
void onReset() {
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;
m_gridColor->setColor(pref.grid.color.defaultValue());
gridOpacity()->setValue(pref.grid.opacity.defaultValue());
gridAutoOpacity()->setSelected(pref.grid.autoOpacity.defaultValue());
m_pixelGridColor->setColor(pref.pixelGrid.color.defaultValue());
pixelGridOpacity()->setValue(pref.pixelGrid.opacity.defaultValue());
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity.defaultValue());
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type.defaultValue()));
checkedBgZoom()->setSelected(pref.bg.zoom.defaultValue());
m_checked_bg_color1->setColor(pref.bg.color1.defaultValue());
@ -421,20 +451,49 @@ 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());
m_checked_bg_color2->setColor(pref.bg.color2());
}
}
void onResetGrid() {
DocumentPreferences& pref = m_globPref;
// Reset global preferences (use default values specified in pref.xml)
if (m_curPref == &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 {
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());
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type()));
checkedBgZoom()->setSelected(pref.bg.zoom());
m_checked_bg_color1->setColor(pref.bg.color1());
m_checked_bg_color2->setColor(pref.bg.color2());
}
}
@ -517,6 +576,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");

View File

@ -91,8 +91,10 @@ ColorPopup::ColorPopup(bool canPin)
break;
}
}
m_topBox.addChild(new BoxFiller);
m_topBox.addChild(closeButton);
if (closeButton) {
m_topBox.addChild(new BoxFiller);
m_topBox.addChild(closeButton);
}
}
m_vbox.addChild(&m_topBox);
@ -268,8 +270,13 @@ void ColorPopup::selectColorType(app::Color::Type type)
case app::Color::MaskType: m_colorType.setSelectedItem(MASK_MODE); break;
}
// Remove focus from some RGB/HSB text entry
manager()->freeFocus();
// Remove focus from hidden RGB/HSB text entries
auto widget = manager()->getFocus();
if (widget && !widget->isVisible()) {
auto window = widget->window();
if (window && window == this)
widget->releaseFocus();
}
m_vbox.layout();
m_vbox.invalidate();

View File

@ -984,11 +984,14 @@ void Editor::flashCurrentLayer()
gfx::Point Editor::autoScroll(MouseMessage* msg, AutoScroll dir)
{
// // Hide the brush preview
// HideBrushPreview hide(editor->brushPreview());
gfx::Point mousePos = msg->position();
if (!Preferences::instance().editor.autoScroll())
return mousePos;
// Hide the brush preview
//HideBrushPreview hide(editor->brushPreview());
View* view = View::getView(this);
gfx::Rect vp = view->viewportBounds();
gfx::Point mousePos = msg->position();
if (!vp.contains(mousePos)) {
gfx::Point delta = (mousePos - m_oldPos);

View File

@ -682,7 +682,8 @@ void StatusBar::showTool(int msecs, tools::Tool* tool)
void StatusBar::showSnapToGridWarning(bool state)
{
if (state) {
ASSERT(m_doc);
// m_doc can be null if "snap to grid" command is pressed without
// an opened document. (E.g. to change the default setting)
if (!m_doc)
return;