Skip to content

Commit e0ff519

Browse files
authored
Add new frame menu to status bar button (aseprite#4582)
1 parent 99f1a1e commit e0ff519

File tree

13 files changed

+58
-7
lines changed

13 files changed

+58
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
.vs
1515
tests/_test*
1616
build
17+
CMakeSettings.json
10 Bytes
Loading

data/extensions/aseprite-theme/dark/theme.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@
390390
<part id="icon_slice" x="248" y="264" w="8" h="8" />
391391
<part id="icon_aspect_ratio" x="256" y="264" w="10" h="8" />
392392
<part id="icon_delta" x="266" y="264" w="6" h="8" />
393+
<part id="icon_add" x="184" y="200" w="5" h="5" />
393394
<part id="tool_rectangular_marquee" x="144" y="0" w="16" h="16" />
394395
<part id="tool_elliptical_marquee" x="160" y="0" w="16" h="16" />
395396
<part id="tool_lasso" x="176" y="0" w="16" h="16" />
@@ -694,7 +695,9 @@
694695
<background color="check_hot_face" state="selected" />
695696
<icon part="pal_options" />
696697
</style>
697-
<style id="new_frame_button" extends="mini_button" />
698+
<style id="new_frame_button" extends="mini_button" padding-bottom="1">
699+
<icon part="icon_add" />
700+
</style>
698701
<style id="color_button" extends="mini_button" font="mini" padding-bottom="1" />
699702
<style id="splitter">
700703
<background color="face" />
8 Bytes
Loading

data/extensions/aseprite-theme/theme.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@
386386
<part id="icon_slice" x="248" y="264" w="8" h="8" />
387387
<part id="icon_aspect_ratio" x="256" y="264" w="10" h="8" />
388388
<part id="icon_delta" x="266" y="264" w="6" h="8" />
389+
<part id="icon_add" x="184" y="200" w="5" h="5" />
389390
<part id="tool_rectangular_marquee" x="144" y="0" w="16" h="16" />
390391
<part id="tool_elliptical_marquee" x="160" y="0" w="16" h="16" />
391392
<part id="tool_lasso" x="176" y="0" w="16" h="16" />
@@ -687,7 +688,9 @@
687688
<background color="check_hot_face" state="selected" />
688689
<icon part="pal_options" />
689690
</style>
690-
<style id="new_frame_button" extends="mini_button" />
691+
<style id="new_frame_button" extends="mini_button" padding-bottom="1">
692+
<icon part="icon_add" />
693+
</style>
691694
<style id="color_button" extends="mini_button" font="mini" padding-bottom="1" />
692695
<style id="splitter">
693696
<background color="face" />

data/gui.xml

+13
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,19 @@
10891089
</menu>
10901090
</menu>
10911091

1092+
<menu id="new_frame_popup_menu">
1093+
<item command="NewFrame" text="@main_menu.frame_duplicate_linked_cels">
1094+
<param name="content" value="cellinked" />
1095+
</item>
1096+
<item command="NewFrame" text="@main_menu.frame_duplicate_cels">
1097+
<param name="content" value="celcopies" />
1098+
</item>
1099+
<item command="NewFrame" text="@main_menu.frame_new_empty_frame">
1100+
<param name="content" value="empty" />
1101+
</item>
1102+
<item command="NewFrame" text="@main_menu.frame_new_frame" />
1103+
</menu>
1104+
10921105
<menu id="tab_popup_menu">
10931106
<item command="CloseFile" text="@.close" group="tab_close" />
10941107
</menu>

data/strings/en.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ disable_snap_grid = Disable Snap to Grid
3838
frame = Frame:
3939
current_frame = Current Frame
4040
zoom_level = Zoom Level
41-
new_frame = New Frame
41+
new_frame = New Frame\nRight-click for more options
4242
locked_layers = There are locked layers
4343
no_active_layers = There is no active layer
4444
layer_x_is_hidden = Layer "{}" is hidden

src/app/app_menus.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ void AppMenus::reload()
382382
m_slicePopupMenu.reset(loadMenuById(handle, "slice_popup_menu"));
383383
m_palettePopupMenu.reset(loadMenuById(handle, "palette_popup_menu"));
384384
m_inkPopupMenu.reset(loadMenuById(handle, "ink_popup_menu"));
385+
m_newFramePopupMenu.reset(loadMenuById(handle, "new_frame_popup_menu"));
385386

386387
// Add one menu item to run each script from the user scripts/ folder
387388
{
@@ -920,6 +921,7 @@ void AppMenus::updateMenusList()
920921
m_menus.push_back(m_slicePopupMenu.get());
921922
m_menus.push_back(m_palettePopupMenu.get());
922923
m_menus.push_back(m_inkPopupMenu.get());
924+
m_menus.push_back(m_newFramePopupMenu.get());
923925
}
924926

925927
void AppMenus::createNativeMenus()

src/app/app_menus.h

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace app {
5757
Menu* getPalettePopupMenu() { return m_palettePopupMenu.get(); }
5858
Menu* getInkPopupMenu() { return m_inkPopupMenu.get(); }
5959
Menu* getAnimationMenu();
60+
Menu* getNewFrameMenu() { return m_newFramePopupMenu.get(); }
6061

6162
void applyShortcutToMenuitemsWithCommand(Command* command, const Params& params,
6263
const KeyPtr& key);
@@ -111,6 +112,7 @@ namespace app {
111112
std::unique_ptr<Menu> m_slicePopupMenu;
112113
std::unique_ptr<Menu> m_palettePopupMenu;
113114
std::unique_ptr<Menu> m_inkPopupMenu;
115+
std::unique_ptr<Menu> m_newFramePopupMenu;
114116
obs::scoped_connection m_recentFilesConn;
115117
std::vector<Menu*> m_menus;
116118
// List of recent menu items pointing to recent files.

src/app/ui/status_bar.cpp

+15-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#endif
1111

1212
#include "app/app.h"
13+
#include "app/app_menus.h"
1314
#include "app/commands/commands.h"
1415
#include "app/commands/params.h"
1516
#include "app/context_access.h"
@@ -694,13 +695,19 @@ StatusBar::StatusBar(TooltipManager* tooltipManager)
694695

695696
// Construct the commands box
696697
{
698+
auto theme = SkinTheme::get(this);
697699
Box* box1 = new Box(HORIZONTAL);
698700
Box* box4 = new Box(HORIZONTAL);
699701

700702
m_frameLabel = new Label(Strings::statusbar_tips_frame());
701703
m_currentFrame = new GotoFrameEntry();
702-
m_newFrame = new Button("+");
703-
m_newFrame->Click.connect([this]{ newFrame(); });
704+
m_newFrame = new Button("");
705+
if (!theme->parts.iconAdd())
706+
m_newFrame->setText("+"); // Fallback for themes without the icon.
707+
708+
m_newFrame->Click.connect(&StatusBar::newFrame, this);
709+
m_newFrame->RightClick.connect(&StatusBar::showNewFramePopupMenu, this);
710+
704711
m_zoomEntry = new ZoomEntry;
705712
m_zoomEntry->ZoomChange.connect(&StatusBar::onChangeZoom, this);
706713

@@ -922,7 +929,7 @@ void StatusBar::onInitTheme(ui::InitThemeEvent& ev)
922929
textHeight()+8*guiscale()));
923930

924931
m_newFrame->setStyle(theme->styles.newFrameButton());
925-
m_commandsBox->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());
932+
m_commandsBox->setBorder(gfx::Border(2, 2, 2, 2)*guiscale());
926933

927934
if (m_snapToGridWindow) {
928935
m_snapToGridWindow->initTheme();
@@ -996,6 +1003,11 @@ void StatusBar::newFrame()
9961003
UIContext::instance()->executeCommandFromMenuOrShortcut(cmd);
9971004
}
9981005

1006+
void StatusBar::showNewFramePopupMenu()
1007+
{
1008+
AppMenus::instance()->getNewFrameMenu()->showPopup(mousePosInDisplay(), display());
1009+
}
1010+
9991011
void StatusBar::onChangeZoom(const render::Zoom& zoom)
10001012
{
10011013
if (auto editor = Editor::activeEditor())

src/app/ui/status_bar.h

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ namespace app {
8989
private:
9090
void onCelOpacitySliderChange();
9191
void newFrame();
92+
void showNewFramePopupMenu();
9293
void onChangeZoom(const render::Zoom& zoom);
9394
void updateSnapToGridWindowPosition();
9495
void showIndicators();

src/ui/button.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ void ButtonBase::onClick()
5656
Click();
5757
}
5858

59+
void ButtonBase::onRightClick()
60+
{
61+
RightClick();
62+
}
63+
5964
bool ButtonBase::onProcessMessage(Message* msg)
6065
{
6166
switch (msg->type()) {
@@ -205,10 +210,17 @@ bool ButtonBase::onProcessMessage(Message* msg)
205210
releaseMouse();
206211

207212
if (hasMouse()) {
213+
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
214+
208215
switch (m_behaviorType) {
209216

210217
case kButtonWidget:
211-
generateButtonSelectSignal();
218+
{
219+
if (mouseMsg->right())
220+
onRightClick();
221+
else
222+
generateButtonSelectSignal();
223+
}
212224
break;
213225

214226
case kCheckWidget:

src/ui/button.h

+2
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ namespace ui {
3434
WidgetType behaviorType() const;
3535
// Signals
3636
obs::signal<void()> Click;
37+
obs::signal<void()> RightClick;
3738

3839
protected:
3940
// Events
4041
bool onProcessMessage(Message* msg) override;
4142

4243
// New events
4344
virtual void onClick();
45+
virtual void onRightClick();
4446
virtual void onStartDrag();
4547
virtual void onSelectWhenDragging();
4648

0 commit comments

Comments
 (0)