Add new frame menu to status bar button (#4582)

This commit is contained in:
Christian Kaiser 2024-08-08 17:23:41 -03:00 committed by GitHub
parent 99f1a1ea06
commit e0ff51947a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 58 additions and 7 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@
.vs
tests/_test*
build
CMakeSettings.json

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -390,6 +390,7 @@
<part id="icon_slice" x="248" y="264" w="8" h="8" />
<part id="icon_aspect_ratio" x="256" y="264" w="10" h="8" />
<part id="icon_delta" x="266" y="264" w="6" h="8" />
<part id="icon_add" x="184" y="200" w="5" h="5" />
<part id="tool_rectangular_marquee" x="144" y="0" w="16" h="16" />
<part id="tool_elliptical_marquee" x="160" y="0" w="16" h="16" />
<part id="tool_lasso" x="176" y="0" w="16" h="16" />
@ -694,7 +695,9 @@
<background color="check_hot_face" state="selected" />
<icon part="pal_options" />
</style>
<style id="new_frame_button" extends="mini_button" />
<style id="new_frame_button" extends="mini_button" padding-bottom="1">
<icon part="icon_add" />
</style>
<style id="color_button" extends="mini_button" font="mini" padding-bottom="1" />
<style id="splitter">
<background color="face" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -386,6 +386,7 @@
<part id="icon_slice" x="248" y="264" w="8" h="8" />
<part id="icon_aspect_ratio" x="256" y="264" w="10" h="8" />
<part id="icon_delta" x="266" y="264" w="6" h="8" />
<part id="icon_add" x="184" y="200" w="5" h="5" />
<part id="tool_rectangular_marquee" x="144" y="0" w="16" h="16" />
<part id="tool_elliptical_marquee" x="160" y="0" w="16" h="16" />
<part id="tool_lasso" x="176" y="0" w="16" h="16" />
@ -687,7 +688,9 @@
<background color="check_hot_face" state="selected" />
<icon part="pal_options" />
</style>
<style id="new_frame_button" extends="mini_button" />
<style id="new_frame_button" extends="mini_button" padding-bottom="1">
<icon part="icon_add" />
</style>
<style id="color_button" extends="mini_button" font="mini" padding-bottom="1" />
<style id="splitter">
<background color="face" />

View File

@ -1089,6 +1089,19 @@
</menu>
</menu>
<menu id="new_frame_popup_menu">
<item command="NewFrame" text="@main_menu.frame_duplicate_linked_cels">
<param name="content" value="cellinked" />
</item>
<item command="NewFrame" text="@main_menu.frame_duplicate_cels">
<param name="content" value="celcopies" />
</item>
<item command="NewFrame" text="@main_menu.frame_new_empty_frame">
<param name="content" value="empty" />
</item>
<item command="NewFrame" text="@main_menu.frame_new_frame" />
</menu>
<menu id="tab_popup_menu">
<item command="CloseFile" text="@.close" group="tab_close" />
</menu>

View File

@ -38,7 +38,7 @@ disable_snap_grid = Disable Snap to Grid
frame = Frame:
current_frame = Current Frame
zoom_level = Zoom Level
new_frame = New Frame
new_frame = New Frame\nRight-click for more options
locked_layers = There are locked layers
no_active_layers = There is no active layer
layer_x_is_hidden = Layer "{}" is hidden

View File

@ -382,6 +382,7 @@ void AppMenus::reload()
m_slicePopupMenu.reset(loadMenuById(handle, "slice_popup_menu"));
m_palettePopupMenu.reset(loadMenuById(handle, "palette_popup_menu"));
m_inkPopupMenu.reset(loadMenuById(handle, "ink_popup_menu"));
m_newFramePopupMenu.reset(loadMenuById(handle, "new_frame_popup_menu"));
// Add one menu item to run each script from the user scripts/ folder
{
@ -920,6 +921,7 @@ void AppMenus::updateMenusList()
m_menus.push_back(m_slicePopupMenu.get());
m_menus.push_back(m_palettePopupMenu.get());
m_menus.push_back(m_inkPopupMenu.get());
m_menus.push_back(m_newFramePopupMenu.get());
}
void AppMenus::createNativeMenus()

View File

@ -57,6 +57,7 @@ namespace app {
Menu* getPalettePopupMenu() { return m_palettePopupMenu.get(); }
Menu* getInkPopupMenu() { return m_inkPopupMenu.get(); }
Menu* getAnimationMenu();
Menu* getNewFrameMenu() { return m_newFramePopupMenu.get(); }
void applyShortcutToMenuitemsWithCommand(Command* command, const Params& params,
const KeyPtr& key);
@ -111,6 +112,7 @@ namespace app {
std::unique_ptr<Menu> m_slicePopupMenu;
std::unique_ptr<Menu> m_palettePopupMenu;
std::unique_ptr<Menu> m_inkPopupMenu;
std::unique_ptr<Menu> m_newFramePopupMenu;
obs::scoped_connection m_recentFilesConn;
std::vector<Menu*> m_menus;
// List of recent menu items pointing to recent files.

View File

@ -10,6 +10,7 @@
#endif
#include "app/app.h"
#include "app/app_menus.h"
#include "app/commands/commands.h"
#include "app/commands/params.h"
#include "app/context_access.h"
@ -694,13 +695,19 @@ StatusBar::StatusBar(TooltipManager* tooltipManager)
// Construct the commands box
{
auto theme = SkinTheme::get(this);
Box* box1 = new Box(HORIZONTAL);
Box* box4 = new Box(HORIZONTAL);
m_frameLabel = new Label(Strings::statusbar_tips_frame());
m_currentFrame = new GotoFrameEntry();
m_newFrame = new Button("+");
m_newFrame->Click.connect([this]{ newFrame(); });
m_newFrame = new Button("");
if (!theme->parts.iconAdd())
m_newFrame->setText("+"); // Fallback for themes without the icon.
m_newFrame->Click.connect(&StatusBar::newFrame, this);
m_newFrame->RightClick.connect(&StatusBar::showNewFramePopupMenu, this);
m_zoomEntry = new ZoomEntry;
m_zoomEntry->ZoomChange.connect(&StatusBar::onChangeZoom, this);
@ -922,7 +929,7 @@ void StatusBar::onInitTheme(ui::InitThemeEvent& ev)
textHeight()+8*guiscale()));
m_newFrame->setStyle(theme->styles.newFrameButton());
m_commandsBox->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());
m_commandsBox->setBorder(gfx::Border(2, 2, 2, 2)*guiscale());
if (m_snapToGridWindow) {
m_snapToGridWindow->initTheme();
@ -996,6 +1003,11 @@ void StatusBar::newFrame()
UIContext::instance()->executeCommandFromMenuOrShortcut(cmd);
}
void StatusBar::showNewFramePopupMenu()
{
AppMenus::instance()->getNewFrameMenu()->showPopup(mousePosInDisplay(), display());
}
void StatusBar::onChangeZoom(const render::Zoom& zoom)
{
if (auto editor = Editor::activeEditor())

View File

@ -89,6 +89,7 @@ namespace app {
private:
void onCelOpacitySliderChange();
void newFrame();
void showNewFramePopupMenu();
void onChangeZoom(const render::Zoom& zoom);
void updateSnapToGridWindowPosition();
void showIndicators();

View File

@ -56,6 +56,11 @@ void ButtonBase::onClick()
Click();
}
void ButtonBase::onRightClick()
{
RightClick();
}
bool ButtonBase::onProcessMessage(Message* msg)
{
switch (msg->type()) {
@ -205,10 +210,17 @@ bool ButtonBase::onProcessMessage(Message* msg)
releaseMouse();
if (hasMouse()) {
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
switch (m_behaviorType) {
case kButtonWidget:
{
if (mouseMsg->right())
onRightClick();
else
generateButtonSelectSignal();
}
break;
case kCheckWidget:

View File

@ -34,6 +34,7 @@ namespace ui {
WidgetType behaviorType() const;
// Signals
obs::signal<void()> Click;
obs::signal<void()> RightClick;
protected:
// Events
@ -41,6 +42,7 @@ namespace ui {
// New events
virtual void onClick();
virtual void onRightClick();
virtual void onStartDrag();
virtual void onSelectWhenDragging();