mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-27 21:19:18 +00:00
Add "Save Brush Here" option to brush slot popup
This commit is contained in:
parent
2d64a1926e
commit
6ff62c899e
@ -77,6 +77,15 @@ BrushRef AppBrushes::getCustomBrush(slot_id slot) const
|
||||
return BrushRef();
|
||||
}
|
||||
|
||||
void AppBrushes::setCustomBrush(slot_id slot, const doc::BrushRef& brush)
|
||||
{
|
||||
--slot;
|
||||
if (slot >= 0 && slot < (int)m_slots.size()) {
|
||||
m_slots[slot].setBrush(brush);
|
||||
ItemsChange();
|
||||
}
|
||||
}
|
||||
|
||||
Brushes AppBrushes::getCustomBrushes()
|
||||
{
|
||||
Brushes brushes;
|
||||
|
@ -32,6 +32,7 @@ namespace app {
|
||||
bool hasCustomBrush(slot_id slot) const;
|
||||
const doc::Brushes& getStandardBrushes() { return m_standard; }
|
||||
doc::BrushRef getCustomBrush(slot_id slot) const;
|
||||
void setCustomBrush(slot_id slot, const doc::BrushRef& brush);
|
||||
doc::Brushes getCustomBrushes();
|
||||
|
||||
void lockCustomBrush(slot_id slot);
|
||||
|
@ -121,12 +121,16 @@ private:
|
||||
|
||||
void onClick() override {
|
||||
Menu menu;
|
||||
AppMenuItem save("Save Brush Here");
|
||||
AppMenuItem lockItem(m_delegate->onIsBrushSlotLocked(m_slot) ? "Unlock Brush": "Lock Brush");
|
||||
AppMenuItem deleteItem("Delete");
|
||||
AppMenuItem deleteAllItem("Delete All");
|
||||
save.Click.connect(&BrushOptionsItem::onSaveBrush, this);
|
||||
lockItem.Click.connect(&BrushOptionsItem::onLockBrush, this);
|
||||
deleteItem.Click.connect(&BrushOptionsItem::onDeleteBrush, this);
|
||||
deleteAllItem.Click.connect(&BrushOptionsItem::onDeleteAllBrushes, this);
|
||||
menu.addChild(&save);
|
||||
menu.addChild(new MenuSeparator);
|
||||
menu.addChild(&lockItem);
|
||||
menu.addChild(&deleteItem);
|
||||
menu.addChild(new MenuSeparator);
|
||||
@ -142,6 +146,13 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
void onSaveBrush() {
|
||||
AppBrushes& brushes = App::instance()->brushes();
|
||||
brushes.setCustomBrush(
|
||||
m_slot, ContextBar::createBrushFromPreferences());
|
||||
brushes.lockCustomBrush(m_slot);
|
||||
}
|
||||
|
||||
void onLockBrush() {
|
||||
if (m_delegate->onIsBrushSlotLocked(m_slot))
|
||||
m_delegate->onUnlockBrushSlot(m_slot);
|
||||
|
Loading…
Reference in New Issue
Block a user