mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 21:19:10 +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);
|
||||
if (mouseMsg->buttons() == kButtonRight) {
|
||||
Menu menu;
|
||||
AppMenuItem lockItem(m_delegate->onIsBrushSlotLocked(m_slot) ? "Unlock Brush": "Lock Brush");
|
||||
AppMenuItem deleteItem("Delete");
|
||||
AppMenuItem deleteAllItem("Delete All");
|
||||
lockItem.Click.connect(&Item::onLockBrush, this);
|
||||
deleteItem.Click.connect(&Item::onDeleteBrush, this);
|
||||
deleteAllItem.Click.connect(&Item::onDeleteAllBrushes, this);
|
||||
menu.addChild(&lockItem);
|
||||
menu.addChild(&deleteItem);
|
||||
menu.addChild(new Separator("", JI_HORIZONTAL));
|
||||
menu.addChild(&deleteAllItem);
|
||||
@ -84,6 +87,13 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
void onLockBrush() {
|
||||
if (m_delegate->onIsBrushSlotLocked(m_slot))
|
||||
m_delegate->onUnlockBrushSlot(m_slot);
|
||||
else
|
||||
m_delegate->onLockBrushSlot(m_slot);
|
||||
}
|
||||
|
||||
void onDeleteBrush() {
|
||||
m_delegate->onDeleteBrushSlot(m_slot);
|
||||
}
|
||||
|
@ -31,6 +31,9 @@ namespace app {
|
||||
virtual ~BrushPopupDelegate() { }
|
||||
virtual void onDeleteBrushSlot(int slot) = 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 {
|
||||
|
@ -113,6 +113,18 @@ protected:
|
||||
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:
|
||||
// Returns a little rectangle that can be used by the popup as the
|
||||
// first brush position.
|
||||
@ -1066,6 +1078,35 @@ Brushes ContextBar::getBrushes()
|
||||
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)
|
||||
{
|
||||
m_activeBrush = brush;
|
||||
|
@ -57,6 +57,10 @@ namespace app {
|
||||
void setActiveBrushBySlot(int slot);
|
||||
doc::Brushes getBrushes();
|
||||
|
||||
void lockBrushSlot(int slot);
|
||||
void unlockBrushSlot(int slot);
|
||||
bool isBrushSlotLocked(int slot) const;
|
||||
|
||||
static doc::BrushRef createBrushFromSettings(
|
||||
IBrushSettings* brushSettings = nullptr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user