mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-09 21:40:08 +00:00
Use generated widget app::gen::NewSprite in NewFileCommand
This commit is contained in:
parent
df0d39ed87
commit
303595689f
@ -15,12 +15,12 @@
|
|||||||
<separator text="Color Mode:" left="true" horizontal="true" />
|
<separator text="Color Mode:" left="true" horizontal="true" />
|
||||||
<box vertical="true" homogeneous="true" childspacing="0">
|
<box vertical="true" homogeneous="true" childspacing="0">
|
||||||
<box horizontal="true">
|
<box horizontal="true">
|
||||||
<radio id="radio3" text="&Indexed color" group="1" tooltip="Using a palette of 256 colors (8 bits per pixel)" />
|
<radio id="indexed_mode" text="&Indexed color" group="1" tooltip="Using a palette of 256 colors (8 bits per pixel)" />
|
||||||
<!-- <entry id="colors" maxsize="8" tooltip="Maximum number of colors (only for Indexed images) This field cannot be modified in this beta version." disabled="true" /> -->
|
<!-- <entry id="colors" maxsize="8" tooltip="Maximum number of colors (only for Indexed images) This field cannot be modified in this beta version." disabled="true" /> -->
|
||||||
<!-- <label text="Colors" /> -->
|
<!-- <label text="Colors" /> -->
|
||||||
</box>
|
</box>
|
||||||
<radio id="radio1" text="&RGB color" group="1" tooltip="RGBA color mode (32 bits per pixel)" />
|
<radio id="rgb_mode" text="&RGB color" group="1" tooltip="RGBA color mode (32 bits per pixel)" />
|
||||||
<radio id="radio2" text="&Grayscale" group="1" tooltip="Value and Alpha (16 bits per pixel)" />
|
<radio id="grayscale_mode" text="&Grayscale" group="1" tooltip="Value and Alpha (16 bits per pixel)" />
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<separator text="Background:" left="true" horizontal="true" />
|
<separator text="Background:" left="true" horizontal="true" />
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
#include "raster/stock.h"
|
#include "raster/stock.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
|
#include "generated_new_sprite.h"
|
||||||
|
|
||||||
#include <allegro/config.h>
|
#include <allegro/config.h>
|
||||||
#include <allegro/unicode.h>
|
#include <allegro/unicode.h>
|
||||||
|
|
||||||
@ -87,15 +89,7 @@ void NewFileCommand::onExecute(Context* context)
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Load the window widget
|
// Load the window widget
|
||||||
base::UniquePtr<Window> window(app::load_widget<Window>("new_sprite.xml", "new_sprite"));
|
app::gen::NewSprite window;
|
||||||
Widget* width = app::find_widget<Widget>(window, "width");
|
|
||||||
Widget* height = app::find_widget<Widget>(window, "height");
|
|
||||||
Widget* radio1 = app::find_widget<Widget>(window, "radio1");
|
|
||||||
Widget* radio2 = app::find_widget<Widget>(window, "radio2");
|
|
||||||
Widget* radio3 = app::find_widget<Widget>(window, "radio3");
|
|
||||||
// Widget* colors = app::find_widget<Widget>(window, "colors");
|
|
||||||
ListBox* bg_box = app::find_widget<ListBox>(window, "bg_box");
|
|
||||||
Widget* ok = app::find_widget<Widget>(window, "ok_button");
|
|
||||||
|
|
||||||
// Default values: Indexed, 320x240, Background color
|
// Default values: Indexed, 320x240, Background color
|
||||||
format = static_cast<PixelFormat>(get_config_int("NewSprite", "Type", IMAGE_INDEXED));
|
format = static_cast<PixelFormat>(get_config_int("NewSprite", "Type", IMAGE_INDEXED));
|
||||||
@ -116,35 +110,38 @@ void NewFileCommand::onExecute(Context* context)
|
|||||||
h = clipboardSize.h;
|
h = clipboardSize.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
width->setTextf("%d", MAX(1, w));
|
window.width()->setTextf("%d", MAX(1, w));
|
||||||
height->setTextf("%d", MAX(1, h));
|
window.height()->setTextf("%d", MAX(1, h));
|
||||||
// colors->setTextf("%d", MID(2, ncolors, 256));
|
// colors->setTextf("%d", MID(2, ncolors, 256));
|
||||||
|
|
||||||
// Select image-type
|
// Select image-type
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case IMAGE_RGB: radio1->setSelected(true); break;
|
case IMAGE_RGB: window.rgbMode()->setSelected(true); break;
|
||||||
case IMAGE_GRAYSCALE: radio2->setSelected(true); break;
|
case IMAGE_GRAYSCALE: window.grayscaleMode()->setSelected(true); break;
|
||||||
case IMAGE_INDEXED: radio3->setSelected(true); break;
|
case IMAGE_INDEXED: window.indexedMode()->setSelected(true); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select background color
|
// Select background color
|
||||||
bg_box->selectIndex(bg);
|
window.bgBox()->selectIndex(bg);
|
||||||
|
|
||||||
// Open the window
|
// Open the window
|
||||||
window->openWindowInForeground();
|
window.openWindowInForeground();
|
||||||
|
|
||||||
if (window->getKiller() == ok) {
|
if (window.getKiller() == window.okButton()) {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
|
||||||
// Get the options
|
// Get the options
|
||||||
if (radio1->isSelected()) format = IMAGE_RGB;
|
if (window.rgbMode()->isSelected())
|
||||||
else if (radio2->isSelected()) format = IMAGE_GRAYSCALE;
|
format = IMAGE_RGB;
|
||||||
else if (radio3->isSelected()) format = IMAGE_INDEXED;
|
else if (window.grayscaleMode()->isSelected())
|
||||||
|
format = IMAGE_GRAYSCALE;
|
||||||
|
else if (window.indexedMode()->isSelected())
|
||||||
|
format = IMAGE_INDEXED;
|
||||||
|
|
||||||
w = width->getTextInt();
|
w = window.width()->getTextInt();
|
||||||
h = height->getTextInt();
|
h = window.height()->getTextInt();
|
||||||
// ncolors = colors->getTextInt();
|
// ncolors = colors->getTextInt();
|
||||||
bg = bg_box->getSelectedIndex();
|
bg = window.bgBox()->getSelectedIndex();
|
||||||
|
|
||||||
w = MID(1, w, 65535);
|
w = MID(1, w, 65535);
|
||||||
h = MID(1, h, 65535);
|
h = MID(1, h, 65535);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user