Add guides/slices options in preference dialog

Also moved guide/slice colors to global preferences (instead of pref per document).
This commit is contained in:
David Capello 2017-03-25 01:01:59 -03:00
parent fb64d5406a
commit add0c81260
10 changed files with 82 additions and 11 deletions

View File

@ -770,6 +770,7 @@
<item command="ShowLayerEdges" text="&amp;Layer Edges" />
<item command="ShowSelectionEdges" text="&amp;Selection Edges" />
<item command="ShowGrid" text="&amp;Grid" />
<item command="ShowAutoGuides" text="&amp;Auto Guides" />
<item command="ShowSlices" text="Sl&amp;ices" />
<item command="ShowPixelGrid" text="&amp;Pixel Grid" />
<separator />

View File

@ -230,6 +230,13 @@
<section id="perf">
<option id="show_render_time" type="bool" default="false" />
</section>
<section id="guides">
<option id="layer_edges_color" type="app::Color" default="app::Color::fromRgb(0, 0, 255)" />
<option id="auto_guides_color" type="app::Color" default="app::Color::fromRgb(0, 0, 255, 128)" />
</section>
<section id="slices">
<option id="default_color" type="app::Color" default="app::Color::fromRgb(0, 0, 255)" />
</section>
</global>
<tool>
@ -280,11 +287,6 @@
<option id="opacity" type="int" default="160" migrate="PixelGrid.Opacity" />
<option id="auto_opacity" type="bool" default="true" migrate="PixelGrid.AutoOpacity" />
</section>
<section id="guides">
<option id="layer_edges_color" type="app::Color" default="app::Color::fromRgb(0, 0, 255)" />
<option id="default_slice_color" type="app::Color" default="app::Color::fromRgb(0, 0, 255)" />
<option id="automatic_guides_color" type="app::Color" default="app::Color::fromRgb(0, 0, 255, 128)" />
</section>
<section id="bg">
<option id="type" type="BgType" default="BgType::CHECKED_16x16" migrate="Option.CheckedBgType" />
<option id="zoom" type="bool" default="true" migrate="Option.CheckedBgZoom" />
@ -356,6 +358,7 @@
<option id="pixel_grid" type="bool" default="false" migrate="pixel_grid.visible" />
<option id="brush_preview" type="bool" default="true" />
<option id="slices" type="bool" default="true" />
<option id="auto_guides" type="bool" default="true" />
</section>
</document>

View File

@ -260,6 +260,7 @@ section_timeline = Timeline
section_cursors = Cursors
section_background = Background
section_grid = Grid
section_guides_and_slices = Guides && Slices
section_undo = Undo
section_theme = Theme
section_experimental = Experimental
@ -356,6 +357,11 @@ grid_pixel_grid_visible = Visible Pixel Grid
grid_pixel_grid_color = Color:
grid_pixel_grid_opacity = Opacity:
reset_grid = Reset
guides = Guides
slices = Slices
layer_edges_color = Layer Edges Color:
auto_guides_color = Auto Guides Color:
default_slice_color = Default Color:
undo = Undo
undo_size_limit = Undo Limit:
undo_size_limit_tooltip = <<<END

View File

@ -12,6 +12,7 @@
<listitem text="@.section_cursors" value="section_cursors" />
<listitem text="@.section_background" value="section_bg" />
<listitem text="@.section_grid" value="section_grid" />
<listitem text="@.section_guides_and_slices" value="section_guides_and_slices" />
<listitem text="@.section_undo" value="section_undo" />
<listitem text="@.section_theme" value="section_theme" />
<listitem text="@.section_experimental" value="section_experimental" />
@ -216,6 +217,23 @@
</hbox>
</vbox>
<!-- Guides -->
<vbox id="section_guides_and_slices">
<separator text="@.guides" horizontal="true" />
<grid columns="2">
<label text="@.layer_edges_color" />
<colorpicker id="layer_edges_color" rgba="true" />
<label text="@.auto_guides_color" />
<colorpicker id="auto_guides_color" rgba="true" />
</grid>
<separator text="@.slices" horizontal="true" />
<hbox>
<label text="@.default_slice_color" />
<colorpicker id="default_slice_color" rgba="true" />
</hbox>
</vbox>
<!-- Undo -->
<vbox id="section_undo">
<separator text="@.section_undo" horizontal="true" />

View File

@ -105,6 +105,13 @@ public:
m_pixelGridColor->setId("pixel_grid_color");
pixelGridColorPlaceholder()->addChild(m_pixelGridColor);
// Guide colors
layerEdgesColor()->setColor(m_pref.guides.layerEdgesColor());
autoGuidesColor()->setColor(m_pref.guides.autoGuidesColor());
// Slices default color
defaultSliceColor()->setColor(m_pref.slices.defaultColor());
// Others
if (m_pref.general.autoshowTimeline())
autotimeline()->setSelected(true);
@ -307,6 +314,9 @@ public:
m_pref.cursor.cursorScale(base::convert_to<int>(cursorScale()->getValue()));
m_pref.selection.autoOpaque(autoOpaque()->isSelected());
m_pref.selection.keepSelectionAfterClear(keepSelectionAfterClear()->isSelected());
m_pref.guides.layerEdgesColor(layerEdgesColor()->getColor());
m_pref.guides.autoGuidesColor(autoGuidesColor()->getColor());
m_pref.slices.defaultColor(defaultSliceColor()->getColor());
m_curPref->show.grid(gridVisible()->isSelected());
m_curPref->grid.bounds(gridBounds());

View File

@ -171,6 +171,28 @@ protected:
}
};
class ShowAutoGuidesCommand : public Command {
public:
ShowAutoGuidesCommand()
: Command("ShowAutoGuides",
"Show Auto Guides",
CmdUIOnlyFlag) {
}
Command* clone() const override { return new ShowAutoGuidesCommand(*this); }
protected:
bool onChecked(Context* ctx) override {
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
return docPref.show.autoGuides();
}
void onExecute(Context* ctx) override {
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
docPref.show.autoGuides(!docPref.show.autoGuides());
}
};
class ShowSlicesCommand : public Command {
public:
ShowSlicesCommand()
@ -223,6 +245,11 @@ Command* CommandFactory::createShowBrushPreviewCommand()
return new ShowBrushPreviewCommand;
}
Command* CommandFactory::createShowAutoGuidesCommand()
{
return new ShowAutoGuidesCommand;
}
Command* CommandFactory::createShowSlicesCommand()
{
return new ShowSlicesCommand;

View File

@ -119,6 +119,7 @@ FOR_EACH_COMMAND(SetLoopSection)
FOR_EACH_COMMAND(SetPalette)
FOR_EACH_COMMAND(SetPaletteEntrySize)
FOR_EACH_COMMAND(SetSameInk)
FOR_EACH_COMMAND(ShowAutoGuides)
FOR_EACH_COMMAND(ShowBrushPreview)
FOR_EACH_COMMAND(ShowExtras)
FOR_EACH_COMMAND(ShowGrid)

View File

@ -807,7 +807,7 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
if (cel) {
drawCelBounds(
g, cel,
color_utils::color_for_ui(m_docPref.guides.layerEdgesColor()));
color_utils::color_for_ui(Preferences::instance().guides.layerEdgesColor()));
if (showGuidesThisCel &&
m_showGuidesThisCel != cel)
@ -1040,7 +1040,7 @@ void Editor::drawCelGuides(ui::Graphics* g, const Cel* cel, const Cel* mouseCel)
drawCelBounds(
g, mouseCel,
color_utils::color_for_ui(m_docPref.guides.automaticGuidesColor()));
color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor()));
}
// Use whole canvas
else {
@ -1116,7 +1116,7 @@ void Editor::drawCelHGuide(ui::Graphics* g,
const gfx::Rect& scrCelBounds, const gfx::Rect& scrCmpBounds,
const int dottedX)
{
auto color = color_utils::color_for_ui(m_docPref.guides.automaticGuidesColor());
gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
g->drawHLine(color, scrX1, scrY, scrX2 - scrX1);
// Vertical guide to touch the horizontal line
@ -1142,7 +1142,7 @@ void Editor::drawCelVGuide(ui::Graphics* g,
const gfx::Rect& scrCelBounds, const gfx::Rect& scrCmpBounds,
const int dottedY)
{
auto color = color_utils::color_for_ui(m_docPref.guides.automaticGuidesColor());
gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
g->drawVLine(color, scrX, scrY1, scrY2 - scrY1);
// Horizontal guide to touch the vertical line
@ -2267,6 +2267,7 @@ bool Editor::showAutoCelGuides()
{
return
(getCurrentEditorInk()->isCelMovement() &&
m_docPref.show.autoGuides() &&
m_customizationDelegate &&
int(m_customizationDelegate->getPressedKeyAction(KeyContext::MoveTool) & KeyAction::AutoSelectLayer));
}

View File

@ -468,7 +468,7 @@ public:
m_transaction.execute(new cmd::SetMask(m_document, newMask));
}
void addSlice(Slice* newSlice) override {
auto color = m_docPref.guides.defaultSliceColor();
auto color = Preferences::instance().slices.defaultColor();
newSlice->userData().setColor(
doc::rgba(color.getRed(),
color.getGreen(),

View File

@ -403,8 +403,12 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
}
}
else if (elem_name == "colorpicker") {
bool rgba = bool_attr_is_true(elem, "rgba");
if (!widget)
widget = new ColorButton(Color::fromMask(), app_get_current_pixel_format(), false);
widget = new ColorButton(Color::fromMask(),
rgba ? IMAGE_RGB:
app_get_current_pixel_format(), false);
}
else if (elem_name == "dropdownbutton") {
if (!widget) {