mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 12:39:57 +00:00
Remove the ScreenShot command.
This commit is contained in:
parent
94f85a2a34
commit
ab333ff02b
@ -15,7 +15,6 @@
|
|||||||
<key command="CloseFile" shortcut="Ctrl+W" />
|
<key command="CloseFile" shortcut="Ctrl+W" />
|
||||||
<key command="CloseAllFiles" shortcut="Ctrl+Shift+W" />
|
<key command="CloseAllFiles" shortcut="Ctrl+Shift+W" />
|
||||||
<key command="DeveloperConsole" shortcut="F11" />
|
<key command="DeveloperConsole" shortcut="F11" />
|
||||||
<key command="ScreenShot" shortcut="F12" />
|
|
||||||
<key command="Exit" shortcut="Ctrl+Q" />
|
<key command="Exit" shortcut="Ctrl+Q" />
|
||||||
<key command="Exit" shortcut="Alt+F4" />
|
<key command="Exit" shortcut="Alt+F4" />
|
||||||
<key command="Cancel" shortcut="Esc" />
|
<key command="Cancel" shortcut="Esc" />
|
||||||
@ -346,7 +345,6 @@
|
|||||||
<item command="Preview" text="Previe&w" />
|
<item command="Preview" text="Previe&w" />
|
||||||
<separator />
|
<separator />
|
||||||
<item command="Refresh" text="&Refresh && Reload Skin" />
|
<item command="Refresh" text="&Refresh && Reload Skin" />
|
||||||
<item command="ScreenShot" text="&Screen Shot" />
|
|
||||||
</menu>
|
</menu>
|
||||||
<menu text="&Help">
|
<menu text="&Help">
|
||||||
<item command="Launch" text="Quick &Reference">
|
<item command="Launch" text="Quick &Reference">
|
||||||
|
@ -180,7 +180,6 @@ add_library(aseprite-library
|
|||||||
commands/cmd_rotate_canvas.cpp
|
commands/cmd_rotate_canvas.cpp
|
||||||
commands/cmd_save_file.cpp
|
commands/cmd_save_file.cpp
|
||||||
commands/cmd_save_mask.cpp
|
commands/cmd_save_mask.cpp
|
||||||
commands/cmd_screen_shot.cpp
|
|
||||||
commands/cmd_select_file.cpp
|
commands/cmd_select_file.cpp
|
||||||
commands/cmd_sprite_editor.cpp
|
commands/cmd_sprite_editor.cpp
|
||||||
commands/cmd_sprite_properties.cpp
|
commands/cmd_sprite_properties.cpp
|
||||||
|
@ -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;
|
|
||||||
}
|
|
@ -93,7 +93,6 @@ FOR_EACH_COMMAND(SaveFile)
|
|||||||
FOR_EACH_COMMAND(SaveFileAs)
|
FOR_EACH_COMMAND(SaveFileAs)
|
||||||
FOR_EACH_COMMAND(SaveFileCopyAs)
|
FOR_EACH_COMMAND(SaveFileCopyAs)
|
||||||
FOR_EACH_COMMAND(SaveMask)
|
FOR_EACH_COMMAND(SaveMask)
|
||||||
FOR_EACH_COMMAND(ScreenShot)
|
|
||||||
FOR_EACH_COMMAND(SelectFile)
|
FOR_EACH_COMMAND(SelectFile)
|
||||||
FOR_EACH_COMMAND(ShowGrid)
|
FOR_EACH_COMMAND(ShowGrid)
|
||||||
FOR_EACH_COMMAND(SnapToGrid)
|
FOR_EACH_COMMAND(SnapToGrid)
|
||||||
|
@ -1255,29 +1255,22 @@ static bool manager_msg_proc(JWidget widget, Message* msg)
|
|||||||
case Shortcut_ExecuteCommand: {
|
case Shortcut_ExecuteCommand: {
|
||||||
Command* command = shortcut->command;
|
Command* command = shortcut->command;
|
||||||
|
|
||||||
// The screen shot is available in everywhere
|
// Commands are executed only when the main window is
|
||||||
if (strcmp(command->short_name(), CommandId::ScreenShot) == 0) {
|
// the current window running at foreground.
|
||||||
UIContext::instance()->executeCommand(command, shortcut->params);
|
JLink link;
|
||||||
return true;
|
JI_LIST_FOR_EACH(widget->children, link) {
|
||||||
}
|
Frame* child = reinterpret_cast<Frame*>(link->data);
|
||||||
// All other keys are only available in the main-window
|
|
||||||
else {
|
|
||||||
JLink link;
|
|
||||||
|
|
||||||
JI_LIST_FOR_EACH(widget->children, link) {
|
// There are a foreground window executing?
|
||||||
Frame* child = reinterpret_cast<Frame*>(link->data);
|
if (child->is_foreground()) {
|
||||||
|
break;
|
||||||
// There are a foreground window executing?
|
}
|
||||||
if (child->is_foreground()) {
|
// Is it the desktop and the top-window=
|
||||||
break;
|
else if (child->is_desktop() && child == app_get_top_window()) {
|
||||||
}
|
// OK, so we can execute the command represented
|
||||||
// Is it the desktop and the top-window=
|
// by the pressed-key in the message...
|
||||||
else if (child->is_desktop() && child == app_get_top_window()) {
|
UIContext::instance()->executeCommand(command, shortcut->params);
|
||||||
// OK, so we can execute the command represented
|
return true;
|
||||||
// by the pressed-key in the message...
|
|
||||||
UIContext::instance()->executeCommand(command, shortcut->params);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user