mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 13:20:28 +00:00
Converted editor widget in a C++ class (Editor class derived from Widget).
This commit is contained in:
parent
991488e59b
commit
6e93dfe4ea
@ -192,7 +192,8 @@ int App::run()
|
||||
{
|
||||
/* initialize GUI interface */
|
||||
if (ase_mode & MODE_GUI) {
|
||||
Widget* view, *editor;
|
||||
Widget* view;
|
||||
Editor* editor;
|
||||
|
||||
PRINTF("GUI mode\n");
|
||||
|
||||
@ -374,7 +375,7 @@ App::~App()
|
||||
// finalize modules, configuration and core
|
||||
modules_exit();
|
||||
delete m_pimpl;
|
||||
editor_cursor_exit();
|
||||
Editor::editor_cursor_exit();
|
||||
boundary_exit();
|
||||
|
||||
gfxobj_exit();
|
||||
|
@ -385,7 +385,7 @@ static bool set_grid_button_select_hook(JWidget widget, void *data)
|
||||
static bool cursor_button_change_hook(JWidget widget, void *data)
|
||||
{
|
||||
set_cursor_color(colorbutton_get_color(widget));
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool onionskin_check_change_hook(JWidget widget, void *data)
|
||||
|
@ -67,25 +67,22 @@ void EyedropperCommand::load_params(Params* params)
|
||||
|
||||
void EyedropperCommand::execute(Context* context)
|
||||
{
|
||||
JWidget widget;
|
||||
Editor *editor;
|
||||
color_t color;
|
||||
int x, y;
|
||||
|
||||
widget = jmanager_get_mouse();
|
||||
JWidget widget = jmanager_get_mouse();
|
||||
if (!widget || widget->type != editor_type())
|
||||
return;
|
||||
|
||||
editor = editor_data(widget);
|
||||
if (!editor->sprite)
|
||||
Editor* editor = static_cast<Editor*>(widget);
|
||||
Sprite* sprite = editor->editor_get_sprite();
|
||||
if (!sprite)
|
||||
return;
|
||||
|
||||
/* pixel position to get */
|
||||
screen_to_editor(widget, jmouse_x(0), jmouse_y(0), &x, &y);
|
||||
// pixel position to get
|
||||
int x, y;
|
||||
editor->screen_to_editor(jmouse_x(0), jmouse_y(0), &x, &y);
|
||||
|
||||
/* get the color from the image */
|
||||
color = color_from_image(editor->sprite->imgtype,
|
||||
sprite_getpixel(editor->sprite, x, y));
|
||||
// get the color from the image
|
||||
color_t color = color_from_image(sprite->imgtype,
|
||||
sprite_getpixel(sprite, x, y));
|
||||
|
||||
if (color_type(color) != COLOR_TYPE_MASK) {
|
||||
// TODO replace the color in the "context", not directly from the color-bar
|
||||
|
@ -58,7 +58,7 @@ void GotoFirstFrameCommand::execute(Context* context)
|
||||
sprite->frame = 0;
|
||||
|
||||
update_screen_for_sprite(sprite);
|
||||
editor_update_statusbar_for_standby(current_editor);
|
||||
current_editor->editor_update_statusbar_for_standby();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -100,7 +100,7 @@ void GotoPreviousFrameCommand::execute(Context* context)
|
||||
sprite->frame = sprite->frames-1;
|
||||
|
||||
update_screen_for_sprite(sprite);
|
||||
editor_update_statusbar_for_standby(current_editor);
|
||||
current_editor->editor_update_statusbar_for_standby();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -142,7 +142,7 @@ void GotoNextFrameCommand::execute(Context* context)
|
||||
sprite->frame = 0;
|
||||
|
||||
update_screen_for_sprite(sprite);
|
||||
editor_update_statusbar_for_standby(current_editor);
|
||||
current_editor->editor_update_statusbar_for_standby();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@ -180,7 +180,7 @@ void GotoLastFrameCommand::execute(Context* context)
|
||||
sprite->frame = sprite->frames-1;
|
||||
|
||||
update_screen_for_sprite(sprite);
|
||||
editor_update_statusbar_for_standby(current_editor);
|
||||
current_editor->editor_update_statusbar_for_standby();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -69,7 +69,7 @@ void GotoPreviousLayerCommand::execute(Context* context)
|
||||
sprite->layer = sprite_index2layer(sprite, i);
|
||||
|
||||
update_screen_for_sprite(sprite);
|
||||
editor_update_statusbar_for_standby(current_editor);
|
||||
current_editor->editor_update_statusbar_for_standby();
|
||||
|
||||
statusbar_show_tip(app_get_statusbar(), 1000,
|
||||
_("Layer `%s' selected"),
|
||||
@ -117,7 +117,7 @@ void GotoNextLayerCommand::execute(Context* context)
|
||||
sprite->layer = sprite_index2layer(sprite, i);
|
||||
|
||||
update_screen_for_sprite(sprite);
|
||||
editor_update_statusbar_for_standby(current_editor);
|
||||
current_editor->editor_update_statusbar_for_standby();
|
||||
|
||||
statusbar_show_tip(app_get_statusbar(), 1000,
|
||||
_("Layer `%s' selected"),
|
||||
|
@ -109,7 +109,7 @@ void PlayAnimationCommand::execute(Context* context)
|
||||
oldpal = newpal;
|
||||
}
|
||||
|
||||
editor_draw_sprite_safe(current_editor, 0, 0, sprite->w, sprite->h);
|
||||
current_editor->editor_draw_sprite_safe(0, 0, sprite->w, sprite->h);
|
||||
|
||||
do {
|
||||
poll_mouse();
|
||||
|
@ -75,12 +75,11 @@ bool PreviewCommand::enabled(Context* context)
|
||||
*/
|
||||
void PreviewCommand::preview_sprite(Context* context, int flags)
|
||||
{
|
||||
JWidget widget = current_editor;
|
||||
Editor* editor = current_editor;
|
||||
|
||||
if (widget && editor_get_sprite(widget)) {
|
||||
Editor *editor = editor_data(widget);
|
||||
Sprite *sprite = editor_get_sprite(widget);
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
if (editor && editor->editor_get_sprite()) {
|
||||
Sprite *sprite = editor->editor_get_sprite();
|
||||
JWidget view = jwidget_get_view(editor);
|
||||
int old_mouse_x, old_mouse_y;
|
||||
int scroll_x, scroll_y;
|
||||
int u, v, x, y, w, h;
|
||||
@ -131,11 +130,11 @@ void PreviewCommand::preview_sprite(Context* context, int flags)
|
||||
else
|
||||
bg_color = makecol(128, 128, 128);
|
||||
|
||||
shiftx = - scroll_x + vp->x1 + editor->offset_x;
|
||||
shifty = - scroll_y + vp->y1 + editor->offset_y;
|
||||
shiftx = - scroll_x + vp->x1 + editor->editor_get_offset_x();
|
||||
shifty = - scroll_y + vp->y1 + editor->editor_get_offset_y();
|
||||
|
||||
w = sprite->w << editor->zoom;
|
||||
h = sprite->h << editor->zoom;
|
||||
w = sprite->w << editor->editor_get_zoom();
|
||||
h = sprite->h << editor->editor_get_zoom();
|
||||
|
||||
redraw = TRUE;
|
||||
do {
|
||||
@ -185,7 +184,7 @@ void PreviewCommand::preview_sprite(Context* context, int flags)
|
||||
clear_to_color(ji_screen, bg_color);
|
||||
}
|
||||
|
||||
if (!editor->zoom) {
|
||||
if (!editor->editor_get_zoom()) {
|
||||
/* in the center */
|
||||
if (!(flags & PREVIEW_TILED))
|
||||
draw_sprite(ji_screen, bmp, x, y);
|
||||
|
@ -174,13 +174,13 @@ void effect_begin_for_preview(Effect *effect)
|
||||
effect->mask = effect->preview_mask;
|
||||
|
||||
{
|
||||
JWidget editor = current_editor;
|
||||
Editor* editor = current_editor;
|
||||
JRect vp = jview_get_viewport_position(jwidget_get_view(editor));
|
||||
int x1, y1, x2, y2;
|
||||
int x, y, w, h;
|
||||
|
||||
screen_to_editor(editor, vp->x1, vp->y1, &x1, &y1);
|
||||
screen_to_editor(editor, vp->x2-1, vp->y2-1, &x2, &y2);
|
||||
editor->screen_to_editor(vp->x1, vp->y1, &x1, &y1);
|
||||
editor->screen_to_editor(vp->x2-1, vp->y2-1, &x2, &y2);
|
||||
|
||||
jrect_free(vp);
|
||||
|
||||
@ -271,17 +271,15 @@ void effect_flush(Effect *effect)
|
||||
if (effect->row >= 0) {
|
||||
JRegion reg1, reg2;
|
||||
struct jrect rect;
|
||||
JWidget editor;
|
||||
Editor* editor = current_editor;
|
||||
|
||||
editor = current_editor;
|
||||
reg1 = jregion_new(NULL, 0);
|
||||
|
||||
editor_to_screen(editor,
|
||||
effect->x+effect->offset_x,
|
||||
effect->y+effect->offset_y+effect->row-1,
|
||||
&rect.x1, &rect.y1);
|
||||
rect.x2 = rect.x1 + (effect->w << editor_data(editor)->zoom);
|
||||
rect.y2 = rect.y1 + (1 << editor_data(editor)->zoom);
|
||||
editor->editor_to_screen(effect->x+effect->offset_x,
|
||||
effect->y+effect->offset_y+effect->row-1,
|
||||
&rect.x1, &rect.y1);
|
||||
rect.x2 = rect.x1 + (effect->w << editor->editor_get_zoom());
|
||||
rect.y2 = rect.y1 + (1 << editor->editor_get_zoom());
|
||||
|
||||
reg2 = jregion_new(&rect, 1);
|
||||
jregion_union(reg1, reg1, reg2);
|
||||
|
@ -18,6 +18,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "jinete/jinete.h"
|
||||
|
||||
#include "sprite_wrappers.h"
|
||||
@ -35,10 +38,12 @@
|
||||
app_get_top_window()->remap_window(); \
|
||||
app_get_top_window()->dirty();
|
||||
|
||||
JWidget current_editor = NULL;
|
||||
JWidget box_editors = NULL;
|
||||
typedef std::vector<Editor*> EditorList;
|
||||
|
||||
static JList editors; /* list of "Editor" structures */
|
||||
Editor* current_editor = NULL;
|
||||
Widget* box_editors = NULL;
|
||||
|
||||
static EditorList editors;
|
||||
|
||||
static int is_sprite_in_some_editor(Sprite *sprite);
|
||||
static Sprite *get_more_reliable_sprite();
|
||||
@ -47,69 +52,65 @@ static int count_parents(JWidget widget);
|
||||
|
||||
int init_module_editors()
|
||||
{
|
||||
editors = jlist_new();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit_module_editors()
|
||||
{
|
||||
jlist_free(editors);
|
||||
editors.clear();
|
||||
}
|
||||
|
||||
JWidget create_new_editor()
|
||||
Editor* create_new_editor()
|
||||
{
|
||||
JWidget editor = editor_new();
|
||||
|
||||
/* add the new editor in the "editors" list */
|
||||
if (editor)
|
||||
jlist_append(editors, editor);
|
||||
|
||||
Editor* editor = new Editor();
|
||||
editors.push_back(editor);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void remove_editor(JWidget editor)
|
||||
/**
|
||||
* Removes the specified editor from the "editors" list.
|
||||
*
|
||||
* It does not delete the editor.
|
||||
*/
|
||||
void remove_editor(Editor* editor)
|
||||
{
|
||||
/* remove the new editor from the "editors" list */
|
||||
jlist_remove(editors, editor);
|
||||
EditorList::iterator it = std::find(editors.begin(), editors.end(), editor);
|
||||
|
||||
assert(it != editors.end());
|
||||
|
||||
editors.erase(it);
|
||||
}
|
||||
|
||||
void refresh_all_editors()
|
||||
{
|
||||
JLink link;
|
||||
|
||||
JI_LIST_FOR_EACH(editors, link)
|
||||
jwidget_dirty(reinterpret_cast<JWidget>(link->data));
|
||||
}
|
||||
|
||||
void update_editors_with_sprite(const Sprite *sprite)
|
||||
{
|
||||
JWidget widget;
|
||||
JLink link;
|
||||
|
||||
JI_LIST_FOR_EACH(editors, link) {
|
||||
widget = reinterpret_cast<JWidget>(link->data);
|
||||
|
||||
if (sprite == editor_get_sprite(widget))
|
||||
editor_update(widget);
|
||||
for (EditorList::iterator it = editors.begin(); it != editors.end(); ++it) {
|
||||
jwidget_dirty(*it);
|
||||
}
|
||||
}
|
||||
|
||||
void editors_draw_sprite(const Sprite *sprite, int x1, int y1, int x2, int y2)
|
||||
void update_editors_with_sprite(const Sprite* sprite)
|
||||
{
|
||||
JWidget widget;
|
||||
JLink link;
|
||||
for (EditorList::iterator it = editors.begin(); it != editors.end(); ++it) {
|
||||
Editor* editor = *it;
|
||||
|
||||
JI_LIST_FOR_EACH(editors, link) {
|
||||
widget = reinterpret_cast<JWidget>(link->data);
|
||||
if (sprite == editor->editor_get_sprite())
|
||||
editor->editor_update();
|
||||
}
|
||||
}
|
||||
|
||||
if (sprite == editor_get_sprite(widget))
|
||||
editor_draw_sprite_safe(widget, x1, y1, x2, y2);
|
||||
void editors_draw_sprite(const Sprite* sprite, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
for (EditorList::iterator it = editors.begin(); it != editors.end(); ++it) {
|
||||
Editor* editor = *it;
|
||||
|
||||
if (sprite == editor->editor_get_sprite())
|
||||
editor->editor_draw_sprite_safe(x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO improve this (with JRegion or something, and without
|
||||
recursivity) */
|
||||
void editors_draw_sprite_tiled(const Sprite *sprite, int x1, int y1, int x2, int y2)
|
||||
void editors_draw_sprite_tiled(const Sprite* sprite, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int cx1, cy1, cx2, cy2; /* cel rectangle */
|
||||
int lx1, ly1, lx2, ly2; /* limited rectangle to the cel rectangle */
|
||||
@ -173,28 +174,27 @@ void editors_draw_sprite_tiled(const Sprite *sprite, int x1, int y1, int x2, int
|
||||
}
|
||||
}
|
||||
|
||||
void editors_hide_sprite(const Sprite *sprite)
|
||||
void editors_hide_sprite(const Sprite* sprite)
|
||||
{
|
||||
UIContext* context = UIContext::instance();
|
||||
bool refresh = (context->get_current_sprite() == sprite) ? true: false;
|
||||
|
||||
JLink link;
|
||||
JI_LIST_FOR_EACH(editors, link) {
|
||||
JWidget widget = reinterpret_cast<JWidget>(link->data);
|
||||
for (EditorList::iterator it = editors.begin(); it != editors.end(); ++it) {
|
||||
Editor* editor = *it;
|
||||
|
||||
if (sprite == editor_get_sprite(widget))
|
||||
editor_set_sprite(widget, get_more_reliable_sprite());
|
||||
if (sprite == editor->editor_get_sprite())
|
||||
editor->editor_set_sprite(get_more_reliable_sprite());
|
||||
}
|
||||
|
||||
if (refresh) {
|
||||
Sprite* sprite = editor_get_sprite(current_editor);
|
||||
Sprite* sprite = current_editor->editor_get_sprite();
|
||||
|
||||
context->set_current_sprite(sprite);
|
||||
app_refresh_screen(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
void set_current_editor(JWidget editor)
|
||||
void set_current_editor(Editor* editor)
|
||||
{
|
||||
if (current_editor != editor) {
|
||||
if (current_editor)
|
||||
@ -205,7 +205,7 @@ void set_current_editor(JWidget editor)
|
||||
jwidget_dirty(jwidget_get_view(current_editor));
|
||||
|
||||
UIContext* context = UIContext::instance();
|
||||
Sprite* sprite = editor_get_sprite(current_editor);
|
||||
Sprite* sprite = current_editor->editor_get_sprite();
|
||||
context->set_current_sprite(sprite);
|
||||
|
||||
app_refresh_screen(sprite);
|
||||
@ -222,7 +222,7 @@ void set_sprite_in_current_editor(Sprite *sprite)
|
||||
if (sprite != NULL)
|
||||
context->send_sprite_to_top(sprite);
|
||||
|
||||
editor_set_sprite(current_editor, sprite);
|
||||
current_editor->editor_set_sprite(sprite);
|
||||
|
||||
jwidget_dirty(jwidget_get_view(current_editor));
|
||||
|
||||
@ -233,17 +233,15 @@ void set_sprite_in_current_editor(Sprite *sprite)
|
||||
|
||||
void set_sprite_in_more_reliable_editor(Sprite* sprite)
|
||||
{
|
||||
JWidget editor, best;
|
||||
JLink link;
|
||||
|
||||
/* the current editor */
|
||||
best = current_editor;
|
||||
Editor* best = current_editor;
|
||||
|
||||
/* search for any empty editor */
|
||||
if (editor_get_sprite(best)) {
|
||||
JI_LIST_FOR_EACH(editors, link) {
|
||||
editor = reinterpret_cast<JWidget>(link->data);
|
||||
if (!editor_get_sprite(editor)) {
|
||||
if (best->editor_get_sprite()) {
|
||||
for (EditorList::iterator it = editors.begin(); it != editors.end(); ++it) {
|
||||
Editor* editor = *it;
|
||||
|
||||
if (!editor->editor_get_sprite()) {
|
||||
best = editor;
|
||||
break;
|
||||
}
|
||||
@ -254,24 +252,21 @@ void set_sprite_in_more_reliable_editor(Sprite* sprite)
|
||||
set_sprite_in_current_editor(sprite);
|
||||
}
|
||||
|
||||
void split_editor(JWidget editor, int align)
|
||||
void split_editor(Editor* editor, int align)
|
||||
{
|
||||
JWidget view = jwidget_get_view(editor);
|
||||
JWidget parent_box = jwidget_get_parent(view); /* box or panel */
|
||||
JWidget new_panel;
|
||||
JWidget new_view;
|
||||
JWidget new_editor;
|
||||
|
||||
if (count_parents(editor) > 10) {
|
||||
jalert(_("Error<<You can't split the editor more||&Close"));
|
||||
jalert(_("Error<<You cannot split this editor more||&Close"));
|
||||
return;
|
||||
}
|
||||
|
||||
JWidget view = jwidget_get_view(editor);
|
||||
JWidget parent_box = jwidget_get_parent(view); /* box or panel */
|
||||
|
||||
/* create a new box to contain both editors, and a new view to put
|
||||
the new editor */
|
||||
new_panel = jpanel_new(align);
|
||||
new_view = editor_view_new();
|
||||
new_editor = create_new_editor();
|
||||
JWidget new_panel = jpanel_new(align);
|
||||
JWidget new_view = editor_view_new();
|
||||
Editor* new_editor = create_new_editor();
|
||||
|
||||
/* insert the "new_box" in the same location that the view */
|
||||
jwidget_replace_child(parent_box, view, new_panel);
|
||||
@ -280,12 +275,12 @@ void split_editor(JWidget editor, int align)
|
||||
jview_attach(new_view, new_editor);
|
||||
|
||||
/* set the sprite for the new editor */
|
||||
editor_set_sprite(new_editor, editor_data(editor)->sprite);
|
||||
editor_data(new_editor)->zoom = editor_data(editor)->zoom;
|
||||
new_editor->editor_set_sprite(editor->editor_get_sprite());
|
||||
new_editor->editor_set_zoom(editor->editor_get_zoom());
|
||||
|
||||
/* expansive widgets */
|
||||
jwidget_expansive(new_panel, TRUE);
|
||||
jwidget_expansive(new_view, TRUE);
|
||||
jwidget_expansive(new_panel, true);
|
||||
jwidget_expansive(new_view, true);
|
||||
|
||||
/* append both views to the "new_panel" */
|
||||
jwidget_add_child(new_panel, view);
|
||||
@ -303,27 +298,26 @@ void split_editor(JWidget editor, int align)
|
||||
jview_get_viewport(view)->rc);
|
||||
jrect_copy(new_editor->rc, editor->rc);
|
||||
|
||||
editor_data(new_editor)->offset_x = editor_data(editor)->offset_x;
|
||||
editor_data(new_editor)->offset_y = editor_data(editor)->offset_y;
|
||||
new_editor->editor_set_offset_x(editor->editor_get_offset_x());
|
||||
new_editor->editor_set_offset_y(editor->editor_get_offset_y());
|
||||
}
|
||||
|
||||
/* fixup window */
|
||||
FIXUP_TOP_WINDOW();
|
||||
|
||||
/* update both editors */
|
||||
editor_update(editor);
|
||||
editor_update(new_editor);
|
||||
editor->editor_update();
|
||||
new_editor->editor_update();
|
||||
}
|
||||
|
||||
void close_editor(JWidget editor)
|
||||
void close_editor(Editor* editor)
|
||||
{
|
||||
JWidget view = jwidget_get_view(editor);
|
||||
JWidget parent_box = jwidget_get_parent(view); /* box or panel */
|
||||
JWidget other_widget;
|
||||
JLink link;
|
||||
|
||||
/* you can't remove all editors */
|
||||
if (jlist_length(editors) == 1)
|
||||
if (editors.size() == 1)
|
||||
return;
|
||||
|
||||
/* deselect the editor */
|
||||
@ -345,26 +339,31 @@ void close_editor(JWidget editor)
|
||||
/* find next editor to select */
|
||||
if (!current_editor) {
|
||||
JWidget next_editor = find_next_editor(other_widget);
|
||||
if (next_editor)
|
||||
set_current_editor(next_editor);
|
||||
if (next_editor) {
|
||||
assert(next_editor->type == editor_type());
|
||||
|
||||
set_current_editor(static_cast<Editor*>(next_editor));
|
||||
}
|
||||
}
|
||||
|
||||
/* fixup window */
|
||||
FIXUP_TOP_WINDOW();
|
||||
|
||||
/* update all editors */
|
||||
JI_LIST_FOR_EACH(editors, link)
|
||||
editor_update(reinterpret_cast<JWidget>(link->data));
|
||||
for (EditorList::iterator it = editors.begin(); it != editors.end(); ++it) {
|
||||
Editor* editor = *it;
|
||||
editor->editor_update();
|
||||
}
|
||||
}
|
||||
|
||||
void make_unique_editor(JWidget editor)
|
||||
void make_unique_editor(Editor* editor)
|
||||
{
|
||||
JWidget view = jwidget_get_view(editor);
|
||||
JLink link, next;
|
||||
JWidget child;
|
||||
|
||||
/* it's the unique editor */
|
||||
if (jlist_length(editors) == 1)
|
||||
if (editors.size() == 1)
|
||||
return;
|
||||
|
||||
/* remove the editor-view of its parent */
|
||||
@ -375,7 +374,7 @@ void make_unique_editor(JWidget editor)
|
||||
child = (JWidget)link->data;
|
||||
|
||||
jwidget_remove_child(box_editors, child);
|
||||
jwidget_free(child);
|
||||
delete child; // widget
|
||||
}
|
||||
|
||||
/* append the editor to main box */
|
||||
@ -388,29 +387,25 @@ void make_unique_editor(JWidget editor)
|
||||
FIXUP_TOP_WINDOW();
|
||||
|
||||
/* update new editor */
|
||||
editor_update(editor);
|
||||
editor->editor_update();
|
||||
}
|
||||
|
||||
static int is_sprite_in_some_editor(Sprite *sprite)
|
||||
static int is_sprite_in_some_editor(Sprite* sprite)
|
||||
{
|
||||
JWidget widget;
|
||||
JLink link;
|
||||
for (EditorList::iterator it = editors.begin(); it != editors.end(); ++it) {
|
||||
Editor* editor = *it;
|
||||
|
||||
JI_LIST_FOR_EACH(editors, link) {
|
||||
widget = reinterpret_cast<JWidget>(link->data);
|
||||
|
||||
if (sprite == editor_get_sprite (widget))
|
||||
return TRUE;
|
||||
if (sprite == editor->editor_get_sprite())
|
||||
return true;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next sprite that should be show if we close the current
|
||||
* one.
|
||||
*/
|
||||
static Sprite *get_more_reliable_sprite()
|
||||
static Sprite* get_more_reliable_sprite()
|
||||
{
|
||||
UIContext* context = UIContext::instance();
|
||||
const SpriteList& list = context->get_sprite_list();
|
||||
|
@ -21,7 +21,9 @@
|
||||
|
||||
#include "jinete/jbase.h"
|
||||
|
||||
extern JWidget current_editor;
|
||||
class Editor;
|
||||
|
||||
extern Editor* current_editor;
|
||||
extern JWidget box_editors;
|
||||
|
||||
class Sprite;
|
||||
@ -29,10 +31,10 @@ class Sprite;
|
||||
int init_module_editors();
|
||||
void exit_module_editors();
|
||||
|
||||
JWidget create_new_editor();
|
||||
void remove_editor(JWidget editor);
|
||||
Editor* create_new_editor();
|
||||
void remove_editor(Editor* editor);
|
||||
|
||||
void set_current_editor(JWidget editor);
|
||||
void set_current_editor(Editor* editor);
|
||||
|
||||
void refresh_all_editors();
|
||||
void update_editors_with_sprite(const Sprite* sprite);
|
||||
@ -43,9 +45,9 @@ void editors_hide_sprite(const Sprite* sprite);
|
||||
void set_sprite_in_current_editor(Sprite* sprite);
|
||||
void set_sprite_in_more_reliable_editor(Sprite* sprite);
|
||||
|
||||
void split_editor(JWidget editor, int align);
|
||||
void close_editor(JWidget editor);
|
||||
void make_unique_editor(JWidget editor);
|
||||
void split_editor(Editor* editor, int align);
|
||||
void close_editor(Editor* editor);
|
||||
void make_unique_editor(Editor* editor);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -806,13 +806,12 @@ static void marker_scroll_callback(int before_change)
|
||||
}
|
||||
|
||||
/* controls any tool to draw in the current sprite */
|
||||
void control_tool(JWidget widget, Tool *tool,
|
||||
void control_tool(Editor* editor, Tool *tool,
|
||||
color_t _color,
|
||||
color_t _other_color,
|
||||
bool left_button)
|
||||
{
|
||||
Editor *editor = editor_data(widget);
|
||||
Sprite *sprite = editor->sprite;
|
||||
Sprite *sprite = editor->editor_get_sprite();
|
||||
JWidget statusbar = app_get_statusbar();
|
||||
int x1, y1, x2, y2;
|
||||
int old_x1, old_y1, old_x2, old_y2;
|
||||
@ -846,8 +845,8 @@ void control_tool(JWidget widget, Tool *tool,
|
||||
the user click outside the window, it is closed, but the filtered
|
||||
JM_BUTTONPRESSED message is not "eaten" so the editor receive it
|
||||
anyway */
|
||||
jmanager_dispatch_messages(jwidget_get_manager(widget));
|
||||
jwidget_flush_redraw(jwidget_get_manager(widget));
|
||||
jmanager_dispatch_messages(editor->getManager());
|
||||
jwidget_flush_redraw(editor->getManager());
|
||||
|
||||
/* error, the active layer is not visible */
|
||||
if (!sprite->layer->is_readable()) {
|
||||
@ -954,10 +953,9 @@ void control_tool(JWidget widget, Tool *tool,
|
||||
old_x1 = old_y1 = old_x2 = old_y2 = 0;
|
||||
|
||||
/* start click */
|
||||
editor_click_start(widget,
|
||||
click2 ? MODE_CLICKANDCLICK:
|
||||
MODE_CLICKANDRELEASE,
|
||||
&start_x, &start_y, &start_b);
|
||||
editor->editor_click_start(click2 ? Editor::MODE_CLICKANDCLICK:
|
||||
Editor::MODE_CLICKANDRELEASE,
|
||||
&start_x, &start_y, &start_b);
|
||||
|
||||
next_pts:;
|
||||
|
||||
@ -1168,8 +1166,8 @@ next_pts:;
|
||||
acquire_bitmap(ji_screen);
|
||||
|
||||
/* clean the area occupied by the cursor in the screen */
|
||||
if (editor->cursor_thick)
|
||||
editor_clean_cursor(widget);
|
||||
if (editor->editor_get_cursor_thick())
|
||||
editor->editor_clean_cursor();
|
||||
|
||||
/* /\* for Path *\/ */
|
||||
/* if (tool == &ase_tool_path) { */
|
||||
@ -1206,16 +1204,14 @@ next_pts:;
|
||||
int nrects;
|
||||
JRect rc;
|
||||
|
||||
editor_to_screen(widget,
|
||||
MIN(x1, x2)-offset_x,
|
||||
MIN(y1, y2)-offset_y, &outx1, &outy1);
|
||||
editor->editor_to_screen(MIN(x1, x2)-offset_x,
|
||||
MIN(y1, y2)-offset_y, &outx1, &outy1);
|
||||
|
||||
editor_to_screen(widget,
|
||||
MAX(x1, x2)-offset_x,
|
||||
MAX(y1, y2)-offset_y, &outx2, &outy2);
|
||||
editor->editor_to_screen(MAX(x1, x2)-offset_x,
|
||||
MAX(y1, y2)-offset_y, &outx2, &outy2);
|
||||
|
||||
outx2 += (1<<editor->zoom)-1;
|
||||
outy2 += (1<<editor->zoom)-1;
|
||||
outx2 += (1<<editor->editor_get_zoom())-1;
|
||||
outy2 += (1<<editor->editor_get_zoom())-1;
|
||||
|
||||
if (rect_tracker)
|
||||
rect_tracker_free(rect_tracker);
|
||||
@ -1224,7 +1220,7 @@ next_pts:;
|
||||
dotted_mode(0);
|
||||
|
||||
/* draw the rectangle in the drawable region */
|
||||
region = jwidget_get_drawable_region(widget, JI_GDR_CUTTOPWINDOWS);
|
||||
region = jwidget_get_drawable_region(editor, JI_GDR_CUTTOPWINDOWS);
|
||||
nrects = JI_REGION_NUM_RECTS(region);
|
||||
for (c=0, rc=JI_REGION_RECTS(region);
|
||||
c<nrects;
|
||||
@ -1322,10 +1318,9 @@ next_pts:;
|
||||
#if 0 /* use this code to see what parts are updated */
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
editor_to_screen(widget, 0, 0, &x1, &y1);
|
||||
editor_to_screen(widget,
|
||||
sprite->w,
|
||||
sprite->h, &x2, &y2);
|
||||
editor->editor_to_screen(0, 0, &x1, &y1);
|
||||
editor->editor_to_screen(sprite->w,
|
||||
sprite->h, &x2, &y2);
|
||||
rectfill(ji_screen, x1, y1, x2-1, y2-1, makecol(255, 0, 0));
|
||||
vsync();
|
||||
}
|
||||
@ -1337,7 +1332,7 @@ next_pts:;
|
||||
}
|
||||
|
||||
/* draw the cursor in the screen */
|
||||
editor_draw_cursor(widget, jmouse_x(0), jmouse_y(0));
|
||||
editor->editor_draw_cursor(jmouse_x(0), jmouse_y(0));
|
||||
|
||||
/* update the state-bar */
|
||||
if (jwidget_is_visible(statusbar)) {
|
||||
@ -1389,14 +1384,10 @@ next_pts:;
|
||||
release_bitmap(ji_screen);
|
||||
forced_update = FALSE;
|
||||
first_time = FALSE;
|
||||
|
||||
/* draw extra stuff */
|
||||
editor_draw_grid_safe(widget);
|
||||
/* editor_draw_path_safe(widget, FALSE); */
|
||||
}
|
||||
|
||||
/* draw mask */
|
||||
editor_draw_mask_safe(widget);
|
||||
editor->editor_draw_mask_safe();
|
||||
|
||||
/* spray updating process */
|
||||
if (current_tool == tools_list[TOOL_SPRAY]) {
|
||||
@ -1417,17 +1408,17 @@ next_pts:;
|
||||
}
|
||||
|
||||
gui_feedback();
|
||||
} while (editor_click(widget, &new_x, &new_y, &update,
|
||||
marker_scroll_callback));
|
||||
} while (editor->editor_click(&new_x, &new_y, &update,
|
||||
marker_scroll_callback));
|
||||
|
||||
/* if we finished with the same button that we start began */
|
||||
if (!editor_click_cancel(widget)) {
|
||||
if (!editor->editor_click_cancel()) {
|
||||
/* in curve we have to input four points */
|
||||
if ((tool->flags & TOOL_4FIRST2LAST) &&
|
||||
(curve_pts < 3)) {
|
||||
++curve_pts;
|
||||
editor_click_continue(widget, MODE_CLICKANDCLICK,
|
||||
&start_x, &start_y);
|
||||
editor->editor_click_continue(Editor::MODE_CLICKANDCLICK,
|
||||
&start_x, &start_y);
|
||||
goto next_pts;
|
||||
}
|
||||
|
||||
@ -1565,7 +1556,7 @@ next_pts:;
|
||||
/* redraw all the sprites */
|
||||
update_screen_for_sprite(sprite);
|
||||
|
||||
editor_click_done(widget);
|
||||
editor->editor_click_done();
|
||||
|
||||
/* no more preview image */
|
||||
set_preview_image(NULL, NULL);
|
||||
|
@ -29,6 +29,7 @@ class Image;
|
||||
class Layer;
|
||||
class Mask;
|
||||
class Sprite;
|
||||
class Editor;
|
||||
|
||||
struct Brush;
|
||||
|
||||
@ -134,7 +135,7 @@ void set_cursor_color(color_t color);
|
||||
|
||||
int get_thickness_for_cursor();
|
||||
|
||||
void control_tool(JWidget editor, Tool *tool,
|
||||
void control_tool(Editor* editor, Tool *tool,
|
||||
color_t color,
|
||||
color_t other_color,
|
||||
bool left_button);
|
||||
|
@ -82,7 +82,7 @@ enum {
|
||||
static void set_clipboard(Image* image, Palette* palette, bool set_system_clipboard);
|
||||
static bool copy_from_sprite(const Sprite* sprite);
|
||||
|
||||
static bool interactive_transform(JWidget widget, Image *dest_image, Image *image,
|
||||
static bool interactive_transform(Editor* widget, Image *dest_image, Image *image,
|
||||
int x, int y, int xout[4], int yout[4]);
|
||||
static void apply_rotation(int x1, int y1, int x2, int y2,
|
||||
fixed angle, int cx, int cy,
|
||||
@ -97,7 +97,7 @@ static void fill_in_vars(int *in_box,
|
||||
int *in_top, int *in_middle, int *in_bottom,
|
||||
int x1, int y1, int x2, int y2, fixed angle,
|
||||
int cx, int cy);
|
||||
static void update_status_bar(JWidget editor, Image *image,
|
||||
static void update_status_bar(Editor* editor, Image *image,
|
||||
int x1, int y1, int x2, int y2, fixed angle);
|
||||
|
||||
static bool first_time = true;
|
||||
@ -246,8 +246,8 @@ void clipboard::paste(SpriteWriter& sprite)
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
int x, y, x1, y1, x2, y2;
|
||||
|
||||
screen_to_editor(current_editor, vp->x1, vp->y1, &x1, &y1);
|
||||
screen_to_editor(current_editor, vp->x2-1, vp->y2-1, &x2, &y2);
|
||||
current_editor->screen_to_editor(vp->x1, vp->y1, &x1, &y1);
|
||||
current_editor->screen_to_editor(vp->x2-1, vp->y2-1, &x2, &y2);
|
||||
x = (x1+x2)/2-src_image->w/2;
|
||||
y = (y1+y2)/2-src_image->h/2;
|
||||
|
||||
@ -297,7 +297,7 @@ void clipboard::paste(SpriteWriter& sprite)
|
||||
|
||||
enum { DONE_NONE, DONE_CANCEL, DONE_PASTE };
|
||||
|
||||
static bool interactive_transform(JWidget widget,
|
||||
static bool interactive_transform(Editor* editor,
|
||||
Image *dest_image, Image *image,
|
||||
int x, int y,
|
||||
int xout[4], int yout[4])
|
||||
@ -319,7 +319,7 @@ static bool interactive_transform(JWidget widget,
|
||||
x1-vp->x1, y1-vp->y1, x2-vp->x1, y2-vp->y1, \
|
||||
preview, mode, angle, cx-vp->x1, cy-vp->y1); \
|
||||
blit(bmp2, ji_screen, 0, 0, vp->x1, vp->y1, jrect_w(vp), jrect_h(vp)); \
|
||||
update_status_bar(widget, image, x1, y1, x2, y2, angle); \
|
||||
update_status_bar(editor, image, x1, y1, x2, y2, angle); \
|
||||
jmouse_show();
|
||||
|
||||
int x1, y1, x2, y2;
|
||||
@ -327,16 +327,16 @@ static bool interactive_transform(JWidget widget,
|
||||
int action = ACTION_SETMODE;
|
||||
int mode = SCALE_MODE;
|
||||
BITMAP *bmp1, *bmp2, *preview, *old_screen;
|
||||
JRect vp = jview_get_viewport_position(jwidget_get_view(widget));
|
||||
JRect vp = jview_get_viewport_position(jwidget_get_view(editor));
|
||||
int done = DONE_NONE;
|
||||
fixed angle = 0;
|
||||
int cx, cy;
|
||||
int mask_color;
|
||||
|
||||
hide_drawing_cursor(widget);
|
||||
editor->hide_drawing_cursor();
|
||||
|
||||
editor_to_screen(widget, x, y, &x1, &y1);
|
||||
editor_to_screen(widget, x+image->w, y+image->h, &x2, &y2);
|
||||
editor->editor_to_screen(x, y, &x1, &y1);
|
||||
editor->editor_to_screen(x+image->w, y+image->h, &x2, &y2);
|
||||
cx = (x1+x2)/2;
|
||||
cy = (y1+y2)/2;
|
||||
|
||||
@ -473,7 +473,7 @@ static bool interactive_transform(JWidget widget,
|
||||
/* left button+shift || middle button = scroll movement */
|
||||
if ((jmouse_b(0) == 1 && (key_shifts & KB_SHIFT_FLAG)) ||
|
||||
(jmouse_b(0) == 4)) {
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
JWidget view = jwidget_get_view(editor);
|
||||
int scroll_x, scroll_y;
|
||||
|
||||
x = jmouse_x(0) - jmouse_x(1);
|
||||
@ -485,7 +485,7 @@ static bool interactive_transform(JWidget widget,
|
||||
/* TODO */
|
||||
|
||||
jview_get_scroll(view, &scroll_x, &scroll_y);
|
||||
editor_set_scroll(widget, scroll_x-x, scroll_y-y, TRUE);
|
||||
editor->editor_set_scroll(scroll_x-x, scroll_y-y, TRUE);
|
||||
|
||||
/* editor_to_screen (widget, x1, y1, &x1, &y1); */
|
||||
/* editor_to_screen (widget, x2, y2, &x2, &y2); */
|
||||
@ -634,8 +634,8 @@ static bool interactive_transform(JWidget widget,
|
||||
break;
|
||||
}
|
||||
|
||||
screen_to_editor(widget, x1, y1, &x1, &y1);
|
||||
screen_to_editor(widget, x2, y2, &x2, &y2);
|
||||
editor->screen_to_editor(x1, y1, &x1, &y1);
|
||||
editor->screen_to_editor(x2, y2, &x2, &y2);
|
||||
|
||||
if (get_use_grid() && angle == 0) {
|
||||
int ox = x1;
|
||||
@ -645,8 +645,8 @@ static bool interactive_transform(JWidget widget,
|
||||
y2 += y1 - oy;
|
||||
}
|
||||
|
||||
editor_to_screen(widget, x1, y1, &x1, &y1);
|
||||
editor_to_screen(widget, x2, y2, &x2, &y2);
|
||||
editor->editor_to_screen(x1, y1, &x1, &y1);
|
||||
editor->editor_to_screen(x2, y2, &x2, &y2);
|
||||
|
||||
/* redraw the screen */
|
||||
REDRAW();
|
||||
@ -688,7 +688,7 @@ static bool interactive_transform(JWidget widget,
|
||||
int c;
|
||||
apply_rotation(x1, y1, x2, y2, angle, cx, cy, xout, yout);
|
||||
for (c=0; c<4; c++)
|
||||
screen_to_editor(widget, xout[c], yout[c], xout+c, yout+c);
|
||||
editor->screen_to_editor(xout[c], yout[c], xout+c, yout+c);
|
||||
}
|
||||
|
||||
destroy_bitmap(bmp1);
|
||||
@ -698,7 +698,7 @@ static bool interactive_transform(JWidget widget,
|
||||
clear_keybuf();
|
||||
|
||||
/* restore the cursor */
|
||||
show_drawing_cursor(widget);
|
||||
editor->show_drawing_cursor();
|
||||
|
||||
jrect_free(vp);
|
||||
return done == DONE_PASTE;
|
||||
@ -844,14 +844,14 @@ static void fill_in_vars(int *in_box,
|
||||
*in_middle = (my > (y1+y2)/2-6 && my < (y1+y2)/2+6);
|
||||
}
|
||||
|
||||
static void update_status_bar(JWidget editor, Image *image,
|
||||
static void update_status_bar(Editor* editor, Image *image,
|
||||
int x1, int y1, int x2, int y2, fixed angle)
|
||||
{
|
||||
int u1, v1, u2, v2;
|
||||
int iangle = 360*(fixtoi (angle & (255<<16)))/256;
|
||||
|
||||
screen_to_editor(editor, x1, y1, &u1, &v1);
|
||||
screen_to_editor(editor, x2, y2, &u2, &v2);
|
||||
editor->screen_to_editor(x1, y1, &u1, &v1);
|
||||
editor->screen_to_editor(x2, y2, &u2, &v2);
|
||||
|
||||
statusbar_set_text
|
||||
(app_get_statusbar(), 0,
|
||||
|
@ -160,8 +160,8 @@ Image* NewImageFromMask(const Sprite* src_sprite)
|
||||
current editor, returns TRUE if the position was changed. */
|
||||
int interactive_move_layer(int mode, bool use_undo, int (*callback)())
|
||||
{
|
||||
JWidget editor = current_editor;
|
||||
Sprite *sprite = editor_get_sprite(editor);
|
||||
Editor* editor = current_editor;
|
||||
Sprite* sprite = editor->editor_get_sprite();
|
||||
|
||||
assert(sprite->layer->is_image());
|
||||
|
||||
@ -183,10 +183,10 @@ int interactive_move_layer(int mode, bool use_undo, int (*callback)())
|
||||
begin_x = cel->x;
|
||||
begin_y = cel->y;
|
||||
|
||||
hide_drawing_cursor(editor);
|
||||
editor->hide_drawing_cursor();
|
||||
jmouse_set_cursor(JI_CURSOR_MOVE);
|
||||
|
||||
editor_click_start(editor, mode, &start_x, &start_y, &start_b);
|
||||
editor->editor_click_start(mode, &start_x, &start_y, &start_b);
|
||||
|
||||
do {
|
||||
if (update) {
|
||||
@ -219,14 +219,14 @@ int interactive_move_layer(int mode, bool use_undo, int (*callback)())
|
||||
jmanager_dispatch_messages(ji_get_default_manager());
|
||||
|
||||
gui_feedback();
|
||||
} while (editor_click(editor, &new_x, &new_y, &update, NULL));
|
||||
} while (editor->editor_click(&new_x, &new_y, &update, NULL));
|
||||
|
||||
new_x = cel->x;
|
||||
new_y = cel->y;
|
||||
cel_set_position(cel, begin_x, begin_y);
|
||||
|
||||
/* the position was changed */
|
||||
if (!editor_click_cancel(editor)) {
|
||||
if (!editor->editor_click_cancel()) {
|
||||
if (use_undo && undo_is_enabled(sprite->undo)) {
|
||||
undo_set_label(sprite->undo, "Cel Movement");
|
||||
undo_open(sprite->undo);
|
||||
@ -247,9 +247,9 @@ int interactive_move_layer(int mode, bool use_undo, int (*callback)())
|
||||
update_screen_for_sprite(sprite);
|
||||
|
||||
/* restore the cursor */
|
||||
show_drawing_cursor(editor);
|
||||
editor->show_drawing_cursor();
|
||||
|
||||
editor_click_done(editor);
|
||||
editor->editor_click_done();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -166,14 +166,15 @@ static bool colorbutton_msg_proc(JWidget widget, JMessage msg)
|
||||
}
|
||||
/* pick a color from a editor */
|
||||
else if (picked->type == editor_type()) {
|
||||
Sprite *sprite = editor_get_sprite(picked);
|
||||
Editor* editor = static_cast<Editor*>(picked);
|
||||
Sprite* sprite = editor->editor_get_sprite();
|
||||
int x, y, imgcolor;
|
||||
color_t tmp;
|
||||
|
||||
if (sprite) {
|
||||
x = msg->mouse.x;
|
||||
y = msg->mouse.y;
|
||||
screen_to_editor(picked, x, y, &x, &y);
|
||||
editor->screen_to_editor(x, y, &x, &y);
|
||||
imgcolor = sprite_getpixel(sprite, x, y);
|
||||
tmp = color_from_image(sprite->imgtype, imgcolor);
|
||||
|
||||
|
@ -20,111 +20,129 @@
|
||||
#define WIDGETS_EDITOR_H_INCLUDED
|
||||
|
||||
#include "jinete/jbase.h"
|
||||
#include "jinete/jwidget.h"
|
||||
#include "core/color.h"
|
||||
|
||||
#define MIN_ZOOM 0
|
||||
#define MAX_ZOOM 5
|
||||
|
||||
class Sprite;
|
||||
|
||||
struct Editor
|
||||
class Editor : public Widget
|
||||
{
|
||||
JWidget widget;
|
||||
// editor states
|
||||
enum {
|
||||
EDIT_STANDBY,
|
||||
EDIT_MOVING_SCROLL,
|
||||
EDIT_DRAWING,
|
||||
};
|
||||
|
||||
/* main stuff */
|
||||
int state;
|
||||
Sprite* sprite;
|
||||
int zoom;
|
||||
int m_state;
|
||||
Sprite* m_sprite;
|
||||
int m_zoom;
|
||||
|
||||
/* drawing cursor */
|
||||
int cursor_thick;
|
||||
int cursor_screen_x; /* position in the screen (view) */
|
||||
int cursor_screen_y;
|
||||
int cursor_editor_x; /* position in the editor (model) */
|
||||
int cursor_editor_y;
|
||||
int old_cursor_thick;
|
||||
bool cursor_candraw : 1;
|
||||
int m_cursor_thick;
|
||||
int m_cursor_screen_x; /* position in the screen (view) */
|
||||
int m_cursor_screen_y;
|
||||
int m_cursor_editor_x; /* position in the editor (model) */
|
||||
int m_cursor_editor_y;
|
||||
int m_old_cursor_thick;
|
||||
bool m_cursor_candraw : 1;
|
||||
|
||||
bool alt_pressed : 1;
|
||||
bool ctrl_pressed : 1;
|
||||
bool space_pressed : 1;
|
||||
bool m_alt_pressed : 1;
|
||||
bool m_ctrl_pressed : 1;
|
||||
bool m_space_pressed : 1;
|
||||
|
||||
/* offset for the sprite */
|
||||
int offset_x;
|
||||
int offset_y;
|
||||
int m_offset_x;
|
||||
int m_offset_y;
|
||||
|
||||
/* marching ants stuff */
|
||||
int mask_timer_id;
|
||||
int offset_count;
|
||||
int m_mask_timer_id;
|
||||
int m_offset_count;
|
||||
|
||||
/* region that must be updated */
|
||||
JRegion refresh_region;
|
||||
};
|
||||
JRegion m_refresh_region;
|
||||
|
||||
/**********************************************************************/
|
||||
/* src/gui/editor/editor.c */
|
||||
public:
|
||||
// in editor.c
|
||||
|
||||
Editor();
|
||||
~Editor();
|
||||
|
||||
int editor_get_zoom() const { return m_zoom; }
|
||||
int editor_get_offset_x() const { return m_offset_x; }
|
||||
int editor_get_offset_y() const { return m_offset_y; }
|
||||
Sprite* editor_get_sprite() { return m_sprite; }
|
||||
int editor_get_cursor_thick() { return m_cursor_thick; }
|
||||
|
||||
void editor_set_zoom(int zoom) { m_zoom = zoom; }
|
||||
void editor_set_offset_x(int x) { m_offset_x = x; }
|
||||
void editor_set_offset_y(int y) { m_offset_y = y; }
|
||||
void editor_set_sprite(Sprite* sprite);
|
||||
|
||||
void editor_set_scroll(int x, int y, int use_refresh_region);
|
||||
void editor_update();
|
||||
|
||||
void editor_draw_sprite(int x1, int y1, int x2, int y2);
|
||||
void editor_draw_sprite_safe(int x1, int y1, int x2, int y2);
|
||||
|
||||
void editor_draw_mask();
|
||||
void editor_draw_mask_safe();
|
||||
|
||||
void screen_to_editor(int xin, int yin, int *xout, int *yout);
|
||||
void editor_to_screen(int xin, int yin, int *xout, int *yout);
|
||||
|
||||
void show_drawing_cursor();
|
||||
void hide_drawing_cursor();
|
||||
|
||||
void editor_update_statusbar_for_standby();
|
||||
|
||||
void editor_refresh_region();
|
||||
|
||||
// in cursor.c
|
||||
|
||||
static void editor_cursor_exit();
|
||||
|
||||
void editor_draw_cursor(int x, int y);
|
||||
void editor_clean_cursor();
|
||||
bool editor_cursor_is_subpixel();
|
||||
|
||||
// keys.c
|
||||
|
||||
bool editor_keys_toset_zoom(int scancode);
|
||||
bool editor_keys_toset_brushsize(int scancode);
|
||||
|
||||
// click.c
|
||||
|
||||
enum {
|
||||
MODE_CLICKANDRELEASE,
|
||||
MODE_CLICKANDCLICK,
|
||||
};
|
||||
|
||||
void editor_click_start(int mode, int *x, int *y, int *b);
|
||||
void editor_click_continue(int mode, int *x, int *y);
|
||||
void editor_click_done();
|
||||
int editor_click(int *x, int *y, int *update,
|
||||
void (*scroll_callback) (int before_change));
|
||||
int editor_click_cancel();
|
||||
|
||||
protected:
|
||||
virtual bool msg_proc(JMessage msg);
|
||||
|
||||
private:
|
||||
void drawGrid();
|
||||
void editor_request_size(int *w, int *h);
|
||||
void editor_setcursor(int x, int y);
|
||||
void editor_update_candraw();
|
||||
|
||||
void for_each_pixel_of_brush(int x, int y, int color,
|
||||
void (*pixel)(BITMAP *bmp, int x, int y, int color));
|
||||
};
|
||||
|
||||
JWidget editor_view_new();
|
||||
|
||||
JWidget editor_new();
|
||||
int editor_type();
|
||||
|
||||
Editor* editor_data(JWidget editor);
|
||||
Sprite* editor_get_sprite(JWidget editor);
|
||||
|
||||
void editor_set_sprite(JWidget editor, Sprite* sprite);
|
||||
void editor_set_scroll(JWidget editor, int x, int y, int use_refresh_region);
|
||||
void editor_update(JWidget editor);
|
||||
|
||||
void editor_draw_sprite(JWidget editor, int x1, int y1, int x2, int y2);
|
||||
void editor_draw_sprite_safe(JWidget editor, int x1, int y1, int x2, int y2);
|
||||
|
||||
void editor_draw_mask(JWidget editor);
|
||||
void editor_draw_mask_safe(JWidget editor);
|
||||
|
||||
void editor_draw_grid(JWidget editor);
|
||||
void editor_draw_grid_safe(JWidget editor);
|
||||
|
||||
void editor_draw_path(JWidget editor, int draw_extras);
|
||||
void editor_draw_path_safe(JWidget editor, int draw_extras);
|
||||
|
||||
void screen_to_editor(JWidget editor, int xin, int yin, int *xout, int *yout);
|
||||
void editor_to_screen(JWidget editor, int xin, int yin, int *xout, int *yout);
|
||||
|
||||
void show_drawing_cursor(JWidget editor);
|
||||
void hide_drawing_cursor(JWidget editor);
|
||||
|
||||
void editor_update_statusbar_for_standby(JWidget editor);
|
||||
|
||||
void editor_refresh_region(JWidget editor);
|
||||
|
||||
/**********************************************************************/
|
||||
/* src/gui/editor/cursor.c */
|
||||
|
||||
void editor_cursor_exit();
|
||||
|
||||
void editor_draw_cursor(JWidget editor, int x, int y);
|
||||
void editor_clean_cursor(JWidget editor);
|
||||
bool editor_cursor_is_subpixel(JWidget editor);
|
||||
|
||||
/**********************************************************************/
|
||||
/* src/gui/editor/keys.c */
|
||||
|
||||
int editor_keys_toset_zoom(JWidget editor, int scancode);
|
||||
int editor_keys_toset_brushsize(JWidget editor, int scancode);
|
||||
|
||||
/**********************************************************************/
|
||||
/* src/gui/editor/click.c */
|
||||
|
||||
enum {
|
||||
MODE_CLICKANDRELEASE,
|
||||
MODE_CLICKANDCLICK,
|
||||
};
|
||||
|
||||
void editor_click_start(JWidget editor, int mode, int *x, int *y, int *b);
|
||||
void editor_click_continue(JWidget editor, int mode, int *x, int *y);
|
||||
void editor_click_done(JWidget editor);
|
||||
int editor_click(JWidget editor, int *x, int *y, int *update,
|
||||
void (*scroll_callback) (int before_change));
|
||||
int editor_click_cancel(JWidget editor);
|
||||
|
||||
#endif
|
||||
|
@ -48,7 +48,7 @@ static int click_last_b;
|
||||
|
||||
static int click_prev_last_b;
|
||||
|
||||
void editor_click_start(JWidget widget, int mode, int *x, int *y, int *b)
|
||||
void Editor::editor_click_start(int mode, int *x, int *y, int *b)
|
||||
{
|
||||
click_mode = mode;
|
||||
click_first = TRUE;
|
||||
@ -59,13 +59,13 @@ void editor_click_start(JWidget widget, int mode, int *x, int *y, int *b)
|
||||
|
||||
click_prev_last_b = click_last_b;
|
||||
|
||||
screen_to_editor(widget, click_start_x, click_start_y, x, y);
|
||||
screen_to_editor(click_start_x, click_start_y, x, y);
|
||||
*b = click_start_b;
|
||||
|
||||
jwidget_capture_mouse(widget);
|
||||
jwidget_capture_mouse(this);
|
||||
}
|
||||
|
||||
void editor_click_continue(JWidget widget, int mode, int *x, int *y)
|
||||
void Editor::editor_click_continue(int mode, int *x, int *y)
|
||||
{
|
||||
click_mode = mode;
|
||||
click_first = TRUE;
|
||||
@ -74,19 +74,19 @@ void editor_click_continue(JWidget widget, int mode, int *x, int *y)
|
||||
click_start_y = click_last_y = jmouse_y(0);
|
||||
click_start_b = click_last_b = click_prev_last_b;
|
||||
|
||||
screen_to_editor(widget, click_start_x, click_start_y, x, y);
|
||||
screen_to_editor(click_start_x, click_start_y, x, y);
|
||||
}
|
||||
|
||||
void editor_click_done(JWidget widget)
|
||||
void Editor::editor_click_done()
|
||||
{
|
||||
jwidget_release_mouse(widget);
|
||||
jwidget_release_mouse(this);
|
||||
clear_keybuf();
|
||||
}
|
||||
|
||||
/* returns FALSE when the user stop the click-loop: releases the
|
||||
button or press the second click (depend of the mode) */
|
||||
int editor_click(JWidget widget, int *x, int *y, int *update,
|
||||
void (*scroll_callback) (int before_change))
|
||||
int Editor::editor_click(int *x, int *y, int *update,
|
||||
void (*scroll_callback) (int before_change))
|
||||
{
|
||||
int prev_x, prev_y;
|
||||
|
||||
@ -108,8 +108,8 @@ int editor_click(JWidget widget, int *x, int *y, int *update,
|
||||
|
||||
*update = jmouse_poll();
|
||||
|
||||
if (!editor_cursor_is_subpixel(widget))
|
||||
screen_to_editor(widget, click_last_x, click_last_y, &prev_x, &prev_y);
|
||||
if (!editor_cursor_is_subpixel())
|
||||
screen_to_editor(click_last_x, click_last_y, &prev_x, &prev_y);
|
||||
|
||||
click_prev_last_b = click_last_b;
|
||||
|
||||
@ -117,11 +117,11 @@ int editor_click(JWidget widget, int *x, int *y, int *update,
|
||||
click_last_y = jmouse_y(0);
|
||||
click_last_b = jmouse_b(0);
|
||||
|
||||
screen_to_editor(widget, click_last_x, click_last_y, x, y);
|
||||
screen_to_editor(click_last_x, click_last_y, x, y);
|
||||
|
||||
/* the mouse was moved */
|
||||
if (*update) {
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
JWidget view = jwidget_get_view(this);
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
|
||||
/* update scroll */
|
||||
@ -146,8 +146,7 @@ int editor_click(JWidget widget, int *x, int *y, int *update,
|
||||
}
|
||||
|
||||
jview_get_scroll(view, &scroll_x, &scroll_y);
|
||||
editor_set_scroll(widget,
|
||||
scroll_x+click_last_x-jmouse_x(0),
|
||||
editor_set_scroll(scroll_x+click_last_x-jmouse_x(0),
|
||||
scroll_y+click_last_y-jmouse_y(0), TRUE);
|
||||
|
||||
click_last_x = jmouse_x(0);
|
||||
@ -158,7 +157,7 @@ int editor_click(JWidget widget, int *x, int *y, int *update,
|
||||
}
|
||||
|
||||
/* if the cursor hasn't subpixel movement */
|
||||
if (!editor_cursor_is_subpixel(widget)) {
|
||||
if (!editor_cursor_is_subpixel()) {
|
||||
/* check if the mouse change to other pixel of the sprite */
|
||||
*update = ((prev_x != *x) || (prev_y != *y));
|
||||
}
|
||||
@ -195,7 +194,7 @@ int editor_click(JWidget widget, int *x, int *y, int *update,
|
||||
}
|
||||
}
|
||||
|
||||
int editor_click_cancel(JWidget widget)
|
||||
int Editor::editor_click_cancel()
|
||||
{
|
||||
return (click_start_b != click_prev_last_b);
|
||||
}
|
||||
|
@ -41,13 +41,12 @@
|
||||
/**
|
||||
* Returns true if the cursor of the editor needs subpixel movement.
|
||||
*/
|
||||
#define IS_SUBPIXEL(editor) ((editor)->zoom >= 2)
|
||||
#define IS_SUBPIXEL(editor) ((editor)->m_zoom >= 2)
|
||||
|
||||
/**
|
||||
* Maximum quantity of colors to save pixels overlapped by the cursor.
|
||||
*/
|
||||
#define MAX_SAVED 4096 /* TODO maybe more size is required for
|
||||
high resolutions */
|
||||
#define MAX_SAVED 4096
|
||||
|
||||
static struct {
|
||||
int brush_type;
|
||||
@ -72,7 +71,6 @@ static JRegion clipping_region;
|
||||
static JRegion old_clipping_region;
|
||||
|
||||
static void generate_cursor_boundaries();
|
||||
static void for_each_pixel_of_brush(Editor *editor, int x, int y, int color, void (*pixel)(BITMAP *bmp, int x, int y, int color));
|
||||
|
||||
static void editor_cursor_cross(Editor *editor, int x, int y, int color, int thickness, void (*pixel)(BITMAP *bmp, int x, int y, int color));
|
||||
static void editor_cursor_brush(Editor *editor, int x, int y, int color, void (*pixel)(BITMAP *bmp, int x, int y, int color));
|
||||
@ -83,7 +81,11 @@ static void cleanpixel(BITMAP *bmp, int x, int y, int color);
|
||||
|
||||
static int point_inside_region(int x, int y, JRegion region);
|
||||
|
||||
void editor_cursor_exit()
|
||||
/***********************************************************/
|
||||
/* CURSOR */
|
||||
/***********************************************************/
|
||||
|
||||
void Editor::editor_cursor_exit()
|
||||
{
|
||||
if (cursor_bound.seg != NULL)
|
||||
jfree(cursor_bound.seg);
|
||||
@ -101,26 +103,25 @@ void editor_cursor_exit()
|
||||
*
|
||||
* @see editor_clean_cursor
|
||||
*/
|
||||
void editor_draw_cursor(JWidget widget, int x, int y)
|
||||
void Editor::editor_draw_cursor(int x, int y)
|
||||
{
|
||||
Editor *editor = editor_data(widget);
|
||||
int color;
|
||||
|
||||
assert(editor->cursor_thick == 0);
|
||||
assert(m_cursor_thick == 0);
|
||||
|
||||
/* get drawable region */
|
||||
clipping_region = jwidget_get_drawable_region(widget, JI_GDR_CUTTOPWINDOWS);
|
||||
clipping_region = jwidget_get_drawable_region(this, JI_GDR_CUTTOPWINDOWS);
|
||||
|
||||
/* get cursor color */
|
||||
cursor_negative = is_cursor_mask();
|
||||
color = get_raw_cursor_color();
|
||||
|
||||
/* cursor in the screen (view) */
|
||||
editor->cursor_screen_x = x;
|
||||
editor->cursor_screen_y = y;
|
||||
m_cursor_screen_x = x;
|
||||
m_cursor_screen_y = y;
|
||||
|
||||
/* get cursor position in the editor */
|
||||
screen_to_editor(widget, x, y, &x, &y);
|
||||
screen_to_editor(x, y, &x, &y);
|
||||
|
||||
/* get cursor type */
|
||||
if (get_thickness_for_cursor() == 1) {
|
||||
@ -131,7 +132,7 @@ void editor_draw_cursor(JWidget widget, int x, int y)
|
||||
case BRUSH_CIRCLE:
|
||||
case BRUSH_SQUARE:
|
||||
cursor_type = CURSOR_BRUSH;
|
||||
if ((get_brush_size()<<editor->zoom)/2 > 3+(1<<editor->zoom))
|
||||
if ((get_brush_size()<<m_zoom)/2 > 3+(1<<m_zoom))
|
||||
cursor_type |= CURSOR_CROSS_ONE;
|
||||
break;
|
||||
case BRUSH_LINE:
|
||||
@ -145,18 +146,18 @@ void editor_draw_cursor(JWidget widget, int x, int y)
|
||||
|
||||
/* save area and draw the cursor */
|
||||
acquire_bitmap(ji_screen);
|
||||
ji_screen->clip = FALSE;
|
||||
for_each_pixel_of_brush(editor, x, y, color, savepixel);
|
||||
for_each_pixel_of_brush(editor, x, y, color, drawpixel);
|
||||
ji_screen->clip = TRUE;
|
||||
ji_screen->clip = false;
|
||||
for_each_pixel_of_brush(x, y, color, savepixel);
|
||||
for_each_pixel_of_brush(x, y, color, drawpixel);
|
||||
ji_screen->clip = true;
|
||||
release_bitmap(ji_screen);
|
||||
|
||||
/* cursor thickness */
|
||||
editor->cursor_thick = get_thickness_for_cursor();
|
||||
m_cursor_thick = get_thickness_for_cursor();
|
||||
|
||||
/* cursor in the editor (model) */
|
||||
editor->cursor_editor_x = x;
|
||||
editor->cursor_editor_y = y;
|
||||
m_cursor_editor_x = x;
|
||||
m_cursor_editor_y = y;
|
||||
|
||||
/* save the clipping-region to know where to clean the pixels */
|
||||
if (old_clipping_region)
|
||||
@ -177,26 +178,25 @@ void editor_draw_cursor(JWidget widget, int x, int y)
|
||||
*
|
||||
* @see editor_draw_cursor
|
||||
*/
|
||||
void editor_clean_cursor(JWidget widget)
|
||||
void Editor::editor_clean_cursor()
|
||||
{
|
||||
Editor *editor = editor_data(widget);
|
||||
int x, y;
|
||||
|
||||
assert(editor->cursor_thick != 0);
|
||||
assert(m_cursor_thick != 0);
|
||||
|
||||
clipping_region = jwidget_get_drawable_region(widget, JI_GDR_CUTTOPWINDOWS);
|
||||
clipping_region = jwidget_get_drawable_region(this, JI_GDR_CUTTOPWINDOWS);
|
||||
|
||||
x = editor->cursor_editor_x;
|
||||
y = editor->cursor_editor_y;
|
||||
x = m_cursor_editor_x;
|
||||
y = m_cursor_editor_y;
|
||||
|
||||
/* restore points */
|
||||
acquire_bitmap(ji_screen);
|
||||
ji_screen->clip = FALSE;
|
||||
for_each_pixel_of_brush(editor, x, y, 0, cleanpixel);
|
||||
ji_screen->clip = TRUE;
|
||||
ji_screen->clip = false;
|
||||
for_each_pixel_of_brush(x, y, 0, cleanpixel);
|
||||
ji_screen->clip = true;
|
||||
release_bitmap(ji_screen);
|
||||
|
||||
editor->cursor_thick = 0;
|
||||
m_cursor_thick = 0;
|
||||
|
||||
jregion_free(clipping_region);
|
||||
if (old_clipping_region)
|
||||
@ -211,13 +211,12 @@ void editor_clean_cursor(JWidget widget)
|
||||
* movement (a little pixel of the screen that indicates where is the
|
||||
* mouse inside the pixel of the sprite).
|
||||
*/
|
||||
bool editor_cursor_is_subpixel(JWidget widget)
|
||||
bool Editor::editor_cursor_is_subpixel()
|
||||
{
|
||||
Editor *editor = editor_data(widget);
|
||||
return IS_SUBPIXEL(editor);
|
||||
return IS_SUBPIXEL(this);
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void generate_cursor_boundaries()
|
||||
{
|
||||
@ -238,23 +237,23 @@ static void generate_cursor_boundaries()
|
||||
}
|
||||
}
|
||||
|
||||
static void for_each_pixel_of_brush(Editor *editor, int x, int y, int color,
|
||||
void (*pixel) (BITMAP *bmp, int x, int y, int color))
|
||||
void Editor::for_each_pixel_of_brush(int x, int y, int color,
|
||||
void (*pixel)(BITMAP *bmp, int x, int y, int color))
|
||||
{
|
||||
saved_pixel_n = 0;
|
||||
|
||||
if (cursor_type & CURSOR_CROSS_ONE) {
|
||||
editor_cursor_cross(editor, x, y, color, 1, pixel);
|
||||
editor_cursor_cross(this, x, y, color, 1, pixel);
|
||||
}
|
||||
|
||||
if (cursor_type & CURSOR_BRUSH) {
|
||||
editor_cursor_brush(editor, x, y, color, pixel);
|
||||
editor_cursor_brush(this, x, y, color, pixel);
|
||||
}
|
||||
|
||||
if (IS_SUBPIXEL(editor)) {
|
||||
if (IS_SUBPIXEL(this)) {
|
||||
(*pixel)(ji_screen,
|
||||
editor->cursor_screen_x,
|
||||
editor->cursor_screen_y, color);
|
||||
m_cursor_screen_x,
|
||||
m_cursor_screen_y, color);
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,19 +271,20 @@ static void editor_cursor_cross(Editor *editor, int x, int y, int color, int thi
|
||||
0, 0, 1, 1, 0, 0,
|
||||
};
|
||||
int u, v, xout, yout;
|
||||
int zoom = editor->editor_get_zoom();
|
||||
|
||||
for (v=0; v<6; v++) {
|
||||
for (u=0; u<6; u++) {
|
||||
if (cursor_cross[v*6+u]) {
|
||||
editor_to_screen(editor->widget, x, y, &xout, &yout);
|
||||
editor->editor_to_screen(x, y, &xout, &yout);
|
||||
|
||||
xout += ((u<3) ?
|
||||
u-((thickness>>1)<<editor->zoom)-3:
|
||||
u-((thickness>>1)<<editor->zoom)-3+(thickness<<editor->zoom));
|
||||
u-((thickness>>1)<<zoom)-3:
|
||||
u-((thickness>>1)<<zoom)-3+(thickness<<zoom));
|
||||
|
||||
yout += ((v<3)?
|
||||
v-((thickness>>1)<<editor->zoom)-3:
|
||||
v-((thickness>>1)<<editor->zoom)-3+(thickness<<editor->zoom));
|
||||
v-((thickness>>1)<<zoom)-3:
|
||||
v-((thickness>>1)<<zoom)-3+(thickness<<zoom));
|
||||
|
||||
(*pixel)(ji_screen, xout, yout, color);
|
||||
}
|
||||
@ -308,8 +308,8 @@ static void editor_cursor_brush(Editor *editor, int x, int y, int color, void (*
|
||||
x2 = seg->x2 - cursor_bound.brush_size/2;
|
||||
y2 = seg->y2 - cursor_bound.brush_size/2;
|
||||
|
||||
editor_to_screen(editor->widget, x+x1, y+y1, &x1, &y1);
|
||||
editor_to_screen(editor->widget, x+x2, y+y2, &x2, &y2);
|
||||
editor->editor_to_screen(x+x1, y+y1, &x1, &y1);
|
||||
editor->editor_to_screen(x+x2, y+y2, &x2, &y2);
|
||||
|
||||
if (seg->open) { /* outside */
|
||||
if (x1 == x2) {
|
||||
@ -336,8 +336,8 @@ static void editor_cursor_brush(Editor *editor, int x, int y, int color, void (*
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* extra routines */
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Helpers
|
||||
|
||||
static void savepixel(BITMAP *bmp, int x, int y, int color)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,14 +34,12 @@
|
||||
#include "widgets/colbar.h"
|
||||
#include "widgets/editor.h"
|
||||
|
||||
int editor_keys_toset_zoom(JWidget widget, int scancode)
|
||||
bool Editor::editor_keys_toset_zoom(int scancode)
|
||||
{
|
||||
Editor *editor = editor_data (widget);
|
||||
|
||||
if ((editor->sprite) &&
|
||||
(jwidget_has_mouse (widget)) &&
|
||||
if ((m_sprite) &&
|
||||
(jwidget_has_mouse(this)) &&
|
||||
!(key_shifts & (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG))) {
|
||||
JWidget view = jwidget_get_view(widget);
|
||||
JWidget view = jwidget_get_view(this);
|
||||
JRect vp = jview_get_viewport_position(view);
|
||||
int x, y, zoom;
|
||||
|
||||
@ -60,42 +58,40 @@ int editor_keys_toset_zoom(JWidget widget, int scancode)
|
||||
|
||||
/* zoom */
|
||||
if (zoom >= 0) {
|
||||
hide_drawing_cursor(widget);
|
||||
screen_to_editor(widget, jmouse_x(0), jmouse_y(0), &x, &y);
|
||||
hide_drawing_cursor();
|
||||
screen_to_editor(jmouse_x(0), jmouse_y(0), &x, &y);
|
||||
|
||||
x = editor->offset_x - jrect_w(vp)/2 + ((1<<zoom)>>1) + (x << zoom);
|
||||
y = editor->offset_y - jrect_h(vp)/2 + ((1<<zoom)>>1) + (y << zoom);
|
||||
x = m_offset_x - jrect_w(vp)/2 + ((1<<zoom)>>1) + (x << zoom);
|
||||
y = m_offset_y - jrect_h(vp)/2 + ((1<<zoom)>>1) + (y << zoom);
|
||||
|
||||
if ((editor->zoom != zoom) ||
|
||||
(editor->cursor_editor_x != (vp->x1+vp->x2)/2) ||
|
||||
(editor->cursor_editor_y != (vp->y1+vp->y2)/2)) {
|
||||
int use_refresh_region = (editor->zoom == zoom) ? TRUE: FALSE;
|
||||
if ((m_zoom != zoom) ||
|
||||
(m_cursor_editor_x != (vp->x1+vp->x2)/2) ||
|
||||
(m_cursor_editor_y != (vp->y1+vp->y2)/2)) {
|
||||
int use_refresh_region = (m_zoom == zoom) ? TRUE: FALSE;
|
||||
|
||||
editor->zoom = zoom;
|
||||
m_zoom = zoom;
|
||||
|
||||
editor_update(widget);
|
||||
editor_set_scroll(widget, x, y, use_refresh_region);
|
||||
editor_update();
|
||||
editor_set_scroll(x, y, use_refresh_region);
|
||||
|
||||
jmouse_set_position((vp->x1+vp->x2)/2, (vp->y1+vp->y2)/2);
|
||||
jrect_free(vp);
|
||||
|
||||
show_drawing_cursor(widget);
|
||||
return TRUE;
|
||||
show_drawing_cursor();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
jrect_free(vp);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
int editor_keys_toset_brushsize(JWidget widget, int scancode)
|
||||
bool Editor::editor_keys_toset_brushsize(int scancode)
|
||||
{
|
||||
Editor *editor = editor_data(widget);
|
||||
|
||||
if ((editor->sprite) &&
|
||||
(jwidget_has_mouse (widget)) &&
|
||||
if ((m_sprite) &&
|
||||
(jwidget_has_mouse(this)) &&
|
||||
!(key_shifts & (KB_SHIFT_FLAG | KB_CTRL_FLAG | KB_ALT_FLAG))) {
|
||||
/* TODO configurable keys */
|
||||
/* set the thickness */
|
||||
|
Loading…
x
Reference in New Issue
Block a user