Remove the ScreenShot command.

This commit is contained in:
David Capello 2012-02-12 10:55:33 -03:00
parent 94f85a2a34
commit ab333ff02b
5 changed files with 15 additions and 164 deletions

View File

@ -15,7 +15,6 @@
<key command="CloseFile" shortcut="Ctrl+W" />
<key command="CloseAllFiles" shortcut="Ctrl+Shift+W" />
<key command="DeveloperConsole" shortcut="F11" />
<key command="ScreenShot" shortcut="F12" />
<key command="Exit" shortcut="Ctrl+Q" />
<key command="Exit" shortcut="Alt+F4" />
<key command="Cancel" shortcut="Esc" />
@ -346,7 +345,6 @@
<item command="Preview" text="Previe&amp;w" />
<separator />
<item command="Refresh" text="&amp;Refresh &amp;&amp; Reload Skin" />
<item command="ScreenShot" text="&amp;Screen Shot" />
</menu>
<menu text="&amp;Help">
<item command="Launch" text="Quick &amp;Reference">

View File

@ -180,7 +180,6 @@ add_library(aseprite-library
commands/cmd_rotate_canvas.cpp
commands/cmd_save_file.cpp
commands/cmd_save_mask.cpp
commands/cmd_screen_shot.cpp
commands/cmd_select_file.cpp
commands/cmd_sprite_editor.cpp
commands/cmd_sprite_properties.cpp

View File

@ -1,138 +0,0 @@
/* ASEPRITE
* Copyright (C) 2001-2012 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <allegro.h>
#include "base/unique_ptr.h"
#include "commands/command.h"
#include "document.h"
#include "file/file.h"
#include "gui/system.h"
#include "raster/raster.h"
#include "util/misc.h"
//////////////////////////////////////////////////////////////////////
// screen_shot
class ScreenShotCommand : public Command
{
public:
ScreenShotCommand();
Command* clone() { return new ScreenShotCommand(*this); }
protected:
void onExecute(Context* context);
};
ScreenShotCommand::ScreenShotCommand()
: Command("ScreenShot",
"Screen Shot",
CmdUIOnlyFlag)
{
}
void ScreenShotCommand::onExecute(Context* context)
{
int c, old_flag;
char buf[512];
PALETTE rgbpal;
BITMAP *bmp;
/* save the active flag which indicate if the mouse is freeze or not */
old_flag = freeze_mouse_flag;
/* freeze the mouse obligatory */
freeze_mouse_flag = true;
/* get the active palette color */
get_palette(rgbpal);
/* get a file name for the capture */
for (c=0; c<10000; c++) {
usprintf(buf, "shot%04d.%s", c, "png");
if (!exists(buf))
break;
}
if (ji_screen != screen)
jmouse_draw_cursor();
/* save in a bitmap the visible screen portion */
bmp = create_sub_bitmap(ji_screen, 0, 0, JI_SCREEN_W, JI_SCREEN_H);
/* creates a sprite with one layer, one image to save the bitmap as a PNG */
{
int imgtype = bitmap_color_depth(bmp) == 8 ? IMAGE_INDEXED: IMAGE_RGB;
UniquePtr<Document> document(Document::createBasicDocument(imgtype, bmp->w, bmp->h, 256));
Sprite* sprite = document->getSprite();
Image* image = sprite->getCurrentImage();
int x, y, r, g, b;
{
UniquePtr<Palette> pal(new Palette(0, 256));
pal->fromAllegro(rgbpal);
sprite->setPalette(pal, true);
}
// Convert Allegro "BITMAP" to ASEPRITE "Image".
if (imgtype == IMAGE_RGB) {
uint32_t* address;
for (y=0; y<image->h; ++y) {
address = (uint32_t*)image->line[y];
for (x=0; x<image->w; ++x) {
c = getpixel(bmp, x, y);
r = getr(c);
g = getg(c);
b = getb(c);
*(address++) = _rgba(r, g, b, 255);
}
}
}
else if (imgtype == IMAGE_INDEXED) {
uint8_t* address;
for (y=0; y<image->h; ++y) {
address = (uint8_t*)image->line[y];
for (x=0; x<image->w; ++x) {
*(address++) = getpixel(bmp, x, y);
}
}
}
// Save the document.
document->setFilename(buf);
save_document(document);
}
// Destroy the bitmap.
destroy_bitmap(bmp);
// Restore the freeze flag by the previous value.
freeze_mouse_flag = old_flag;
}
//////////////////////////////////////////////////////////////////////
// CommandFactory
Command* CommandFactory::createScreenShotCommand()
{
return new ScreenShotCommand;
}

View File

@ -93,7 +93,6 @@ FOR_EACH_COMMAND(SaveFile)
FOR_EACH_COMMAND(SaveFileAs)
FOR_EACH_COMMAND(SaveFileCopyAs)
FOR_EACH_COMMAND(SaveMask)
FOR_EACH_COMMAND(ScreenShot)
FOR_EACH_COMMAND(SelectFile)
FOR_EACH_COMMAND(ShowGrid)
FOR_EACH_COMMAND(SnapToGrid)

View File

@ -1255,29 +1255,22 @@ static bool manager_msg_proc(JWidget widget, Message* msg)
case Shortcut_ExecuteCommand: {
Command* command = shortcut->command;
// The screen shot is available in everywhere
if (strcmp(command->short_name(), CommandId::ScreenShot) == 0) {
UIContext::instance()->executeCommand(command, shortcut->params);
return true;
}
// All other keys are only available in the main-window
else {
JLink link;
// Commands are executed only when the main window is
// the current window running at foreground.
JLink link;
JI_LIST_FOR_EACH(widget->children, link) {
Frame* child = reinterpret_cast<Frame*>(link->data);
JI_LIST_FOR_EACH(widget->children, link) {
Frame* child = reinterpret_cast<Frame*>(link->data);
// There are a foreground window executing?
if (child->is_foreground()) {
break;
}
// Is it the desktop and the top-window=
else if (child->is_desktop() && child == app_get_top_window()) {
// OK, so we can execute the command represented
// by the pressed-key in the message...
UIContext::instance()->executeCommand(command, shortcut->params);
return true;
}
// There are a foreground window executing?
if (child->is_foreground()) {
break;
}
// Is it the desktop and the top-window=
else if (child->is_desktop() && child == app_get_top_window()) {
// OK, so we can execute the command represented
// by the pressed-key in the message...
UIContext::instance()->executeCommand(command, shortcut->params);
return true;
}
}
break;