Add option to show/hide Aseprite menu bar

The original Aseprite menu bar will be hidden by default for new users
on macOS.
This commit is contained in:
David Capello 2017-09-01 17:18:53 -03:00
parent 0154a73d36
commit dfa441d2a0
6 changed files with 41 additions and 2 deletions

View File

@ -109,6 +109,7 @@
<option id="data_recovery_period" type="double" default="2.0" />
<option id="show_full_path" type="bool" default="true" />
<option id="timeline_position" type="TimelinePosition" default="TimelinePosition::BOTTOM" />
<option id="show_menu_bar" type="bool" default="true" />
</section>
<section id="undo" text="Undo">
<option id="size_limit" type="int" default="64" />

View File

@ -275,6 +275,7 @@ screen_scaling = Screen Scaling:
ui_scaling = UI Elements Scaling:
gpu_acceleration = GPU acceleration
gpu_acceleration_tooltip = Check this option to enable hardware acceleration
show_menu_bar = Show Aseprite menu bar
show_home = Show Home tab when Aseprite is started
expand_menu_bar_items_on_mouseover = Expand menu bar items on mouseover
expand_menu_bar_items_on_mouseover_tooltip = <<<END

View File

@ -45,6 +45,8 @@
<check id="gpu_acceleration"
text="@.gpu_acceleration"
tooltip="@.gpu_acceleration_tooltip" />
<check id="show_menu_bar"
text="@.show_menu_bar" />
<check id="show_home"
text="@.show_home" />
<check id="expand_menubar_on_mouseover"

View File

@ -252,6 +252,13 @@ public:
gpuAcceleration()->setVisible(false);
}
// If the platform does support native menus, we show the option,
// in other case, the option doesn't make sense for this platform.
if (she::instance()->menus())
showMenuBar()->setSelected(m_pref.general.showMenuBar());
else
showMenuBar()->setVisible(false);
showHome()->setSelected(m_pref.general.showHome());
// Right-click
@ -429,6 +436,11 @@ public:
reset_screen = true;
}
if (she::instance()->menus() &&
m_pref.general.showMenuBar() != showMenuBar()->isSelected()) {
m_pref.general.showMenuBar(showMenuBar()->isSelected());
}
bool newShowHome = showHome()->isSelected();
if (newShowHome != m_pref.general.showHome())
m_pref.general.showHome(newShowHome);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -15,6 +15,7 @@
#include "app/tools/ink.h"
#include "app/tools/tool.h"
#include "doc/sprite.h"
#include "she/system.h"
namespace app {
@ -34,6 +35,14 @@ Preferences::Preferences()
singleton = this;
load();
// Hide the menu bar depending on:
// 1. the native menu bar is available
// 2. this is the first run of the program
if (she::instance()->menus() &&
updater.uuid().empty()) {
general.showMenuBar(false);
}
}
Preferences::~Preferences()

View File

@ -38,6 +38,7 @@
#include "base/bind.h"
#include "base/fs.h"
#include "she/display.h"
#include "she/system.h"
#include "ui/message.h"
#include "ui/splitter.h"
#include "ui/system.h"
@ -137,7 +138,10 @@ MainWindow::MainWindow()
timelineSplitter()->setPosition(75);
// Reconfigure workspace when the timeline position is changed.
Preferences::instance().general.timelinePosition
auto& pref = Preferences::instance();
pref.general.timelinePosition
.AfterChange.connect(base::Bind<void>(&MainWindow::configureWorkspaceLayout, this));
pref.general.showMenuBar
.AfterChange.connect(base::Bind<void>(&MainWindow::configureWorkspaceLayout, this));
// Prepare the window
@ -478,6 +482,16 @@ void MainWindow::configureWorkspaceLayout()
bool normal = (m_mode == NormalMode);
bool isDoc = (getDocView() != nullptr);
if (she::instance()->menus() == nullptr ||
pref.general.showMenuBar()) {
if (!m_menuBar->parent())
menuBarPlaceholder()->insertChild(0, m_menuBar);
}
else {
if (m_menuBar->parent())
menuBarPlaceholder()->removeChild(m_menuBar);
}
m_menuBar->setVisible(normal);
m_tabsBar->setVisible(normal);
colorBarPlaceholder()->setVisible(normal && isDoc);