forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snap to grid preferences (fix aseprite#723)
This commit adds fields on Preferences > Grid about: - Snap To Grid (on/off) - Snap To <geometric location in a box grid> Also added PreferSnapTo::BoxCenter calculation in snap_to_grid.cpp.
- Loading branch information
1 parent
dd7e27a
commit 8c69881
Showing
11 changed files
with
166 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Aseprite | ||
// Copyright (C) 2023 Igara Studio S.A. | ||
// | ||
// This program is distributed under the terms of | ||
// the End-User License Agreement for Aseprite. | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include "app/snap_to_grid.h" | ||
#include "app/ui/snap_to_selector.h" | ||
|
||
#include "app/i18n/strings.h" | ||
|
||
namespace app { | ||
|
||
SnapToSelector::SnapToSelector() | ||
{ | ||
// addItem() must match the PreferSnapTo enum | ||
static_assert(int(PreferSnapTo::ClosestGridVertex) == 0 && | ||
int(PreferSnapTo::BoxCenter) == 1, | ||
"Unexpected app::PreferSnapTo values"); | ||
|
||
addItem(Strings::snap_to_selector_default()); | ||
addItem(Strings::snap_to_selector_box_center()); | ||
snapTo(app::PreferSnapTo::ClosestGridVertex); | ||
} | ||
|
||
PreferSnapTo SnapToSelector::snapTo() | ||
{ | ||
return (PreferSnapTo)getSelectedItemIndex(); | ||
} | ||
|
||
void SnapToSelector::snapTo(const PreferSnapTo snapTo) | ||
{ | ||
setSelectedItemIndex((int)snapTo); | ||
} | ||
|
||
} // namespace app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Aseprite | ||
// Copyright (C) 2023 Igara Studio S.A. | ||
// | ||
// This program is distributed under the terms of | ||
// the End-User License Agreement for Aseprite. | ||
|
||
#ifndef APP_UI_SNAP_TO_SELECTOR_H_INCLUDED | ||
#define APP_UI_SNAP_TO_SELECTOR_H_INCLUDED | ||
#pragma once | ||
|
||
#include "app/snap_to_grid.h" | ||
#include "ui/combobox.h" | ||
|
||
namespace app { | ||
|
||
class SnapToSelector : public ui::ComboBox { | ||
public: | ||
SnapToSelector(); | ||
|
||
PreferSnapTo snapTo(); | ||
void snapTo(PreferSnapTo snapTo); | ||
}; | ||
|
||
} // namespace app | ||
|
||
#endif |