2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-13 17:44:30 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-13 17:44:30 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_image/space_image.c
|
|
|
|
* \ingroup spimage
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2012-02-19 22:17:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
#include "BLI_rand.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
#include "BKE_colortools.h"
|
2008-12-18 02:56:48 +00:00
|
|
|
#include "BKE_context.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "BKE_image.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_main.h"
|
2009-04-22 18:39:44 +00:00
|
|
|
#include "BKE_mesh.h"
|
2011-11-08 13:07:16 +00:00
|
|
|
#include "BKE_scene.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
#include "BKE_screen.h"
|
2011-11-10 03:40:02 +00:00
|
|
|
#include "BKE_tessmesh.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "ED_image.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "ED_mesh.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
#include "ED_space_api.h"
|
|
|
|
#include "ED_screen.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "ED_uvedit.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
#include "image_intern.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2010-01-20 04:19:55 +00:00
|
|
|
/**************************** common state *****************************/
|
|
|
|
|
|
|
|
/* note; image_panel_properties() uses pointer to sima->image directly */
|
|
|
|
Image *ED_space_image(SpaceImage *sima)
|
|
|
|
{
|
|
|
|
return sima->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* called to assign images to UV faces */
|
2011-11-10 13:39:25 +00:00
|
|
|
void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *ima)
|
2010-01-20 04:19:55 +00:00
|
|
|
{
|
2011-11-10 13:39:25 +00:00
|
|
|
/* context may be NULL, so use global */
|
|
|
|
ED_uvedit_assign_image(G.main, scene, obedit, ima, sima->image);
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-04-24 19:59:06 +00:00
|
|
|
/* change the space ima after because uvedit_face_visible_test uses the space ima
|
2010-01-20 04:19:55 +00:00
|
|
|
* to check if the face is displayed in UV-localview */
|
2012-03-28 11:53:18 +00:00
|
|
|
sima->image = ima;
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (ima == NULL || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)
|
2010-01-20 04:19:55 +00:00
|
|
|
sima->flag &= ~SI_DRAWTOOL;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sima->image)
|
2010-01-20 04:19:55 +00:00
|
|
|
BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (sima->image && sima->image->id.us == 0)
|
|
|
|
sima->image->id.us = 1;
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit)
|
2012-03-28 11:53:18 +00:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data);
|
2011-11-10 13:39:25 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL);
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r)
|
|
|
|
{
|
|
|
|
ImBuf *ibuf;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sima && sima->image) {
|
2010-01-20 04:19:55 +00:00
|
|
|
#if 0
|
2012-03-28 11:53:18 +00:00
|
|
|
if (sima->image->type == IMA_TYPE_R_RESULT && BIF_show_render_spare())
|
2010-01-20 04:19:55 +00:00
|
|
|
return BIF_render_spare_imbuf();
|
|
|
|
else
|
|
|
|
#endif
|
2012-03-28 11:53:18 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r);
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf && (ibuf->rect || ibuf->rect_float))
|
2010-01-20 04:19:55 +00:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_space_image_release_buffer(SpaceImage *sima, void *lock)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sima && sima->image)
|
2010-01-20 04:19:55 +00:00
|
|
|
BKE_image_release_ibuf(sima->image, lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_space_image_has_buffer(SpaceImage *sima)
|
|
|
|
{
|
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
int has_buffer;
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
ibuf = ED_space_image_acquire_buffer(sima, &lock);
|
|
|
|
has_buffer = (ibuf != NULL);
|
2010-01-20 04:19:55 +00:00
|
|
|
ED_space_image_release_buffer(sima, lock);
|
|
|
|
|
|
|
|
return has_buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_image_size(Image *ima, int *width, int *height)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
ImBuf *ibuf = NULL;
|
2010-01-20 04:19:55 +00:00
|
|
|
void *lock;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima)
|
2012-03-28 11:53:18 +00:00
|
|
|
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
2012-03-28 11:53:18 +00:00
|
|
|
*width = ibuf->x;
|
|
|
|
*height = ibuf->y;
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-28 11:53:18 +00:00
|
|
|
*width = 256;
|
|
|
|
*height = 256;
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima)
|
2010-01-20 04:19:55 +00:00
|
|
|
BKE_image_release_ibuf(ima, lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_space_image_size(SpaceImage *sima, int *width, int *height)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Scene *scene = sima->iuser.scene;
|
2010-01-20 04:19:55 +00:00
|
|
|
ImBuf *ibuf;
|
|
|
|
void *lock;
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
ibuf = ED_space_image_acquire_buffer(sima, &lock);
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf && ibuf->x > 0 && ibuf->y > 0) {
|
2012-03-28 11:53:18 +00:00
|
|
|
*width = ibuf->x;
|
|
|
|
*height = ibuf->y;
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
else if (sima->image && sima->image->type == IMA_TYPE_R_RESULT && scene) {
|
2010-01-20 04:19:55 +00:00
|
|
|
/* not very important, just nice */
|
2012-03-28 11:53:18 +00:00
|
|
|
*width = (scene->r.xsch * scene->r.size) / 100;
|
|
|
|
*height = (scene->r.ysch * scene->r.size) / 100;
|
2010-04-23 18:02:50 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) {
|
2010-04-23 18:02:50 +00:00
|
|
|
*width *= (scene->r.border.xmax - scene->r.border.xmin);
|
|
|
|
*height *= (scene->r.border.ymax - scene->r.border.ymin);
|
|
|
|
}
|
|
|
|
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
/* I know a bit weak... but preview uses not actual image size */
|
2012-03-24 06:38:07 +00:00
|
|
|
// XXX else if (image_preview_active(sima, width, height));
|
2010-01-20 04:19:55 +00:00
|
|
|
else {
|
2012-03-28 11:53:18 +00:00
|
|
|
*width = 256;
|
|
|
|
*height = 256;
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ED_space_image_release_buffer(sima, lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_image_aspect(Image *ima, float *aspx, float *aspy)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
*aspx = *aspy = 1.0;
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
|
2012-03-28 11:53:18 +00:00
|
|
|
(ima->aspx == 0.0f || ima->aspy == 0.0f))
|
2012-04-28 06:31:57 +00:00
|
|
|
{
|
2010-01-20 04:19:55 +00:00
|
|
|
return;
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
2010-01-20 04:19:55 +00:00
|
|
|
|
|
|
|
/* x is always 1 */
|
2012-03-28 11:53:18 +00:00
|
|
|
*aspy = ima->aspy / ima->aspx;
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_space_image_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
|
|
|
{
|
|
|
|
ED_image_aspect(ED_space_image(sima), aspx, aspy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_space_image_zoom(SpaceImage *sima, ARegion *ar, float *zoomx, float *zoomy)
|
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
ED_space_image_size(sima, &width, &height);
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
*zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width);
|
|
|
|
*zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height);
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
ED_space_image_aspect(sima, aspx, aspy);
|
|
|
|
ED_space_image_size(sima, &w, &h);
|
2010-11-16 17:37:26 +00:00
|
|
|
|
|
|
|
*aspx *= (float)w;
|
|
|
|
*aspy *= (float)h;
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (*aspx < *aspy) {
|
2012-03-28 11:53:18 +00:00
|
|
|
*aspy = *aspy / *aspx;
|
|
|
|
*aspx = 1.0f;
|
2010-11-16 17:37:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-28 11:53:18 +00:00
|
|
|
*aspx = *aspx / *aspy;
|
|
|
|
*aspy = 1.0f;
|
2010-11-16 17:37:26 +00:00
|
|
|
}
|
2010-01-20 04:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_image_uv_aspect(Image *ima, float *aspx, float *aspy)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
ED_image_aspect(ima, aspx, aspy);
|
|
|
|
ED_image_size(ima, &w, &h);
|
|
|
|
|
|
|
|
*aspx *= (float)w;
|
|
|
|
*aspy *= (float)h;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_space_image_show_render(SpaceImage *sima)
|
|
|
|
{
|
|
|
|
return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_space_image_show_paint(SpaceImage *sima)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_space_image_show_render(sima))
|
2010-01-20 04:19:55 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (sima->flag & SI_DRAWTOOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima)))
|
2010-01-20 04:19:55 +00:00
|
|
|
return 0;
|
2010-12-20 05:26:25 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obedit && obedit->type == OB_MESH) {
|
2012-03-02 12:09:49 +00:00
|
|
|
struct BMEditMesh *em = BMEdit_FromObject(obedit);
|
2010-01-20 04:19:55 +00:00
|
|
|
int ret;
|
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
ret = EDBM_mtexpoly_check(em);
|
2010-01-20 04:19:55 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_space_image_show_render(sima))
|
2010-01-20 04:19:55 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ED_space_image_show_paint(sima))
|
|
|
|
if (obedit && obedit->type == OB_MESH) {
|
2012-03-02 12:09:49 +00:00
|
|
|
struct BMEditMesh *em = BMEdit_FromObject(obedit);
|
2010-01-20 04:19:55 +00:00
|
|
|
int ret;
|
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
ret = EDBM_mtexpoly_check(em);
|
2010-01-20 04:19:55 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
static void image_scopes_tag_refresh(ScrArea *sa)
|
2010-01-19 02:26:36 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
|
2010-01-19 02:26:36 +00:00
|
|
|
ARegion *ar;
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2010-01-19 02:26:36 +00:00
|
|
|
/* only while histogram is visible */
|
2012-03-28 11:53:18 +00:00
|
|
|
for (ar = sa->regionbase.first; ar; ar = ar->next) {
|
2010-01-19 02:26:36 +00:00
|
|
|
if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN)
|
|
|
|
return;
|
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
sima->scopes.ok = 0;
|
2010-01-19 02:26:36 +00:00
|
|
|
}
|
|
|
|
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* ******************** manage regions ********************* */
|
|
|
|
|
|
|
|
ARegion *image_has_buttons_region(ScrArea *sa)
|
|
|
|
{
|
|
|
|
ARegion *ar, *arnew;
|
2011-05-20 05:27:31 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar) return ar;
|
2009-02-21 15:31:01 +00:00
|
|
|
|
|
|
|
/* add subdiv level; after header */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
|
2011-05-20 05:27:31 +00:00
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* is error! */
|
2012-03-28 11:53:18 +00:00
|
|
|
if (ar == NULL) return NULL;
|
2009-02-21 15:31:01 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
arnew = MEM_callocN(sizeof(ARegion), "buttons for image");
|
2009-02-21 15:31:01 +00:00
|
|
|
|
|
|
|
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
|
2012-03-28 11:53:18 +00:00
|
|
|
arnew->regiontype = RGN_TYPE_UI;
|
|
|
|
arnew->alignment = RGN_ALIGN_LEFT;
|
2009-02-21 15:31:01 +00:00
|
|
|
|
|
|
|
arnew->flag = RGN_FLAG_HIDDEN;
|
|
|
|
|
|
|
|
return arnew;
|
|
|
|
}
|
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
ARegion *image_has_scope_region(ScrArea *sa)
|
|
|
|
{
|
|
|
|
ARegion *ar, *arnew;
|
2011-05-20 05:27:31 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ar) return ar;
|
2011-05-20 05:27:31 +00:00
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
/* add subdiv level; after buttons */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
|
2011-05-20 05:27:31 +00:00
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
/* is error! */
|
2012-03-28 11:53:18 +00:00
|
|
|
if (ar == NULL) return NULL;
|
2010-01-19 01:32:06 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
arnew = MEM_callocN(sizeof(ARegion), "scopes for image");
|
2010-01-19 01:32:06 +00:00
|
|
|
|
|
|
|
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
|
2012-03-28 11:53:18 +00:00
|
|
|
arnew->regiontype = RGN_TYPE_PREVIEW;
|
|
|
|
arnew->alignment = RGN_ALIGN_RIGHT;
|
2010-01-19 01:32:06 +00:00
|
|
|
|
|
|
|
arnew->flag = RGN_FLAG_HIDDEN;
|
2010-04-06 02:05:54 +00:00
|
|
|
|
|
|
|
image_scopes_tag_refresh(sa);
|
2010-01-19 02:26:36 +00:00
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
return arnew;
|
|
|
|
}
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* ******************** default callbacks for image space ***************** */
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static SpaceLink *image_new(const bContext *UNUSED(C))
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
SpaceImage *simage;
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
simage = MEM_callocN(sizeof(SpaceImage), "initimage");
|
|
|
|
simage->spacetype = SPACE_IMAGE;
|
|
|
|
simage->zoom = 1;
|
|
|
|
simage->lock = 1;
|
|
|
|
|
|
|
|
simage->iuser.ok = 1;
|
|
|
|
simage->iuser.fie_ima = 2;
|
|
|
|
simage->iuser.frames = 100;
|
2010-05-10 01:46:44 +00:00
|
|
|
|
|
|
|
scopes_new(&simage->scopes);
|
2012-03-28 11:53:18 +00:00
|
|
|
simage->sample_line_hist.height = 100;
|
2009-12-04 04:56:42 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* header */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "header for image");
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
BLI_addtail(&simage->regionbase, ar);
|
2012-03-28 11:53:18 +00:00
|
|
|
ar->regiontype = RGN_TYPE_HEADER;
|
|
|
|
ar->alignment = RGN_ALIGN_BOTTOM;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* buttons/list view */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "buttons for image");
|
2009-02-21 15:31:01 +00:00
|
|
|
|
|
|
|
BLI_addtail(&simage->regionbase, ar);
|
2012-03-28 11:53:18 +00:00
|
|
|
ar->regiontype = RGN_TYPE_UI;
|
|
|
|
ar->alignment = RGN_ALIGN_LEFT;
|
2009-02-21 15:31:01 +00:00
|
|
|
ar->flag = RGN_FLAG_HIDDEN;
|
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
/* scopes */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "buttons for image");
|
2010-01-19 01:32:06 +00:00
|
|
|
|
|
|
|
BLI_addtail(&simage->regionbase, ar);
|
2012-03-28 11:53:18 +00:00
|
|
|
ar->regiontype = RGN_TYPE_PREVIEW;
|
|
|
|
ar->alignment = RGN_ALIGN_RIGHT;
|
2010-01-19 01:32:06 +00:00
|
|
|
ar->flag = RGN_FLAG_HIDDEN;
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* main area */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar = MEM_callocN(sizeof(ARegion), "main area for image");
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
BLI_addtail(&simage->regionbase, ar);
|
2012-03-28 11:53:18 +00:00
|
|
|
ar->regiontype = RGN_TYPE_WINDOW;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
return (SpaceLink *)simage;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not spacelink itself */
|
|
|
|
static void image_free(SpaceLink *sl)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *simage = (SpaceImage *) sl;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (simage->cumap)
|
2008-12-13 17:44:30 +00:00
|
|
|
curvemapping_free(simage->cumap);
|
2010-04-06 02:05:54 +00:00
|
|
|
scopes_free(&simage->scopes);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
/* spacetype; init callback, add handlers */
|
2010-10-14 12:24:08 +00:00
|
|
|
static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
|
2008-12-13 17:44:30 +00:00
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
/* add drop boxes */
|
|
|
|
WM_event_add_dropbox_handler(&sa->handlers, lb);
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static SpaceLink *image_duplicate(SpaceLink *sl)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *simagen = MEM_dupallocN(sl);
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
/* clear or remove stuff from old */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (simagen->cumap)
|
2012-03-28 11:53:18 +00:00
|
|
|
simagen->cumap = curvemapping_copy(simagen->cumap);
|
2011-03-23 14:24:13 +00:00
|
|
|
|
|
|
|
scopes_new(&simagen->scopes);
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
return (SpaceLink *)simagen;
|
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void image_operatortypes(void)
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
|
|
|
WM_operatortype_append(IMAGE_OT_view_all);
|
|
|
|
WM_operatortype_append(IMAGE_OT_view_pan);
|
|
|
|
WM_operatortype_append(IMAGE_OT_view_selected);
|
|
|
|
WM_operatortype_append(IMAGE_OT_view_zoom);
|
|
|
|
WM_operatortype_append(IMAGE_OT_view_zoom_in);
|
|
|
|
WM_operatortype_append(IMAGE_OT_view_zoom_out);
|
|
|
|
WM_operatortype_append(IMAGE_OT_view_zoom_ratio);
|
2011-06-25 18:51:29 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_view_ndof);
|
2009-01-30 12:58:00 +00:00
|
|
|
|
2009-02-10 23:17:58 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_new);
|
|
|
|
WM_operatortype_append(IMAGE_OT_open);
|
2012-06-01 17:28:09 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_match_movie_length);
|
2009-02-10 23:17:58 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_replace);
|
|
|
|
WM_operatortype_append(IMAGE_OT_reload);
|
|
|
|
WM_operatortype_append(IMAGE_OT_save);
|
|
|
|
WM_operatortype_append(IMAGE_OT_save_as);
|
|
|
|
WM_operatortype_append(IMAGE_OT_save_sequence);
|
|
|
|
WM_operatortype_append(IMAGE_OT_pack);
|
|
|
|
WM_operatortype_append(IMAGE_OT_unpack);
|
2011-02-23 12:02:43 +00:00
|
|
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_invert);
|
2009-02-11 19:16:14 +00:00
|
|
|
|
2010-02-09 19:37:37 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_cycle_render_slot);
|
|
|
|
|
2009-02-10 23:17:58 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_sample);
|
2010-03-23 01:22:33 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_sample_line);
|
2009-03-29 02:15:13 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_curves_point_set);
|
2009-02-10 23:17:58 +00:00
|
|
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_record_composite);
|
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_properties);
|
2010-01-19 01:32:06 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_scopes);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void image_keymap(struct wmKeyConfig *keyconf)
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
2012-03-24 02:51:46 +00:00
|
|
|
wmKeyMap *keymap = WM_keymap_find(keyconf, "Image Generic", SPACE_IMAGE, 0);
|
2010-10-13 01:58:09 +00:00
|
|
|
wmKeyMapItem *kmi;
|
2012-03-30 16:09:12 +00:00
|
|
|
int i;
|
2009-02-21 15:31:01 +00:00
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0);
|
2009-11-01 00:06:53 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0);
|
2009-02-21 15:31:01 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0);
|
2011-03-02 16:52:09 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_scopes", TKEY, KM_PRESS, 0, 0);
|
2010-02-09 19:37:37 +00:00
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0);
|
2010-12-13 05:02:23 +00:00
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, KM_ALT, 0)->ptr, "reverse", TRUE);
|
2009-02-21 15:31:01 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, 0, 0);
|
2010-09-30 21:07:42 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
|
2010-01-11 11:14:36 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_pan", MOUSEPAN, 0, 0, 0);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2011-06-25 18:51:29 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); // or view selected?
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_ndof", NDOF_MOTION, 0, 0, 0);
|
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", WHEELINMOUSE, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", WHEELOUTMOUSE, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_out", PADMINUS, KM_PRESS, 0, 0);
|
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
|
2010-01-11 11:14:36 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom", MOUSEZOOM, 0, 0, 0);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
|
|
|
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
|
|
|
|
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
|
|
|
|
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
|
|
|
|
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
|
|
|
|
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
|
|
|
|
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
|
|
|
|
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
|
2009-01-30 12:58:00 +00:00
|
|
|
|
2009-02-10 23:17:58 +00:00
|
|
|
WM_keymap_add_item(keymap, "IMAGE_OT_sample", ACTIONMOUSE, KM_PRESS, 0, 0);
|
2009-03-29 02:15:13 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "point", 0);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "IMAGE_OT_curves_point_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "point", 1);
|
2009-02-10 23:17:58 +00:00
|
|
|
|
2010-10-13 01:58:09 +00:00
|
|
|
/* toggle editmode is handy to have while UV unwrapping */
|
2012-03-24 02:51:46 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
|
2010-10-13 01:58:09 +00:00
|
|
|
RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
|
2012-01-16 09:51:04 +00:00
|
|
|
RNA_boolean_set(kmi->ptr, "toggle", TRUE);
|
2012-03-30 16:09:12 +00:00
|
|
|
|
|
|
|
/* fast switch to render slots */
|
2012-04-21 12:51:47 +00:00
|
|
|
for (i = 0; i < MAX2(IMA_MAX_RENDER_SLOT, 9); i++) {
|
2012-06-17 09:58:26 +00:00
|
|
|
kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY + i, KM_PRESS, 0, 0);
|
2012-03-30 16:09:12 +00:00
|
|
|
RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slot");
|
|
|
|
RNA_int_set(kmi->ptr, "value", i);
|
|
|
|
}
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
|
|
|
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
/* dropboxes */
|
2010-10-14 12:24:08 +00:00
|
|
|
static int image_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
if (drag->type == WM_DRAG_PATH)
|
|
|
|
if (ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
{
|
|
|
|
/* copy drag path to properties */
|
2010-06-14 03:52:10 +00:00
|
|
|
RNA_string_set(drop->ptr, "filepath", drag->path);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* area+region dropbox definition */
|
|
|
|
static void image_dropboxes(void)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
|
|
|
WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static void image_refresh(const bContext *C, ScrArea *UNUSED(sa))
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
2011-11-08 13:07:16 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
Image *ima;
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
ima = ED_space_image(sima);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-06-04 10:41:18 +00:00
|
|
|
BKE_image_user_check_frame_calc(&sima->iuser, scene->r.cfra, 0);
|
2010-03-16 08:06:50 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/* check if we have to set the image from the editmesh */
|
2012-03-28 11:53:18 +00:00
|
|
|
if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) ;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (obedit && obedit->type == OB_MESH) {
|
2012-03-28 11:53:18 +00:00
|
|
|
Mesh *me = (Mesh *)obedit->data;
|
|
|
|
struct BMEditMesh *em = me->edit_btmesh;
|
|
|
|
int sloppy = 1; /* partially selected face is ok */
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-05-05 14:33:36 +00:00
|
|
|
if (BKE_scene_use_new_shading_nodes(scene)) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* new shading system, get image from material */
|
2012-02-12 10:51:45 +00:00
|
|
|
BMFace *efa = BM_active_face_get(em->bm, sloppy);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (efa) {
|
2012-01-12 21:10:30 +00:00
|
|
|
Image *node_ima;
|
2012-04-02 22:26:00 +00:00
|
|
|
ED_object_get_active_image(obedit, efa->mat_nr + 1, &node_ima, NULL, NULL);
|
2012-01-12 21:10:30 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node_ima)
|
2012-03-28 11:53:18 +00:00
|
|
|
sima->image = node_ima;
|
2012-01-12 21:10:30 +00:00
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* old shading system, we set texface */
|
2011-11-10 03:05:11 +00:00
|
|
|
MTexPoly *tf;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
if (em && EDBM_mtexpoly_check(em)) {
|
2012-03-28 11:53:18 +00:00
|
|
|
sima->image = NULL;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-27 04:46:52 +00:00
|
|
|
tf = EDBM_mtexpoly_active_get(em, NULL, TRUE); /* partially selected face is ok */
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tf) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* don't need to check for pin here, see above */
|
2012-03-28 11:53:18 +00:00
|
|
|
sima->image = tf->tpage;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
if (sima->flag & SI_EDITTILE) ;
|
|
|
|
else sima->curtile = tf->tile;
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_listener(ScrArea *sa, wmNotifier *wmn)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
|
2010-01-19 01:32:06 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->category) {
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
case NC_SCENE:
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->data) {
|
2010-03-16 08:06:50 +00:00
|
|
|
case ND_FRAME:
|
2010-04-06 02:05:54 +00:00
|
|
|
image_scopes_tag_refresh(sa);
|
2010-03-28 23:30:00 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
break;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
case ND_MODE:
|
2009-01-27 17:12:40 +00:00
|
|
|
case ND_RENDER_RESULT:
|
|
|
|
case ND_COMPO_RESULT:
|
2010-01-20 04:19:55 +00:00
|
|
|
if (ED_space_image_show_render(sima))
|
2010-04-06 02:05:54 +00:00
|
|
|
image_scopes_tag_refresh(sa);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
2010-03-16 08:06:50 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2009-12-30 14:37:25 +00:00
|
|
|
case NC_IMAGE:
|
2010-01-31 23:25:57 +00:00
|
|
|
if (wmn->reference == sima->image || !wmn->reference) {
|
2010-04-06 02:05:54 +00:00
|
|
|
image_scopes_tag_refresh(sa);
|
2010-01-19 01:32:06 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
2009-02-11 19:16:14 +00:00
|
|
|
break;
|
2009-09-16 17:43:09 +00:00
|
|
|
case NC_SPACE:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->data == ND_SPACE_IMAGE) {
|
2010-04-06 02:05:54 +00:00
|
|
|
image_scopes_tag_refresh(sa);
|
2009-09-16 17:43:09 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
2010-03-28 23:30:00 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
break;
|
|
|
|
case NC_GEOM:
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->data) {
|
2009-09-16 17:43:09 +00:00
|
|
|
case ND_DATA:
|
|
|
|
case ND_SELECT:
|
2010-12-13 14:47:31 +00:00
|
|
|
image_scopes_tag_refresh(sa);
|
2009-12-14 18:15:48 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
2009-07-08 15:34:41 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
break;
|
|
|
|
}
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
case NC_OBJECT:
|
2010-11-15 07:07:14 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Object *ob = (Object *)wmn->reference;
|
|
|
|
switch (wmn->data) {
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
case ND_TRANSFORM:
|
2010-11-15 07:07:14 +00:00
|
|
|
case ND_MODIFIER:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob && (ob->mode & OB_MODE_EDIT) && sima->lock && (sima->flag & SI_DRAWSHADOW)) {
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
ED_area_tag_refresh(sa);
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-11-15 07:07:14 +00:00
|
|
|
}
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-15 14:38:43 +00:00
|
|
|
const char *image_context_dir[] = {"edit_image", NULL};
|
|
|
|
|
2009-03-19 19:03:38 +00:00
|
|
|
static int image_context(const bContext *C, const char *member, bContextDataResult *result)
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_data_dir(member)) {
|
2011-02-15 14:38:43 +00:00
|
|
|
CTX_data_dir_set(result, image_context_dir);
|
2009-06-20 14:55:28 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "edit_image")) {
|
2012-03-28 11:53:18 +00:00
|
|
|
CTX_data_id_pointer_set(result, (ID *)ED_space_image(sima));
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************** main region ***************************/
|
|
|
|
|
|
|
|
/* sets up the fields of the View2D from zoom and offset */
|
2009-10-22 23:22:05 +00:00
|
|
|
static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar)
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
Image *ima = ED_space_image(sima);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
float x1, y1, w, h;
|
|
|
|
int width, height, winx, winy;
|
|
|
|
|
|
|
|
#if 0
|
2012-03-28 11:53:18 +00:00
|
|
|
if (image_preview_active(curarea, &width, &height)) ;
|
2009-02-17 21:07:01 +00:00
|
|
|
else
|
2009-10-22 23:22:05 +00:00
|
|
|
#endif
|
|
|
|
ED_space_image_size(sima, &width, &height);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
w = width;
|
|
|
|
h = height;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ima)
|
2012-03-28 11:53:18 +00:00
|
|
|
h *= ima->aspy / ima->aspx;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
winx = ar->winrct.xmax - ar->winrct.xmin + 1;
|
|
|
|
winy = ar->winrct.ymax - ar->winrct.ymin + 1;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->v2d.tot.xmin = 0;
|
|
|
|
ar->v2d.tot.ymin = 0;
|
|
|
|
ar->v2d.tot.xmax = w;
|
|
|
|
ar->v2d.tot.ymax = h;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
ar->v2d.mask.xmin = ar->v2d.mask.ymin = 0;
|
|
|
|
ar->v2d.mask.xmax = winx;
|
|
|
|
ar->v2d.mask.ymax = winy;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/* which part of the image space do we see? */
|
2012-03-28 11:53:18 +00:00
|
|
|
x1 = ar->winrct.xmin + (winx - sima->zoom * w) / 2.0f;
|
|
|
|
y1 = ar->winrct.ymin + (winy - sima->zoom * h) / 2.0f;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
x1 -= sima->zoom * sima->xof;
|
|
|
|
y1 -= sima->zoom * sima->yof;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
|
|
|
/* relative display right */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1) / sima->zoom);
|
|
|
|
ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sima->zoom);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
|
|
|
/* relative display left */
|
2012-03-28 11:53:18 +00:00
|
|
|
ar->v2d.cur.ymin = ((ar->winrct.ymin - (float)y1) / sima->zoom);
|
|
|
|
ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sima->zoom);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
|
|
|
|
/* normalize 0.0..1.0 */
|
|
|
|
ar->v2d.cur.xmin /= w;
|
|
|
|
ar->v2d.cur.xmax /= w;
|
|
|
|
ar->v2d.cur.ymin /= h;
|
|
|
|
ar->v2d.cur.ymax /= h;
|
|
|
|
}
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
wmKeyMap *keymap;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
// image space manages own v2d
|
|
|
|
// UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
|
2009-02-19 23:53:40 +00:00
|
|
|
|
|
|
|
/* image paint polls for mode */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Image Paint", 0, 0);
|
2009-02-19 23:53:40 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "UV Editor", 0, 0);
|
2009-10-22 23:22:05 +00:00
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "UV Sculpt", 0, 0);
|
2012-01-17 16:31:13 +00:00
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* own keymaps */
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
|
2009-02-21 15:31:01 +00:00
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Image", SPACE_IMAGE, 0);
|
2008-12-13 17:44:30 +00:00
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void image_main_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
/* draw entirely, view changes should be handled here */
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
Object *obact = CTX_data_active_object(C);
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
View2D *v2d = &ar->v2d;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
//View2DScrollers *scrollers;
|
2008-12-13 17:44:30 +00:00
|
|
|
float col[3];
|
|
|
|
|
2011-01-04 15:19:16 +00:00
|
|
|
/* XXX not supported yet, disabling for now */
|
|
|
|
scene->r.scemode &= ~R_COMP_CROP;
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* clear and setup matrix */
|
|
|
|
UI_GetThemeColor3fv(TH_BACK, col);
|
|
|
|
glClearColor(col[0], col[1], col[2], 0.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
|
|
|
/* put scene context variable in iuser */
|
2012-03-28 11:53:18 +00:00
|
|
|
sima->iuser.scene = scene;
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/* we set view2d from own zoom and offset each time */
|
2009-10-22 23:22:05 +00:00
|
|
|
image_main_area_set_view2d(sima, ar);
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/* we draw image in pixelspace */
|
|
|
|
draw_image_main(sima, ar, scene);
|
|
|
|
|
|
|
|
/* and uvs in 0.0-1.0 space */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2012-01-17 16:31:13 +00:00
|
|
|
draw_uvedit_main(sima, ar, scene, obedit, obact);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2009-11-01 00:06:53 +00:00
|
|
|
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
|
2012-06-10 12:09:25 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* Grease Pencil too (in addition to UV's) */
|
|
|
|
draw_image_grease_pencil((bContext *)C, 1);
|
|
|
|
|
2012-06-10 12:09:25 +00:00
|
|
|
/* sample line */
|
|
|
|
draw_image_sample_line(sima);
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
UI_view2d_view_restore(C);
|
2009-11-01 00:06:53 +00:00
|
|
|
|
2009-09-16 17:43:09 +00:00
|
|
|
/* draw Grease Pencil - screen space only */
|
|
|
|
draw_image_grease_pencil((bContext *)C, 0);
|
2012-06-10 12:09:25 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* scrollers? */
|
2012-03-03 16:31:46 +00:00
|
|
|
#if 0
|
2012-03-28 11:53:18 +00:00
|
|
|
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
2012-03-03 16:31:46 +00:00
|
|
|
UI_view2d_scrollers_free(scrollers);
|
|
|
|
#endif
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
static void image_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->category) {
|
2010-04-05 06:52:27 +00:00
|
|
|
case NC_SCREEN:
|
2012-03-28 11:53:18 +00:00
|
|
|
if (wmn->data == ND_GPENCIL)
|
2010-04-05 06:52:27 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
2012-03-28 11:53:18 +00:00
|
|
|
break;
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
}
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* *********************** buttons region ************************ */
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void image_buttons_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
wmKeyMap *keymap;
|
2009-05-19 17:13:33 +00:00
|
|
|
|
|
|
|
ED_region_panels_init(wm, ar);
|
2009-02-21 15:31:01 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
|
2009-02-21 15:31:01 +00:00
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_buttons_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
2009-07-29 22:57:53 +00:00
|
|
|
ED_region_panels(C, ar, 1, NULL, -1);
|
2009-02-21 15:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
|
|
|
|
{
|
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->category) {
|
2010-04-05 06:52:27 +00:00
|
|
|
case NC_SCREEN:
|
2012-03-28 11:53:18 +00:00
|
|
|
if (wmn->data == ND_GPENCIL)
|
2010-04-05 06:52:27 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
2009-10-22 23:22:05 +00:00
|
|
|
case NC_BRUSH:
|
2012-03-28 11:53:18 +00:00
|
|
|
if (wmn->action == NA_EDITED)
|
2009-10-22 23:22:05 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
2012-02-17 16:06:32 +00:00
|
|
|
case NC_TEXTURE:
|
|
|
|
case NC_MATERIAL:
|
|
|
|
/* sending by texture render job and needed to properly update displaying
|
|
|
|
* brush texture icon */
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
2009-02-21 15:31:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
/* *********************** scopes region ************************ */
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void image_scope_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
|
|
|
wmKeyMap *keymap;
|
|
|
|
|
|
|
|
ED_region_panels_init(wm, ar);
|
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0);
|
2010-01-19 01:32:06 +00:00
|
|
|
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_scope_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2010-01-28 07:26:21 +00:00
|
|
|
void *lock;
|
2012-03-28 11:53:18 +00:00
|
|
|
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf) {
|
2012-06-13 22:38:31 +00:00
|
|
|
if (!sima->scopes.ok) {
|
|
|
|
BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
|
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT);
|
2010-04-06 02:05:54 +00:00
|
|
|
}
|
2010-01-28 07:26:21 +00:00
|
|
|
ED_space_image_release_buffer(sima, lock);
|
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
ED_region_panels(C, ar, 1, NULL, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void image_scope_area_listener(ARegion *ar, wmNotifier *wmn)
|
|
|
|
{
|
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->category) {
|
2010-01-28 07:26:21 +00:00
|
|
|
case NC_SCENE:
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->data) {
|
2010-01-28 07:26:21 +00:00
|
|
|
case ND_MODE:
|
|
|
|
case ND_RENDER_RESULT:
|
|
|
|
case ND_COMPO_RESULT:
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NC_IMAGE:
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
case NC_NODE:
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/************************* header region **************************/
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2010-10-14 12:24:08 +00:00
|
|
|
static void image_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2009-06-16 01:22:56 +00:00
|
|
|
ED_region_header_init(ar);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void image_header_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
2009-06-16 01:22:56 +00:00
|
|
|
ED_region_header(C, ar);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
2010-03-09 06:49:58 +00:00
|
|
|
static void image_header_area_listener(ARegion *ar, wmNotifier *wmn)
|
|
|
|
{
|
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->category) {
|
2010-03-09 06:49:58 +00:00
|
|
|
case NC_SCENE:
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->data) {
|
2010-03-09 06:49:58 +00:00
|
|
|
case ND_MODE:
|
|
|
|
case ND_TOOLSETTINGS:
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NC_GEOM:
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->data) {
|
2010-03-09 06:49:58 +00:00
|
|
|
case ND_DATA:
|
|
|
|
case ND_SELECT:
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5: Space Image ported back
Organized as follows:
uvedit/
uv editing related code
uvedit_draw.c: drawing code
uvedit_ops.c: operators, just a few done
uvedit_unwrap_ops.c: will be operators for unwrapping
uvedit_paramatrizer.c: lscm/abf/stretch/pack
space_image/
space_image.c: registration and common getter/setters
image_draw.c: drawing code, mostly functional
image_panels.c: panels, all commented out
image_render.c: render callbacks, non functional
image_ops.c: operators, only view navigation done
image_header.c: header, menus mostly done but missing buttons
Notes:
* Header menus consist only of Operator and RNA buttons, if they
are not implemented they're displayed grayed out. Ideally the full
header could work like this, but std_libbuttons looks problematic.
* Started using view2d code more than the old code, but for now it
still does own view2d management due to some very specific
requirements that the image window has. The drawing code however
is more clear hopefully, it only uses view2d, and there is no
switching between 'p' and 'f' view2d's anymore, it is always 'f'.
* In order to make uvedit operators more independent I move some
image space settings to scene toolsettings, and the current image
and its buffer is in the context. Especially sync selection and
select mode belonged there anyway as this cannot work correct with
different spaces having different settings anyway.
* Image paint is not back yet, did not want to put that together with
uvedit because there's really no code sharing.. perhaps vertex paint,
image paint and sculpt would be good to have in one module to share
brush code, partial redraw, etc better.
2009-01-15 04:38:18 +00:00
|
|
|
/**************************** spacetype *****************************/
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
void ED_spacetype_image(void)
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype image");
|
2008-12-13 17:44:30 +00:00
|
|
|
ARegionType *art;
|
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
st->spaceid = SPACE_IMAGE;
|
2009-12-19 22:37:51 +00:00
|
|
|
strncpy(st->name, "Image", BKE_ST_MAXNAME);
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
st->new = image_new;
|
|
|
|
st->free = image_free;
|
|
|
|
st->init = image_init;
|
|
|
|
st->duplicate = image_duplicate;
|
|
|
|
st->operatortypes = image_operatortypes;
|
|
|
|
st->keymap = image_keymap;
|
|
|
|
st->dropboxes = image_dropboxes;
|
|
|
|
st->refresh = image_refresh;
|
|
|
|
st->listener = image_listener;
|
|
|
|
st->context = image_context;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
/* regions: main window */
|
2012-03-28 11:53:18 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
2008-12-13 17:44:30 +00:00
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2012-03-28 11:53:18 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
|
|
|
|
art->init = image_main_area_init;
|
|
|
|
art->draw = image_main_area_draw;
|
|
|
|
art->listener = image_main_area_listener;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* regions: listview/buttons */
|
2012-03-28 11:53:18 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
2009-02-21 15:31:01 +00:00
|
|
|
art->regionid = RGN_TYPE_UI;
|
2012-03-28 11:53:18 +00:00
|
|
|
art->prefsizex = 220; // XXX
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
|
|
|
|
art->listener = image_buttons_area_listener;
|
|
|
|
art->init = image_buttons_area_init;
|
|
|
|
art->draw = image_buttons_area_draw;
|
2009-02-21 15:31:01 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
2009-05-19 17:13:33 +00:00
|
|
|
image_buttons_register(art);
|
2011-05-02 11:11:57 +00:00
|
|
|
ED_uvedit_buttons_register(art);
|
2010-01-19 01:32:06 +00:00
|
|
|
|
|
|
|
/* regions: statistics/scope buttons */
|
2012-03-28 11:53:18 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
2010-01-19 01:32:06 +00:00
|
|
|
art->regionid = RGN_TYPE_PREVIEW;
|
2012-03-28 11:53:18 +00:00
|
|
|
art->prefsizex = 220; // XXX
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
|
|
|
|
art->listener = image_scope_area_listener;
|
|
|
|
art->init = image_scope_area_init;
|
|
|
|
art->draw = image_scope_area_draw;
|
2010-01-19 01:32:06 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* regions: header */
|
2012-03-28 11:53:18 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
2008-12-13 17:44:30 +00:00
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
2012-03-28 11:53:18 +00:00
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
|
|
|
|
art->listener = image_header_area_listener;
|
|
|
|
art->init = image_header_area_init;
|
|
|
|
art->draw = image_header_area_draw;
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
BKE_spacetype_register(st);
|
|
|
|
}
|
2011-05-11 09:31:00 +00:00
|
|
|
|