mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Change Window() ctor to avoid ambiguity (DesktopWindow, WithoutTitleBar, or WithTitleBar)
In this way we know at the moment of the creation of the window if it will need the close button. Issue #280. https://github.com/aseprite/aseprite/pull/6
This commit is contained in:
parent
7dc8e548be
commit
ad0b28bd63
@ -47,7 +47,7 @@ AboutCommand::AboutCommand()
|
||||
|
||||
void AboutCommand::onExecute(Context* context)
|
||||
{
|
||||
base::UniquePtr<Window> window(new Window(false, "About " PACKAGE));
|
||||
base::UniquePtr<Window> window(new Window(Window::WithTitleBar, "About " PACKAGE));
|
||||
Box* box1 = new Box(JI_VERTICAL);
|
||||
Grid* grid = new Grid(2, false);
|
||||
Label* title = new Label(PACKAGE " v" VERSION);
|
||||
|
@ -55,7 +55,7 @@ class CanvasSizeWindow : public Window
|
||||
{
|
||||
public:
|
||||
CanvasSizeWindow(int left, int top, int right, int bottom)
|
||||
: Window(false, "Canvas Size")
|
||||
: Window(WithTitleBar, "Canvas Size")
|
||||
, m_editor(current_editor)
|
||||
, m_rect(-left, -top,
|
||||
current_editor->getSprite()->getWidth() + left + right,
|
||||
|
@ -36,7 +36,7 @@ using namespace ui;
|
||||
class DeveloperConsole : public Window {
|
||||
public:
|
||||
DeveloperConsole()
|
||||
: Window(false, "Developer Console")
|
||||
: Window(WithTitleBar, "Developer Console")
|
||||
, m_vbox(JI_VERTICAL)
|
||||
{
|
||||
m_vbox.addChild(&m_docs);
|
||||
|
@ -55,7 +55,7 @@ class ExportSpriteSheetWindow : public Window {
|
||||
|
||||
public:
|
||||
ExportSpriteSheetWindow(Context* context)
|
||||
: Window(false, "Export Sprite Sheet")
|
||||
: Window(WithTitleBar, "Export Sprite Sheet")
|
||||
, m_context(context)
|
||||
, m_document(context->getActiveDocument())
|
||||
, m_grid(4, false)
|
||||
|
@ -58,7 +58,7 @@ class ImportSpriteSheetWindow : public Window,
|
||||
public SelectBoxDelegate {
|
||||
public:
|
||||
ImportSpriteSheetWindow(Context* context)
|
||||
: Window(false, "Import Sprite Sheet")
|
||||
: Window(WithTitleBar, "Import Sprite Sheet")
|
||||
, m_context(context)
|
||||
, m_document(NULL)
|
||||
, m_grid(4, false)
|
||||
|
@ -62,7 +62,7 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
||||
const ContextReader reader(context);
|
||||
const Layer* layer = reader.layer();
|
||||
|
||||
base::UniquePtr<Window> window(new Window(false, "Layer Properties"));
|
||||
base::UniquePtr<Window> window(new Window(Window::WithTitleBar, "Layer Properties"));
|
||||
Box* box1 = new Box(JI_VERTICAL);
|
||||
Box* box2 = new Box(JI_HORIZONTAL);
|
||||
Box* box3 = new Box(JI_HORIZONTAL + JI_HOMOGENEOUS);
|
||||
|
@ -100,7 +100,7 @@ void MaskByColorCommand::onExecute(Context* context)
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
base::UniquePtr<Window> window(new Window(false, "Mask by Color"));
|
||||
base::UniquePtr<Window> window(new Window(Window::WithTitleBar, "Mask by Color"));
|
||||
box1 = new Box(JI_VERTICAL);
|
||||
box2 = new Box(JI_HORIZONTAL);
|
||||
box3 = new Box(JI_HORIZONTAL);
|
||||
|
@ -243,7 +243,7 @@ void PaletteEditorCommand::onExecute(Context* context)
|
||||
// Based on ColorSelector class.
|
||||
|
||||
PaletteEntryEditor::PaletteEntryEditor()
|
||||
: Window(false, "Palette Editor (F4)")
|
||||
: Window(WithTitleBar, "Palette Editor (F4)")
|
||||
, m_vbox(JI_VERTICAL)
|
||||
, m_topBox(JI_HORIZONTAL)
|
||||
, m_bottomBox(JI_HORIZONTAL)
|
||||
|
@ -38,7 +38,7 @@ FilterWindow::FilterWindow(const char* title, const char* cfgSection,
|
||||
WithChannels withChannels,
|
||||
WithTiled withTiled,
|
||||
TiledMode tiledMode)
|
||||
: Window(false, title)
|
||||
: Window(WithTitleBar, title)
|
||||
, m_cfgSection(cfgSection)
|
||||
, m_filterMgr(filterMgr)
|
||||
, m_hbox(JI_HORIZONTAL)
|
||||
|
@ -54,7 +54,7 @@ Console::Console()
|
||||
console_counter > 1)
|
||||
return;
|
||||
else {
|
||||
Window* window = new Window(false, "Errors Console");
|
||||
Window* window = new Window(Window::WithTitleBar, "Errors Console");
|
||||
Grid* grid = new Grid(1, false);
|
||||
View* view = new View();
|
||||
TextBox* textbox = new TextBox("", JI_WORDWRAP);
|
||||
|
@ -194,7 +194,7 @@ public:
|
||||
};
|
||||
|
||||
FileSelector::FileSelector()
|
||||
: Window(false, "")
|
||||
: Window(WithTitleBar, "")
|
||||
{
|
||||
app::WidgetLoader loader;
|
||||
loader.addWidgetType("filenameentry", new CustomFileNameEntryCreator);
|
||||
|
@ -49,7 +49,7 @@ namespace app {
|
||||
using namespace ui;
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: Window(true, "")
|
||||
: Window(DesktopWindow)
|
||||
, m_lastSplitterPos(0.0)
|
||||
, m_lastTimelineSplitterPos(75.0)
|
||||
, m_advancedMode(false)
|
||||
|
@ -110,7 +110,7 @@ private:
|
||||
};
|
||||
|
||||
MiniEditorWindow::MiniEditorWindow()
|
||||
: Window(false, "Mini-Editor")
|
||||
: Window(WithTitleBar, "Mini-Editor")
|
||||
, m_docView(NULL)
|
||||
, m_playButton(new MiniPlayButton())
|
||||
, m_playTimer(10)
|
||||
|
@ -385,15 +385,14 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
/* window */
|
||||
else if (elem_name == "window") {
|
||||
const char *text = elem->Attribute("text");
|
||||
bool desktop = bool_attr_is_true(elem, "desktop");
|
||||
|
||||
if (text) {
|
||||
bool desktop = bool_attr_is_true(elem, "desktop");
|
||||
|
||||
if (desktop)
|
||||
widget = new Window(true, "");
|
||||
else
|
||||
widget = new Window(false, TRANSLATE_ATTR(text));
|
||||
}
|
||||
if (desktop)
|
||||
widget = new Window(Window::DesktopWindow);
|
||||
else if (text)
|
||||
widget = new Window(Window::WithTitleBar, TRANSLATE_ATTR(text));
|
||||
else
|
||||
widget = new Window(Window::WithoutTitleBar);
|
||||
}
|
||||
/* colorpicker */
|
||||
else if (elem_name == "colorpicker") {
|
||||
|
@ -42,7 +42,7 @@
|
||||
namespace ui {
|
||||
|
||||
Alert::Alert()
|
||||
: Window(false, "")
|
||||
: Window(WithTitleBar)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ void ComboBox::onButtonClick(Event& ev)
|
||||
void ComboBox::openListBox()
|
||||
{
|
||||
if (!m_window) {
|
||||
m_window = new Window(false, "");
|
||||
m_window = new Window(Window::WithoutTitleBar);
|
||||
View* view = new View();
|
||||
m_listbox = new ComboBoxListBox(this);
|
||||
m_window->setOnTop(true);
|
||||
|
@ -90,7 +90,7 @@ class CustomizedWindowForMenuBox : public Window
|
||||
{
|
||||
public:
|
||||
CustomizedWindowForMenuBox(MenuBox* menubox)
|
||||
: Window(false, "")
|
||||
: Window(WithoutTitleBar, "")
|
||||
{
|
||||
setMoveable(false); // Can't move the window
|
||||
addChild(menubox);
|
||||
@ -272,7 +272,7 @@ void Menu::showPopup(int x, int y)
|
||||
} while (jmouse_b(0) != kButtonNone);
|
||||
|
||||
// New window and new menu-box
|
||||
Window* window = new Window(false, "");
|
||||
Window* window = new Window(Window::WithoutTitleBar);
|
||||
MenuBox* menubox = new MenuBox();
|
||||
MenuBaseData* base = menubox->createBase();
|
||||
base->was_clicked = true;
|
||||
|
@ -22,7 +22,7 @@ namespace ui {
|
||||
using namespace gfx;
|
||||
|
||||
PopupWindow::PopupWindow(const base::string& text, bool close_on_buttonpressed)
|
||||
: Window(false, text)
|
||||
: Window(WithTitleBar, text)
|
||||
{
|
||||
m_close_on_buttonpressed = close_on_buttonpressed;
|
||||
m_filtering = false;
|
||||
|
@ -152,7 +152,7 @@ void TooltipManager::onTick()
|
||||
// TipWindow
|
||||
|
||||
TipWindow::TipWindow(const char *text, bool close_on_buttonpressed)
|
||||
: Window(false, text)
|
||||
: Window(WithTitleBar, text)
|
||||
{
|
||||
m_close_on_buttonpressed = close_on_buttonpressed;
|
||||
m_filtering = false;
|
||||
|
@ -33,21 +33,22 @@ enum {
|
||||
static gfx::Point clickedMousePos;
|
||||
static gfx::Rect* clickedWindowPos = NULL;
|
||||
|
||||
Window::Window(bool desktop, const base::string& text)
|
||||
Window::Window(Type type, const base::string& text)
|
||||
: Widget(kWindowWidget)
|
||||
{
|
||||
m_killer = NULL;
|
||||
m_isDesktop = desktop;
|
||||
m_isMoveable = !desktop;
|
||||
m_isSizeable = !desktop;
|
||||
m_isDesktop = (type == DesktopWindow);
|
||||
m_isMoveable = !m_isDesktop;
|
||||
m_isSizeable = !m_isDesktop;
|
||||
m_isOnTop = false;
|
||||
m_isWantFocus = true;
|
||||
m_isForeground = false;
|
||||
m_isAutoRemap = true;
|
||||
|
||||
setVisible(false);
|
||||
setText(text);
|
||||
setAlign(JI_LEFT | JI_MIDDLE);
|
||||
if (type == WithTitleBar)
|
||||
setText(text);
|
||||
|
||||
initTheme();
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ namespace ui {
|
||||
class Window : public Widget
|
||||
{
|
||||
public:
|
||||
Window(bool isDesktop, const base::string& text);
|
||||
enum Type { DesktopWindow, WithTitleBar, WithoutTitleBar };
|
||||
|
||||
explicit Window(Type type, const base::string& text = "");
|
||||
~Window();
|
||||
|
||||
Widget* getKiller();
|
||||
|
Loading…
x
Reference in New Issue
Block a user