mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-10 19:13:29 +00:00
Add a menu option to lock/unlock each brush
This is an alternative to lock brushes using its keyboard shortcut.
This commit is contained in:
parent
9dfd5ae0d3
commit
9f39f4384c
@ -64,10 +64,13 @@ protected:
|
|||||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||||
if (mouseMsg->buttons() == kButtonRight) {
|
if (mouseMsg->buttons() == kButtonRight) {
|
||||||
Menu menu;
|
Menu menu;
|
||||||
|
AppMenuItem lockItem(m_delegate->onIsBrushSlotLocked(m_slot) ? "Unlock Brush": "Lock Brush");
|
||||||
AppMenuItem deleteItem("Delete");
|
AppMenuItem deleteItem("Delete");
|
||||||
AppMenuItem deleteAllItem("Delete All");
|
AppMenuItem deleteAllItem("Delete All");
|
||||||
|
lockItem.Click.connect(&Item::onLockBrush, this);
|
||||||
deleteItem.Click.connect(&Item::onDeleteBrush, this);
|
deleteItem.Click.connect(&Item::onDeleteBrush, this);
|
||||||
deleteAllItem.Click.connect(&Item::onDeleteAllBrushes, this);
|
deleteAllItem.Click.connect(&Item::onDeleteAllBrushes, this);
|
||||||
|
menu.addChild(&lockItem);
|
||||||
menu.addChild(&deleteItem);
|
menu.addChild(&deleteItem);
|
||||||
menu.addChild(new Separator("", JI_HORIZONTAL));
|
menu.addChild(new Separator("", JI_HORIZONTAL));
|
||||||
menu.addChild(&deleteAllItem);
|
menu.addChild(&deleteAllItem);
|
||||||
@ -84,6 +87,13 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void onLockBrush() {
|
||||||
|
if (m_delegate->onIsBrushSlotLocked(m_slot))
|
||||||
|
m_delegate->onUnlockBrushSlot(m_slot);
|
||||||
|
else
|
||||||
|
m_delegate->onLockBrushSlot(m_slot);
|
||||||
|
}
|
||||||
|
|
||||||
void onDeleteBrush() {
|
void onDeleteBrush() {
|
||||||
m_delegate->onDeleteBrushSlot(m_slot);
|
m_delegate->onDeleteBrushSlot(m_slot);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ namespace app {
|
|||||||
virtual ~BrushPopupDelegate() { }
|
virtual ~BrushPopupDelegate() { }
|
||||||
virtual void onDeleteBrushSlot(int slot) = 0;
|
virtual void onDeleteBrushSlot(int slot) = 0;
|
||||||
virtual void onDeleteAllBrushes() = 0;
|
virtual void onDeleteAllBrushes() = 0;
|
||||||
|
virtual bool onIsBrushSlotLocked(int slot) const = 0;
|
||||||
|
virtual void onLockBrushSlot(int slot) = 0;
|
||||||
|
virtual void onUnlockBrushSlot(int slot) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BrushPopup : public ui::PopupWindow {
|
class BrushPopup : public ui::PopupWindow {
|
||||||
|
@ -113,6 +113,18 @@ protected:
|
|||||||
m_owner->removeAllBrushes();
|
m_owner->removeAllBrushes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool onIsBrushSlotLocked(int slot) const override {
|
||||||
|
return m_owner->isBrushSlotLocked(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onLockBrushSlot(int slot) override {
|
||||||
|
m_owner->lockBrushSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
void onUnlockBrushSlot(int slot) override {
|
||||||
|
m_owner->unlockBrushSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Returns a little rectangle that can be used by the popup as the
|
// Returns a little rectangle that can be used by the popup as the
|
||||||
// first brush position.
|
// first brush position.
|
||||||
@ -1066,6 +1078,35 @@ Brushes ContextBar::getBrushes()
|
|||||||
return brushes;
|
return brushes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextBar::lockBrushSlot(int slot)
|
||||||
|
{
|
||||||
|
--slot;
|
||||||
|
if (slot >= 0 && slot < (int)m_brushes.size() &&
|
||||||
|
m_brushes[slot].brush) {
|
||||||
|
m_brushes[slot].locked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContextBar::unlockBrushSlot(int slot)
|
||||||
|
{
|
||||||
|
--slot;
|
||||||
|
if (slot >= 0 && slot < (int)m_brushes.size() &&
|
||||||
|
m_brushes[slot].brush) {
|
||||||
|
m_brushes[slot].locked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ContextBar::isBrushSlotLocked(int slot) const
|
||||||
|
{
|
||||||
|
--slot;
|
||||||
|
if (slot >= 0 && slot < (int)m_brushes.size() &&
|
||||||
|
m_brushes[slot].brush) {
|
||||||
|
return m_brushes[slot].locked;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ContextBar::setActiveBrush(const doc::BrushRef& brush)
|
void ContextBar::setActiveBrush(const doc::BrushRef& brush)
|
||||||
{
|
{
|
||||||
m_activeBrush = brush;
|
m_activeBrush = brush;
|
||||||
|
@ -57,6 +57,10 @@ namespace app {
|
|||||||
void setActiveBrushBySlot(int slot);
|
void setActiveBrushBySlot(int slot);
|
||||||
doc::Brushes getBrushes();
|
doc::Brushes getBrushes();
|
||||||
|
|
||||||
|
void lockBrushSlot(int slot);
|
||||||
|
void unlockBrushSlot(int slot);
|
||||||
|
bool isBrushSlotLocked(int slot) const;
|
||||||
|
|
||||||
static doc::BrushRef createBrushFromSettings(
|
static doc::BrushRef createBrushFromSettings(
|
||||||
IBrushSettings* brushSettings = nullptr);
|
IBrushSettings* brushSettings = nullptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user