mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Fix issue #164: Palette area visible in Advanced Mode.
Instead of switching ColorBar visibility, we've to switch the Splitter position between the ColorBar and sprite editors.
This commit is contained in:
parent
2e80621a1e
commit
23660eb0d1
@ -25,12 +25,7 @@
|
||||
#include "ini_file.h"
|
||||
#include "modules/gui.h"
|
||||
#include "ui/gui.h"
|
||||
#include "widgets/color_bar.h"
|
||||
#include "widgets/main_menu_bar.h"
|
||||
#include "widgets/main_window.h"
|
||||
#include "widgets/status_bar.h"
|
||||
#include "widgets/tabs.h"
|
||||
#include "widgets/toolbar.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
@ -44,13 +39,8 @@ public:
|
||||
|
||||
protected:
|
||||
void onExecute(Context* context);
|
||||
|
||||
private:
|
||||
static bool advanced_mode;
|
||||
};
|
||||
|
||||
bool AdvancedModeCommand::advanced_mode = false;
|
||||
|
||||
AdvancedModeCommand::AdvancedModeCommand()
|
||||
: Command("AdvancedMode",
|
||||
"Advanced Mode",
|
||||
@ -60,19 +50,12 @@ AdvancedModeCommand::AdvancedModeCommand()
|
||||
|
||||
void AdvancedModeCommand::onExecute(Context* context)
|
||||
{
|
||||
advanced_mode = !advanced_mode;
|
||||
|
||||
// Switch advanced mode.
|
||||
MainWindow* mainWindow = App::instance()->getMainWindow();
|
||||
mainWindow->getMenuBar()->setVisible(!advanced_mode);
|
||||
mainWindow->getTabsBar()->setVisible(!advanced_mode);
|
||||
ToolBar::instance()->setVisible(!advanced_mode);
|
||||
StatusBar::instance()->setVisible(!advanced_mode);
|
||||
ColorBar::instance()->setVisible(!advanced_mode);
|
||||
bool advancedMode = !mainWindow->isAdvancedMode();
|
||||
mainWindow->setAdvancedMode(advancedMode);
|
||||
|
||||
mainWindow->remap_window();
|
||||
mainWindow->invalidate();
|
||||
|
||||
if (advanced_mode &&
|
||||
if (advancedMode &&
|
||||
get_config_bool("AdvancedMode", "Warning", true)) {
|
||||
Accelerator* accel = get_accel_to_execute_command(short_name());
|
||||
if (accel != NULL) {
|
||||
|
@ -37,7 +37,11 @@ double Splitter::getPosition() const
|
||||
|
||||
void Splitter::setPosition(double pos)
|
||||
{
|
||||
m_pos = MID(0, pos, 100);
|
||||
if (m_type == ByPercentage)
|
||||
m_pos = MID(0, pos, 100);
|
||||
else
|
||||
m_pos = pos;
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,11 @@
|
||||
#include "widgets/main_window.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "app_menus.h"
|
||||
#include "app/load_widget.h"
|
||||
#include "app_menus.h"
|
||||
#include "commands/commands.h"
|
||||
#include "modules/editors.h"
|
||||
#include "ui/splitter.h"
|
||||
#include "ui/system.h"
|
||||
#include "ui/view.h"
|
||||
#include "ui_context.h"
|
||||
@ -47,6 +48,8 @@ public:
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: Window(true, NULL)
|
||||
, m_lastSplitterPos(0.0)
|
||||
, m_advancedMode(false)
|
||||
{
|
||||
setId("main_window");
|
||||
|
||||
@ -71,6 +74,7 @@ MainWindow::MainWindow()
|
||||
m_colorBar = new ColorBar(box_colorbar->getAlign());
|
||||
m_toolBar = new ToolBar();
|
||||
m_tabsBar = new Tabs(m_tabsDelegate = new AppTabsDelegate());
|
||||
m_colorBarSplitter = findChildT<Splitter>("colorbarsplitter");
|
||||
|
||||
// configure all widgets to expansives
|
||||
m_menuBar->setExpansive(true);
|
||||
@ -123,7 +127,7 @@ void MainWindow::reloadMenus()
|
||||
{
|
||||
m_menuBar->reload();
|
||||
|
||||
remap_window();
|
||||
layout();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ -143,6 +147,39 @@ void MainWindow::createFirstEditor()
|
||||
set_current_editor(editor); // TODO remove this line from here
|
||||
}
|
||||
|
||||
void MainWindow::setAdvancedMode(bool advanced)
|
||||
{
|
||||
// Check if we already are in the given mode.
|
||||
if (m_advancedMode == advanced)
|
||||
return;
|
||||
|
||||
m_advancedMode = advanced;
|
||||
|
||||
if (m_advancedMode) {
|
||||
m_lastSplitterPos = m_colorBarSplitter->getPosition();
|
||||
m_colorBarSplitter->setPosition(0.0);
|
||||
}
|
||||
else if (m_colorBarSplitter->getPosition() == 0.0)
|
||||
m_colorBarSplitter->setPosition(m_lastSplitterPos);
|
||||
|
||||
m_menuBar->setVisible(!advanced);
|
||||
m_tabsBar->setVisible(!advanced);
|
||||
m_toolBar->setVisible(!advanced);
|
||||
m_statusBar->setVisible(!advanced);
|
||||
|
||||
layout();
|
||||
}
|
||||
|
||||
void MainWindow::onSaveLayout(SaveLayoutEvent& ev)
|
||||
{
|
||||
Window::onSaveLayout(ev);
|
||||
|
||||
// Restore splitter position if we are in advanced mode, so we save
|
||||
// the original splitter position in the layout.
|
||||
if (m_colorBarSplitter->getPosition() == 0.0)
|
||||
m_colorBarSplitter->setPosition(m_lastSplitterPos);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// AppTabsDelegate
|
||||
|
||||
|
@ -27,6 +27,10 @@ class MainMenuBar;
|
||||
class StatusBar;
|
||||
class Tabs;
|
||||
|
||||
namespace ui {
|
||||
class Splitter;
|
||||
}
|
||||
|
||||
class MainWindow : public ui::Window
|
||||
{
|
||||
public:
|
||||
@ -39,13 +43,22 @@ public:
|
||||
void reloadMenus();
|
||||
void createFirstEditor();
|
||||
|
||||
bool isAdvancedMode() const { return m_advancedMode; }
|
||||
void setAdvancedMode(bool advanced);
|
||||
|
||||
protected:
|
||||
void onSaveLayout(ui::SaveLayoutEvent& ev) OVERRIDE;
|
||||
|
||||
private:
|
||||
AppTabsDelegate* m_tabsDelegate;
|
||||
MainMenuBar* m_menuBar; // the menu bar widget
|
||||
StatusBar* m_statusBar; // the status bar widget
|
||||
ColorBar* m_colorBar; // the color bar widget
|
||||
ui::Splitter* m_colorBarSplitter;
|
||||
ui::Widget* m_toolBar; // the tool bar widget
|
||||
Tabs* m_tabsBar; // The tabs bar widget
|
||||
double m_lastSplitterPos;
|
||||
bool m_advancedMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user