Convert jalert to Alert C++ class.

This commit is contained in:
David Capello 2011-01-27 17:21:33 -03:00
parent f558666056
commit 5a9d991219
18 changed files with 157 additions and 173 deletions

View File

@ -124,8 +124,8 @@ try_again:;
// see if the sprite has changes // see if the sprite has changes
while (sprite->isModified()) { while (sprite->isModified()) {
// ask what want to do the user with the changes in the sprite // ask what want to do the user with the changes in the sprite
int ret = jalert("Warning<<Saving changes in:<<%s||&Save||Do&n't Save||&Cancel", int ret = Alert::show("Warning<<Saving changes in:<<%s||&Save||Do&n't Save||&Cancel",
get_filename(sprite->getFilename())); get_filename(sprite->getFilename()));
if (ret == 1) { if (ret == 1) {
// "save": save the changes // "save": save the changes

View File

@ -52,7 +52,7 @@ void ExitCommand::onExecute(Context* context)
while (sprite) { while (sprite) {
// check if this sprite is modified // check if this sprite is modified
if (sprite->isModified()) { if (sprite->isModified()) {
if (jalert("Warning<<There are sprites with changes.<<Do you want quit anyway?||&Yes||&No") != 1) { if (Alert::show("Warning<<There are sprites with changes.<<Do you want quit anyway?||&Yes||&No") != 1) {
return; return;
} }
break; break;

View File

@ -118,9 +118,9 @@ void FramePropertiesCommand::onExecute(Context* context)
int num = strtol(frlen->getText(), NULL, 10); int num = strtol(frlen->getText(), NULL, 10);
if (m_frame == ALL_FRAMES) { if (m_frame == ALL_FRAMES) {
if (jalert("Warning" if (Alert::show("Warning"
"<<Do you want to change the duration of all frames?" "<<Do you want to change the duration of all frames?"
"||&Yes||&No") == 1) { "||&Yes||&No") == 1) {
SpriteWriter sprite_writer(sprite); SpriteWriter sprite_writer(sprite);
Undoable undoable(sprite_writer, "Constant Frame-Rate"); Undoable undoable(sprite_writer, "Constant Frame-Rate");
undoable.setConstantFrameRate(num); undoable.setConstantFrameRate(num);

View File

@ -57,7 +57,7 @@ struct OpenFileData
Monitor *monitor; Monitor *monitor;
FileOp *fop; FileOp *fop;
Progress *progress; Progress *progress;
Frame* alert_window; AlertPtr alert_window;
}; };
/** /**
@ -162,9 +162,9 @@ void OpenFileCommand::onExecute(Context* context)
data->fop = fop; data->fop = fop;
data->progress = app_get_statusbar()->addProgress(); data->progress = app_get_statusbar()->addProgress();
data->alert_window = jalert_new(PACKAGE data->alert_window = Alert::create(PACKAGE
"<<Loading file:<<%s||&Cancel", "<<Loading file:<<%s||&Cancel",
get_filename(m_filename.c_str())); get_filename(m_filename.c_str()));
// Add a monitor to check the loading (FileOp) progress // Add a monitor to check the loading (FileOp) progress
data->monitor = add_gui_monitor(monitor_openfile_bg, data->monitor = add_gui_monitor(monitor_openfile_bg,
@ -196,7 +196,6 @@ void OpenFileCommand::onExecute(Context* context)
unrecent = true; unrecent = true;
delete data->progress; delete data->progress;
jwidget_free(data->alert_window);
fop_free(fop); fop_free(fop);
delete data; delete data;
} }

View File

@ -419,7 +419,7 @@ static void load_command(JWidget widget)
if (!filename.empty()) { if (!filename.empty()) {
palette = Palette::load(filename.c_str()); palette = Palette::load(filename.c_str());
if (!palette) { if (!palette) {
jalert("Error<<Loading palette file||&Close"); Alert::show("Error<<Loading palette file||&Close");
} }
else { else {
set_new_palette(palette, "Load Palette"); set_new_palette(palette, "Load Palette");
@ -437,8 +437,8 @@ static void save_command(JWidget widget)
filename = ase_file_selector("Save Palette", "", "png,pcx,bmp,tga,col"); filename = ase_file_selector("Save Palette", "", "png,pcx,bmp,tga,col");
if (!filename.empty()) { if (!filename.empty()) {
if (exists(filename.c_str())) { if (exists(filename.c_str())) {
ret = jalert("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel", ret = Alert::show("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel",
get_filename(filename.c_str())); get_filename(filename.c_str()));
if (ret == 2) if (ret == 2)
goto again; goto again;
@ -448,7 +448,7 @@ static void save_command(JWidget widget)
Palette* palette = get_current_palette(); Palette* palette = get_current_palette();
if (!palette->save(filename.c_str())) { if (!palette->save(filename.c_str())) {
jalert("Error<<Saving palette file||&Close"); Alert::show("Error<<Saving palette file||&Close");
} }
} }
} }
@ -503,7 +503,7 @@ static bool sort_by_criteria(Palette* palette, int from, int to, JList selected_
static void sort_command(JWidget widget) static void sort_command(JWidget widget)
{ {
if (jalert("ASE Beta<<Sort command is not available in this beta version.||&OK")) // TODO remove this if (Alert::show("ASE Beta<<Sort command is not available in this beta version.||&OK")) // TODO remove this
return; return;
SortDlgData data; SortDlgData data;
@ -786,12 +786,12 @@ static void quantize_command(JWidget widget)
const CurrentSpriteReader& sprite(UIContext::instance()); const CurrentSpriteReader& sprite(UIContext::instance());
if (sprite == NULL) { if (sprite == NULL) {
jalert("Error<<There is no sprite selected to quantize.||&OK"); Alert::show("Error<<There is no sprite selected to quantize.||&OK");
return; return;
} }
if (sprite->getImgType() != IMAGE_RGB) { if (sprite->getImgType() != IMAGE_RGB) {
jalert("Error<<You can use this command only for RGB sprites||&OK"); Alert::show("Error<<You can use this command only for RGB sprites||&OK");
return; return;
} }

View File

@ -33,13 +33,13 @@
#include "sprite_wrappers.h" #include "sprite_wrappers.h"
#include "widgets/statebar.h" #include "widgets/statebar.h"
typedef struct SaveFileData struct SaveFileData
{ {
Monitor *monitor; Monitor *monitor;
FileOp *fop; FileOp *fop;
Progress *progress; Progress *progress;
Frame* alert_window; AlertPtr alert_window;
} SaveFileData; };
/** /**
* Thread to do the hard work: save the file to the disk. * Thread to do the hard work: save the file to the disk.
@ -102,9 +102,9 @@ static void save_sprite_in_background(Sprite* sprite, bool mark_as_saved)
data->fop = fop; data->fop = fop;
data->progress = app_get_statusbar()->addProgress(); data->progress = app_get_statusbar()->addProgress();
data->alert_window = jalert_new(PACKAGE data->alert_window = Alert::create(PACKAGE
"<<Saving file:<<%s||&Cancel", "<<Saving file:<<%s||&Cancel",
get_filename(sprite->getFilename())); get_filename(sprite->getFilename()));
/* add a monitor to check the saving (FileOp) progress */ /* add a monitor to check the saving (FileOp) progress */
data->monitor = add_gui_monitor(monitor_savefile_bg, data->monitor = add_gui_monitor(monitor_savefile_bg,
@ -137,7 +137,6 @@ static void save_sprite_in_background(Sprite* sprite, bool mark_as_saved)
} }
delete data->progress; delete data->progress;
jwidget_free(data->alert_window);
fop_free(fop); fop_free(fop);
delete data; delete data;
} }
@ -164,8 +163,8 @@ static void save_as_dialog(Sprite* sprite, const char* dlg_title, bool mark_as_s
/* does the file exist? */ /* does the file exist? */
if (exists(filename.c_str())) { if (exists(filename.c_str())) {
/* ask if the user wants overwrite the file? */ /* ask if the user wants overwrite the file? */
ret = jalert("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel", ret = Alert::show("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel",
get_filename(filename.c_str())); get_filename(filename.c_str()));
} }
else else
break; break;

View File

@ -73,8 +73,8 @@ void SaveMaskCommand::onExecute(Context* context)
/* does the file exist? */ /* does the file exist? */
if (exists(filename.c_str())) { if (exists(filename.c_str())) {
/* ask if the user wants overwrite the file? */ /* ask if the user wants overwrite the file? */
ret = jalert("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel", ret = Alert::show("Warning<<File exists, overwrite it?<<%s||&Yes||&No||&Cancel",
get_filename(filename.c_str())); get_filename(filename.c_str()));
} }
else else
break; break;
@ -90,7 +90,7 @@ void SaveMaskCommand::onExecute(Context* context)
} }
if (save_msk_file(sprite->getMask(), filename.c_str()) != 0) if (save_msk_file(sprite->getMask(), filename.c_str()) != 0)
jalert("Error<<Error saving .msk file<<%s||&Close", filename.c_str()); Alert::show("Error<<Error saving .msk file<<%s||&Close", filename.c_str());
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View File

@ -50,7 +50,7 @@ struct ThreadData
bool cancelled : 1; /* was the effect cancelled by the user? */ bool cancelled : 1; /* was the effect cancelled by the user? */
Monitor* monitor; /* monitor to update the progress-bar */ Monitor* monitor; /* monitor to update the progress-bar */
Progress* progress; /* the progress-bar */ Progress* progress; /* the progress-bar */
Frame* alert_window; /* alert for the user to cancel the AlertPtr alert_window; /* alert for the user to cancel the
effect-progress if he wants */ effect-progress if he wants */
}; };
@ -157,8 +157,8 @@ void effect_apply_to_target_with_progressbar(Effect* effect)
data->done = false; data->done = false;
data->cancelled = false; data->cancelled = false;
data->progress = app_get_statusbar()->addProgress(); data->progress = app_get_statusbar()->addProgress();
data->alert_window = jalert_new(PACKAGE data->alert_window = Alert::create(PACKAGE
"<<Applying effect...||&Cancel"); "<<Applying effect...||&Cancel");
data->monitor = add_gui_monitor(monitor_effect_bg, data->monitor = add_gui_monitor(monitor_effect_bg,
monitor_free, data); monitor_free, data);
@ -180,6 +180,5 @@ void effect_apply_to_target_with_progressbar(Effect* effect)
thread.join(); thread.join();
delete data->progress; delete data->progress;
jwidget_free(data->alert_window);
delete data; delete data;
} }

View File

@ -603,7 +603,7 @@ static bool anieditor_msg_proc(JWidget widget, JMessage msg)
anieditor_regenerate_layers(widget); anieditor_regenerate_layers(widget);
} }
else { else {
jalert(PACKAGE "<<You can't move the `Background' layer.||&OK"); Alert::show(PACKAGE "<<You can't move the `Background' layer.||&OK");
} }
} }
} }

View File

@ -190,12 +190,12 @@ FileOp *fop_to_load_sprite(const char *filename, int flags)
App::instance()->isGui()) { App::instance()->isGui()) {
/* really want load all files? */ /* really want load all files? */
if ((fop->seq.filename_list.size() > 1) && if ((fop->seq.filename_list.size() > 1) &&
(jalert("Notice" (Alert::show("Notice"
"<<Possible animation with:" "<<Possible animation with:"
"<<%s" "<<%s"
"<<Load the sequence of bitmaps?" "<<Load the sequence of bitmaps?"
"||&Agree||&Skip", "||&Agree||&Skip",
get_filename(filename)) != 1)) { get_filename(filename)) != 1)) {
/* if the user replies "Skip", we need just one file name (the /* if the user replies "Skip", we need just one file name (the
first one) */ first one) */
@ -338,14 +338,14 @@ FileOp *fop_to_save_sprite(Sprite *sprite)
int ret; int ret;
if (fatal) if (fatal)
ret = jalert("Error<<File format \"%s\" doesn't support:%s" ret = Alert::show("Error<<File format \"%s\" doesn't support:%s"
"||&Close", "||&Close",
fop->format->name(), buf); fop->format->name(), buf);
else else
ret = jalert("Warning<<File format \"%s\" doesn't support:%s" ret = Alert::show("Warning<<File format \"%s\" doesn't support:%s"
"<<Do you want continue?" "<<Do you want continue?"
"||&Yes||&No", "||&Yes||&No",
fop->format->name(), buf); fop->format->name(), buf);
/* operation can't be done (by fatal error) or the user cancel /* operation can't be done (by fatal error) or the user cancel
the operation */ the operation */

View File

@ -37,92 +37,72 @@
#include "base/bind.h" #include "base/bind.h"
#include "gui/jinete.h" #include "gui/jinete.h"
static Frame* create_alert(char *buf, JList *labels, JList *buttons); Alert::Alert()
: Frame(false, "")
/* creates a new alert-box
the buttons will have names like: button-1, button-2, etc.
*/
Frame* jalert_new(const char *format, ...)
{ {
JList labels, buttons; // Do nothing
char buf[4096]; }
Frame* window;
AlertPtr Alert::create(const char* format, ...)
{
char buf[4096]; // TODO warning buffer overflow
va_list ap; va_list ap;
/* process arguments */ // Process arguments
va_start(ap, format); va_start(ap, format);
vsprintf(buf, format, ap); vsprintf(buf, format, ap);
va_end(ap); va_end(ap);
/* create the alert window */ // Create the alert window
labels = jlist_new(); std::vector<Widget*> labels;
buttons = jlist_new(); std::vector<Widget*> buttons;
window = create_alert(buf, &labels, &buttons); AlertPtr window(new Alert());
window->processString(buf, labels, buttons);
jlist_free(labels);
jlist_free(buttons);
/* and return it */
return window; return window;
} }
int jalert(const char *format, ...) // static
int Alert::show(const char* format, ...)
{ {
JList labels, buttons; char buf[4096]; // TODO warning buffer overflow
Frame* window;
Widget* killer;
char buf[4096];
int c, ret = 0;
JLink link;
va_list ap; va_list ap;
/* process arguments */ // Process arguments
va_start(ap, format); va_start(ap, format);
vsprintf(buf, format, ap); vsprintf(buf, format, ap);
va_end(ap); va_end(ap);
/* create the alert window */ // Create the alert window
labels = jlist_new(); std::vector<Widget*> labels;
buttons = jlist_new(); std::vector<Widget*> buttons;
window = create_alert(buf, &labels, &buttons); AlertPtr window(new Alert());
window->processString(buf, labels, buttons);
/* was created succefully? */ // Open it
if (window) { window->open_window_fg();
/* open it */
window->open_window_fg();
/* check the killer */ // Check the killer
killer = window->get_killer(); int ret = 0;
if (killer) { if (Widget* killer = window->get_killer()) {
c = 1; for (int i=0; i<(int)buttons.size(); ++i) {
JI_LIST_FOR_EACH(buttons, link) { if (killer == buttons[i]) {
if (killer == (JWidget)link->data) { ret = i+1;
ret = c; break;
break;
}
c++;
} }
} }
/* destroy the window */
jwidget_free(window);
} }
jlist_free(labels); // And return it
jlist_free(buttons);
/* and return it */
return ret; return ret;
} }
static Frame* create_alert(char *buf, JList *labels, JList *buttons) void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<Widget*>& buttons)
{ {
Box* box1, *box2, *box3, *box4, *box5; Box* box1, *box2, *box3, *box4, *box5;
Grid* grid; Grid* grid;
Frame* window = NULL;
bool title = true; bool title = true;
bool label = false; bool label = false;
bool separator = false; bool separator = false;
@ -130,9 +110,8 @@ static Frame* create_alert(char *buf, JList *labels, JList *buttons)
int align = 0; int align = 0;
char *beg; char *beg;
int c, chr; int c, chr;
JLink link;
/* process buffer */ // Process buffer
c = 0; c = 0;
beg = buf; beg = buf;
for (; ; c++) { for (; ; c++) {
@ -148,25 +127,25 @@ static Frame* create_alert(char *buf, JList *labels, JList *buttons)
buf[c] = 0; buf[c] = 0;
if (title) { if (title) {
window = new Frame(false, beg); setText(beg);
} }
else if (label) { else if (label) {
Label* label = new Label(beg); Label* label = new Label(beg);
label->setAlign(align); label->setAlign(align);
jlist_append(*labels, label); labels.push_back(label);
} }
else if (separator) { else if (separator) {
jlist_append(*labels, ji_separator_new(NULL, JI_HORIZONTAL)); labels.push_back(ji_separator_new(NULL, JI_HORIZONTAL));
} }
else if (button) { else if (button) {
char button_name[256]; char button_name[256];
Button* button_widget = new Button(beg); Button* button_widget = new Button(beg);
jwidget_set_min_size(button_widget, 60*jguiscale(), 0); jwidget_set_min_size(button_widget, 60*jguiscale(), 0);
jlist_append(*buttons, button_widget); buttons.push_back(button_widget);
usprintf(button_name, "button-%d", jlist_length(*buttons)); usprintf(button_name, "button-%d", buttons.size());
button_widget->setName(button_name); button_widget->setName(button_name);
button_widget->Click.connect(Bind<void>(&Frame::closeWindow, window, button_widget)); button_widget->Click.connect(Bind<void>(&Frame::closeWindow, this, button_widget));
} }
buf[c] = chr; buf[c] = chr;
@ -193,46 +172,42 @@ static Frame* create_alert(char *buf, JList *labels, JList *buttons)
} }
} }
if (window) { box1 = new Box(JI_VERTICAL);
box1 = new Box(JI_VERTICAL); box2 = new Box(JI_VERTICAL);
box2 = new Box(JI_VERTICAL); grid = new Grid(1, false);
grid = new Grid(1, false); box3 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
box3 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
/* to identify by the user */ // To identify by the user
box2->setName("labels"); box2->setName("labels");
box3->setName("buttons"); box3->setName("buttons");
/* pseudo separators (only to fill blank space) */ // Pseudo separators (only to fill blank space)
box4 = new Box(0); box4 = new Box(0);
box5 = new Box(0); box5 = new Box(0);
jwidget_expansive(box4, true); jwidget_expansive(box4, true);
jwidget_expansive(box5, true); jwidget_expansive(box5, true);
jwidget_noborders(box4); jwidget_noborders(box4);
jwidget_noborders(box5); jwidget_noborders(box5);
/* setup parent <-> children relationship */ // Setup parent <-> children relationship
jwidget_add_child(window, box1); jwidget_add_child(this, box1);
jwidget_add_child(box1, box4); /* filler */ jwidget_add_child(box1, box4); // Filler
jwidget_add_child(box1, box2); /* labels */ jwidget_add_child(box1, box2); // Labels
jwidget_add_child(box1, box5); /* filler */ jwidget_add_child(box1, box5); // Filler
jwidget_add_child(box1, grid); /* buttons */ jwidget_add_child(box1, grid); // Buttons
grid->addChildInCell(box3, 1, 1, JI_CENTER | JI_BOTTOM); grid->addChildInCell(box3, 1, 1, JI_CENTER | JI_BOTTOM);
JI_LIST_FOR_EACH(*labels, link) for (std::vector<Widget*>::iterator it = labels.begin(); it != labels.end(); ++it)
jwidget_add_child(box2, (JWidget)link->data); jwidget_add_child(box2, *it);
JI_LIST_FOR_EACH(*buttons, link) for (std::vector<Widget*>::iterator it = buttons.begin(); it != buttons.end(); ++it)
jwidget_add_child(box3, (JWidget)link->data); jwidget_add_child(box3, *it);
/* default button is the last one */ // Default button is the last one
if (jlist_last(*buttons)) if (!buttons.empty())
jwidget_magnetic((JWidget)jlist_last(*buttons)->data, true); jwidget_magnetic(buttons[buttons.size()-1], true);
}
return window;
} }

View File

@ -7,10 +7,23 @@
#ifndef GUI_ALERT_H_INCLUDED #ifndef GUI_ALERT_H_INCLUDED
#define GUI_ALERT_H_INCLUDED #define GUI_ALERT_H_INCLUDED
class Frame; #include "base/shared_ptr.h"
#include "gui/frame.h"
Frame* jalert_new(const char *format, ...); class Alert;
int jalert(const char *format, ...); typedef SharedPtr<Alert> AlertPtr;
class Alert : public Frame
{
public:
Alert();
static AlertPtr create(const char* format, ...);
static int show(const char* format, ...);
private:
void processString(char* buf, std::vector<Widget*>& labels, std::vector<Widget*>& buttons);
};
#endif #endif

View File

@ -35,7 +35,6 @@ Job::Job(const char* job_name)
m_thread = NULL; m_thread = NULL;
m_progress = NULL; m_progress = NULL;
m_monitor = NULL; m_monitor = NULL;
m_alert_window = NULL;
m_last_progress = 0.0f; m_last_progress = 0.0f;
m_done_flag = false; m_done_flag = false;
m_canceled_flag = false; m_canceled_flag = false;
@ -45,7 +44,7 @@ Job::Job(const char* job_name)
m_monitor = add_gui_monitor(&Job::monitor_proc, m_monitor = add_gui_monitor(&Job::monitor_proc,
&Job::monitor_free, &Job::monitor_free,
(void*)this); (void*)this);
m_alert_window = jalert_new("%s<<Working...||&Cancel", job_name); m_alert_window = Alert::create("%s<<Working...||&Cancel", job_name);
} }
Job::~Job() Job::~Job()
@ -72,9 +71,6 @@ Job::~Job()
if (m_mutex) if (m_mutex)
delete m_mutex; delete m_mutex;
if (m_alert_window)
jwidget_free(m_alert_window);
} }
void Job::startJob() void Job::startJob()

View File

@ -19,6 +19,8 @@
#ifndef CORE_JOB_H_INCLUDED #ifndef CORE_JOB_H_INCLUDED
#define CORE_JOB_H_INCLUDED #define CORE_JOB_H_INCLUDED
#include "gui/alert.h"
namespace base { class thread; } namespace base { class thread; }
class Frame; class Frame;
@ -71,7 +73,7 @@ private:
Monitor* m_monitor; Monitor* m_monitor;
Progress* m_progress; Progress* m_progress;
Mutex* m_mutex; Mutex* m_mutex;
Frame* m_alert_window; AlertPtr m_alert_window;
float m_last_progress; float m_last_progress;
bool m_done_flag; bool m_done_flag;
bool m_canceled_flag; bool m_canceled_flag;

View File

@ -22,7 +22,8 @@
#include "launcher.h" #include "launcher.h"
#if defined ALLEGRO_WINDOWS #if defined ALLEGRO_WINDOWS
#include <windows.h> #define BITMAP WINDOWS_BITMAP
#include <windows.h>
#endif #endif
void Launcher::openUrl(const std::string& url) void Launcher::openUrl(const std::string& url)
@ -50,5 +51,5 @@ void Launcher::openFile(const std::string& file)
#endif #endif
if (ret != 0) if (ret != 0)
jalert("Problem<<Cannot open:<<%s||&Close", file.c_str()); Alert::show("Problem<<Cannot open:<<%s||&Close", file.c_str());
} }

View File

@ -255,7 +255,7 @@ void set_sprite_in_more_reliable_editor(Sprite* sprite)
void split_editor(Editor* editor, int align) void split_editor(Editor* editor, int align)
{ {
if (count_parents(editor) > 10) { if (count_parents(editor) > 10) {
jalert("Error<<You cannot split this editor more||&Close"); Alert::show("Error<<You cannot split this editor more||&Close");
return; return;
} }

View File

@ -181,7 +181,7 @@ static void get_win32_clipboard_bitmap(Image*& image, Palette*& palette)
if (bi) { if (bi) {
if (bi->bmiHeader.biCompression != BI_RGB && if (bi->bmiHeader.biCompression != BI_RGB &&
bi->bmiHeader.biCompression != BI_BITFIELDS) { bi->bmiHeader.biCompression != BI_BITFIELDS) {
jalert("Error<<The current Windows clipboard format is not a bitmap.||&OK"); Alert::show("Error<<The current Windows clipboard format is not a bitmap.||&OK");
return; return;
} }

View File

@ -1099,12 +1099,12 @@ bool Editor::onProcessMessage(JMessage msg)
(m_sprite->getCurrentLayer()->getType() == GFXOBJ_LAYER_IMAGE)) { (m_sprite->getCurrentLayer()->getType() == GFXOBJ_LAYER_IMAGE)) {
// TODO you can move the `Background' with tiled mode // TODO you can move the `Background' with tiled mode
if (m_sprite->getCurrentLayer()->is_background()) { if (m_sprite->getCurrentLayer()->is_background()) {
jalert(PACKAGE Alert::show(PACKAGE
"<<You can't move the `Background' layer." "<<You can't move the `Background' layer."
"||&Close"); "||&Close");
} }
else if (!m_sprite->getCurrentLayer()->is_moveable()) { else if (!m_sprite->getCurrentLayer()->is_moveable()) {
jalert(PACKAGE "<<The layer movement is locked.||&Close"); Alert::show(PACKAGE "<<The layer movement is locked.||&Close");
} }
else { else {
bool click2 = get_config_bool("Options", "MoveClick2", FALSE); bool click2 = get_config_bool("Options", "MoveClick2", FALSE);
@ -1122,7 +1122,7 @@ bool Editor::onProcessMessage(JMessage msg)
Image* image = m_sprite->getCurrentImage(&x, &y, &opacity); Image* image = m_sprite->getCurrentImage(&x, &y, &opacity);
if (image) { if (image) {
if (!m_sprite->getCurrentLayer()->is_writable()) { if (!m_sprite->getCurrentLayer()->is_writable()) {
jalert(PACKAGE "<<The layer is locked.||&Close"); Alert::show(PACKAGE "<<The layer is locked.||&Close");
return true; return true;
} }
@ -2102,24 +2102,24 @@ IToolLoop* Editor::createToolLoopImpl(Context* context, JMessage msg)
Layer* layer = sprite->getCurrentLayer(); Layer* layer = sprite->getCurrentLayer();
if (!layer) { if (!layer) {
jalert(PACKAGE "<<The current sprite does not have any layer.||&Close"); Alert::show(PACKAGE "<<The current sprite does not have any layer.||&Close");
return NULL; return NULL;
} }
// if the active layer is not visible // if the active layer is not visible
if (!layer->is_readable()) { if (!layer->is_readable()) {
jalert(PACKAGE Alert::show(PACKAGE
"<<The current layer is hidden," "<<The current layer is hidden,"
"<<make it visible and try again" "<<make it visible and try again"
"||&Close"); "||&Close");
return NULL; return NULL;
} }
// if the active layer is read-only // if the active layer is read-only
else if (!layer->is_writable()) { else if (!layer->is_writable()) {
jalert(PACKAGE Alert::show(PACKAGE
"<<The current layer is locked," "<<The current layer is locked,"
"<<unlock it and try again" "<<unlock it and try again"
"||&Close"); "||&Close");
return NULL; return NULL;
} }
@ -2129,10 +2129,10 @@ IToolLoop* Editor::createToolLoopImpl(Context* context, JMessage msg)
Color bg = colorbar->getBgColor(); Color bg = colorbar->getBgColor();
if (!fg.isValid() || !bg.isValid()) { if (!fg.isValid() || !bg.isValid()) {
jalert(PACKAGE Alert::show(PACKAGE
"<<The current selected foreground and/or background color" "<<The current selected foreground and/or background color"
"<<is out of range. Select valid colors in the color-bar." "<<is out of range. Select valid colors in the color-bar."
"||&Close"); "||&Close");
return NULL; return NULL;
} }