2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2008 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spimage
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2022-10-13 12:24:47 +02:00
|
|
|
#include "DNA_defaults.h"
|
2023-03-13 10:42:51 +01:00
|
|
|
#include "DNA_gpencil_legacy_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_image_types.h"
|
2012-07-24 19:29:24 +00:00
|
|
|
#include "DNA_mask_types.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2025-02-11 16:59:42 +01:00
|
|
|
#include "BLI_listbase.h"
|
2025-07-27 16:41:19 +10:00
|
|
|
#include "BLI_string_utf8.h"
|
2013-01-15 07:56:38 +00:00
|
|
|
#include "BLI_threads.h"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2023-12-21 10:10:53 +01:00
|
|
|
#include "BKE_colortools.hh"
|
2023-11-16 11:41:55 +01:00
|
|
|
#include "BKE_context.hh"
|
2024-11-12 15:21:59 +01:00
|
|
|
#include "BKE_image.hh"
|
2024-01-23 15:18:09 -05:00
|
|
|
#include "BKE_layer.hh"
|
2024-01-18 12:20:42 +01:00
|
|
|
#include "BKE_lib_query.hh"
|
2023-11-30 19:51:22 +01:00
|
|
|
#include "BKE_lib_remap.hh"
|
2025-05-21 15:57:31 +02:00
|
|
|
#include "BKE_scene.hh"
|
2023-09-25 17:48:21 -04:00
|
|
|
#include "BKE_screen.hh"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
|
|
|
|
#include "RNA_define.hh"
|
|
|
|
|
#include "RNA_enum_types.hh"
|
2018-12-05 14:35:45 +11:00
|
|
|
|
2024-01-18 22:50:23 +02:00
|
|
|
#include "IMB_imbuf_types.hh"
|
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
|
|
|
|
2024-04-24 17:55:37 +02:00
|
|
|
#include "ED_asset_shelf.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_image.hh"
|
|
|
|
|
#include "ED_mask.hh"
|
|
|
|
|
#include "ED_node.hh"
|
|
|
|
|
#include "ED_render.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_space_api.hh"
|
|
|
|
|
#include "ED_transform.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_util.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_uvedit.hh"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
|
|
|
|
#include "UI_view2d.hh"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2023-08-28 15:01:05 +02:00
|
|
|
#include "BLO_read_write.hh"
|
2022-09-28 11:52:22 +02:00
|
|
|
|
2024-01-05 11:16:57 -05:00
|
|
|
#include "DRW_engine.hh"
|
2020-08-06 14:29:33 +02:00
|
|
|
|
2023-12-20 13:17:39 +02:00
|
|
|
#include "image_intern.hh"
|
2008-12-13 17:44:30 +00:00
|
|
|
|
2010-01-20 04:19:55 +00:00
|
|
|
/**************************** common state *****************************/
|
|
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
static void image_scopes_tag_refresh(ScrArea *area)
|
2010-01-19 02:26:36 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceImage *sima = (SpaceImage *)area->spacedata.first;
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2010-01-19 02:26:36 +00:00
|
|
|
/* only while histogram is visible */
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region->regiontype == RGN_TYPE_TOOL_PROPS && region->flag & RGN_FLAG_HIDDEN) {
|
2010-01-19 02:26:36 +00:00
|
|
|
return;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-01-19 02:26:36 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2018-01-17 10:00:14 +11:00
|
|
|
static void image_user_refresh_scene(const bContext *C, SpaceImage *sima)
|
|
|
|
|
{
|
2019-03-11 12:44:14 +01:00
|
|
|
/* Update scene image user for acquiring render results. */
|
|
|
|
|
sima->iuser.scene = CTX_data_scene(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-01-17 10:00:14 +11:00
|
|
|
if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) {
|
2019-03-11 12:44:14 +01:00
|
|
|
/* While rendering, prefer scene that is being rendered. */
|
2018-01-17 10:00:14 +11:00
|
|
|
Scene *render_scene = ED_render_job_get_current_scene(C);
|
|
|
|
|
if (render_scene) {
|
|
|
|
|
sima->iuser.scene = render_scene;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-11 12:44:14 +01:00
|
|
|
/* Auto switch image to show in UV editor when selection changes. */
|
|
|
|
|
ED_space_image_auto_set(C, sima);
|
2018-01-17 10:00:14 +11:00
|
|
|
}
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* ******************** default callbacks for image space ***************** */
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
static SpaceLink *image_create(const ScrArea * /*area*/, const Scene * /*scene*/)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region;
|
2008-12-13 17:44:30 +00:00
|
|
|
SpaceImage *simage;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2025-04-22 11:22:18 +02:00
|
|
|
simage = MEM_callocN<SpaceImage>("initimage");
|
2012-03-28 11:53:18 +00:00
|
|
|
simage->spacetype = SPACE_IMAGE;
|
2012-07-25 10:55:45 +00:00
|
|
|
simage->zoom = 1.0f;
|
2014-04-01 11:34:00 +11:00
|
|
|
simage->lock = true;
|
2018-05-24 21:19:38 +02:00
|
|
|
simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS;
|
2020-04-16 18:10:21 +10:00
|
|
|
simage->uv_opacity = 1.0f;
|
Overlay: Allow drawing UVs in Image Editor in any mode
**Problem**
When using Texture Paint mode, the Image Editor will show a UV Wireframe
to display the active object's UVs. In every other mode, this wireframe
is absent. This is currently a big problem for Sculpt Mode since the
Experimental Texture Paint system is a part of that mode, meaning that
the user can't see their UVs while they paint in Sculpt Mode. This is
also troublesome for users that would like to quickly view an object's
UVs without using Texture Paint Mode.
**Solution**
Since it's useful to be able to view an object's UVs at all times, the
Image Editor should display UV Wireframes in all Object Modes regardless
of the Image Editor's mode. This is the best solution since it means
that future Blender features, that would benefit from having a preview
of an object's UV Wireframes, will automatically have that option since
UV Wireframes are supported in all modes. Also, if a user doesn't want
to see UV Wireframes for any reason, it can be disabled with an Overlay
option.
Additionally, when multiple objects are selected, each object should
have its UV Wireframe drawn in the Image Editor. The selected objects
that aren't active should have less opaque wireframes to indicate which
wireframe belongs to the active object. This is the best approach for
having multiple objects selected since it allows the user to quickly
view the UV layout for all selected objects to troubleshoot UV problems,
like texture mapping. This is especially helpful when using a material
for multiple different objects.
An alternative solution would be to only show the UV Wireframe for the
active object, but this would be undesirable because it would make
troubleshooting UV positions tedious when working with multiple objects
since the user would need to select objects individually.
Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/135102
2025-04-04 21:30:05 +02:00
|
|
|
simage->uv_face_opacity = 1.0f;
|
2024-02-20 11:03:37 +01:00
|
|
|
simage->stretch_opacity = 1.0f;
|
2022-04-08 21:40:05 -07:00
|
|
|
simage->overlay.flag = SI_OVERLAY_SHOW_OVERLAYS | SI_OVERLAY_SHOW_GRID_BACKGROUND;
|
2025-05-21 15:57:31 +02:00
|
|
|
simage->overlay.passepartout_alpha = 0.5f;
|
2012-03-28 11:53:18 +00:00
|
|
|
|
2016-02-20 22:36:02 +01:00
|
|
|
BKE_imageuser_default(&simage->iuser);
|
2022-05-27 10:52:49 +02:00
|
|
|
simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-08-07 03:21:55 +10:00
|
|
|
BKE_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
|
|
|
|
Add support for tiled images and the UDIM naming scheme
This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender.
With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser.
Therefore, code that is not yet aware of tiles will just access the default tile as usual.
The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10*<y coordinate of the tile> + <x coordinate of the tile>), where the x coordinate never goes above 9.
Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator.
The following features are supported so far:
- Automatic detection and loading of all tiles when opening the first tile (1001)
- Saving all tiles
- Adding and removing tiles
- Filling tiles with generated images
- Drawing all tiles in the Image Editor
- Viewing a tiled grid even if no image is selected
- Rendering tiled images in Eevee
- Rendering tiled images in Cycles (in SVM mode)
- Automatically skipping loading of unused tiles in Cycles
- 2D texture painting (also across tiles)
- 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders)
- Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID)
- Different resolutions between tiles
There still are some missing features that will be added later (see T72390):
- Workbench engine support
- Packing/Unpacking support
- Baking support
- Cycles OSL support
- many other Blender features that rely on images
Thanks to Brecht for the review and to all who tested the intermediate versions!
Differential Revision: https://developer.blender.org/D3509
2019-12-12 16:06:08 +01:00
|
|
|
simage->tile_grid_shape[0] = 1;
|
|
|
|
|
simage->tile_grid_shape[1] = 1;
|
|
|
|
|
|
2022-09-18 17:03:40 +12:00
|
|
|
simage->custom_grid_subdiv[0] = 10;
|
|
|
|
|
simage->custom_grid_subdiv[1] = 10;
|
2021-09-29 17:47:32 +10:00
|
|
|
|
2022-10-13 12:24:47 +02:00
|
|
|
simage->mask_info = *DNA_struct_default_get(MaskSpaceInfo);
|
|
|
|
|
|
2021-09-28 14:44:36 +10:00
|
|
|
/* header */
|
2024-11-15 02:00:11 +01:00
|
|
|
region = BKE_area_region_new();
|
2019-04-18 21:13:22 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_addtail(&simage->regionbase, region);
|
2021-09-28 14:44:36 +10:00
|
|
|
region->regiontype = RGN_TYPE_HEADER;
|
2020-03-06 16:56:42 +01:00
|
|
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
2019-04-18 21:13:22 +02:00
|
|
|
|
2024-04-24 17:55:37 +02:00
|
|
|
/* asset shelf */
|
2024-11-15 02:00:11 +01:00
|
|
|
region = BKE_area_region_new();
|
2024-04-24 17:55:37 +02:00
|
|
|
BLI_addtail(&simage->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_ASSET_SHELF;
|
|
|
|
|
region->alignment = RGN_ALIGN_BOTTOM;
|
|
|
|
|
region->flag |= RGN_FLAG_HIDDEN;
|
|
|
|
|
|
|
|
|
|
/* asset shelf header */
|
2024-11-15 02:00:11 +01:00
|
|
|
region = BKE_area_region_new();
|
2024-04-24 17:55:37 +02:00
|
|
|
BLI_addtail(&simage->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_ASSET_SHELF_HEADER;
|
|
|
|
|
region->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV;
|
|
|
|
|
|
2021-09-28 14:44:36 +10:00
|
|
|
/* tool header */
|
2024-11-15 02:00:11 +01:00
|
|
|
region = BKE_area_region_new();
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_addtail(&simage->regionbase, region);
|
2021-09-28 14:44:36 +10:00
|
|
|
region->regiontype = RGN_TYPE_TOOL_HEADER;
|
2020-03-06 16:56:42 +01:00
|
|
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
2021-09-28 14:44:36 +10:00
|
|
|
region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* buttons/list view */
|
2024-11-15 02:00:11 +01:00
|
|
|
region = BKE_area_region_new();
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_addtail(&simage->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_UI;
|
|
|
|
|
region->alignment = RGN_ALIGN_RIGHT;
|
|
|
|
|
region->flag = RGN_FLAG_HIDDEN;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2014-02-13 19:49:26 +02:00
|
|
|
/* scopes/uv sculpt/paint */
|
2024-11-15 02:00:11 +01:00
|
|
|
region = BKE_area_region_new();
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_addtail(&simage->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_TOOLS;
|
|
|
|
|
region->alignment = RGN_ALIGN_LEFT;
|
|
|
|
|
region->flag = RGN_FLAG_HIDDEN;
|
2010-04-06 02:05:54 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* main area */
|
2024-11-15 02:00:11 +01:00
|
|
|
region = BKE_area_region_new();
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_addtail(&simage->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_WINDOW;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
return (SpaceLink *)simage;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-09 11:39:27 +10:00
|
|
|
/* Doesn't free the space-link itself. */
|
2008-12-13 17:44:30 +00:00
|
|
|
static void image_free(SpaceLink *sl)
|
2018-06-04 09:31:30 +02:00
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *simage = (SpaceImage *)sl;
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
2019-08-07 03:21:55 +10:00
|
|
|
BKE_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 */
|
2023-07-12 13:43:00 +02:00
|
|
|
static void image_init(wmWindowManager * /*wm*/, ScrArea *area)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2023-09-14 13:32:42 +10:00
|
|
|
ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
2018-06-04 09:31:30 +02: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 */
|
2020-04-03 13:25:03 +02:00
|
|
|
WM_event_add_dropbox_handler(&area->handlers, lb);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SpaceLink *image_duplicate(SpaceLink *sl)
|
|
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
SpaceImage *simagen = static_cast<SpaceImage *>(MEM_dupallocN(sl));
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* clear or remove stuff from old */
|
2011-03-23 14:24:13 +00:00
|
|
|
|
2019-08-07 03:21:55 +10:00
|
|
|
BKE_scopes_new(&simagen->scopes);
|
2011-03-23 14:24:13 +00:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
return (SpaceLink *)simagen;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 09:54:02 +10:00
|
|
|
static void image_operatortypes()
|
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);
|
2019-10-01 20:19:44 +10:00
|
|
|
WM_operatortype_append(IMAGE_OT_view_center_cursor);
|
2021-03-27 15:03:45 +11:00
|
|
|
WM_operatortype_append(IMAGE_OT_view_cursor_center);
|
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_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);
|
2016-05-07 04:22:48 +10:00
|
|
|
WM_operatortype_append(IMAGE_OT_view_zoom_border);
|
2016-08-18 00:21:55 -04:00
|
|
|
#ifdef WITH_INPUT_NDOF
|
2011-06-25 18:51:29 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_view_ndof);
|
2016-08-18 00:21:55 -04:00
|
|
|
#endif
|
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);
|
2022-05-31 20:57:33 -07:00
|
|
|
WM_operatortype_append(IMAGE_OT_file_browse);
|
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);
|
2019-05-16 16:01:11 +02:00
|
|
|
WM_operatortype_append(IMAGE_OT_save_all_modified);
|
2009-02-10 23:17:58 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_pack);
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_unpack);
|
2023-04-14 03:48:17 +02:00
|
|
|
WM_operatortype_append(IMAGE_OT_clipboard_copy);
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_clipboard_paste);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-02-04 18:03:42 +01:00
|
|
|
WM_operatortype_append(IMAGE_OT_flip);
|
2024-01-31 23:36:28 +01:00
|
|
|
WM_operatortype_append(IMAGE_OT_rotate_orthogonal);
|
2011-02-23 12:02:43 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_invert);
|
2019-10-02 00:24:21 +10:00
|
|
|
WM_operatortype_append(IMAGE_OT_resize);
|
2009-02-11 19:16:14 +00:00
|
|
|
|
2010-02-09 19:37:37 +00:00
|
|
|
WM_operatortype_append(IMAGE_OT_cycle_render_slot);
|
2018-06-14 22:46:30 +02:00
|
|
|
WM_operatortype_append(IMAGE_OT_clear_render_slot);
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_add_render_slot);
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_remove_render_slot);
|
2010-02-09 19:37:37 +00:00
|
|
|
|
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
|
|
|
|
2014-04-02 17:58:34 +06:00
|
|
|
WM_operatortype_append(IMAGE_OT_change_frame);
|
2014-06-28 19:13:54 +02:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
WM_operatortype_append(IMAGE_OT_read_viewlayers);
|
2014-10-08 18:02:49 +02:00
|
|
|
WM_operatortype_append(IMAGE_OT_render_border);
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_clear_render_border);
|
Add support for tiled images and the UDIM naming scheme
This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender.
With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser.
Therefore, code that is not yet aware of tiles will just access the default tile as usual.
The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10*<y coordinate of the tile> + <x coordinate of the tile>), where the x coordinate never goes above 9.
Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator.
The following features are supported so far:
- Automatic detection and loading of all tiles when opening the first tile (1001)
- Saving all tiles
- Adding and removing tiles
- Filling tiles with generated images
- Drawing all tiles in the Image Editor
- Viewing a tiled grid even if no image is selected
- Rendering tiled images in Eevee
- Rendering tiled images in Cycles (in SVM mode)
- Automatically skipping loading of unused tiles in Cycles
- 2D texture painting (also across tiles)
- 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders)
- Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID)
- Different resolutions between tiles
There still are some missing features that will be added later (see T72390):
- Workbench engine support
- Packing/Unpacking support
- Baking support
- Cycles OSL support
- many other Blender features that rely on images
Thanks to Brecht for the review and to all who tested the intermediate versions!
Differential Revision: https://developer.blender.org/D3509
2019-12-12 16:06:08 +01:00
|
|
|
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_tile_add);
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_tile_remove);
|
|
|
|
|
WM_operatortype_append(IMAGE_OT_tile_fill);
|
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
|
|
|
}
|
|
|
|
|
|
2023-06-03 08:36:28 +10:00
|
|
|
static void image_keymap(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
|
|
|
{
|
2023-09-14 13:32:42 +10:00
|
|
|
WM_keymap_ensure(keyconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
|
|
|
|
WM_keymap_ensure(keyconf, "Image", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
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
|
|
|
/* area+region dropbox definition */
|
2024-04-25 03:40:14 +02:00
|
|
|
static void image_dropboxes() {}
|
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-08-03 20:56:04 +00:00
|
|
|
/**
|
|
|
|
|
* \note take care not to get into feedback loop here,
|
|
|
|
|
* calling composite job causes viewer to refresh.
|
|
|
|
|
*/
|
2020-04-03 13:25:03 +02:00
|
|
|
static void image_refresh(const bContext *C, ScrArea *area)
|
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);
|
2023-07-12 13:43:00 +02:00
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
ima = ED_space_image(sima);
|
2019-06-17 11:39:52 +02:00
|
|
|
BKE_image_user_frame_calc(ima, &sima->iuser, scene->r.cfra);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-01-06 13:54:52 +11:00
|
|
|
/* Check if we have to set the image from the edit-mesh. */
|
2012-08-03 20:56:04 +00:00
|
|
|
if (ima && (ima->source == IMA_SRC_VIEWER && sima->mode == SI_MODE_MASK)) {
|
2025-06-10 17:46:55 +02:00
|
|
|
if (scene->compositing_node_group) {
|
2013-06-24 22:41:37 +00:00
|
|
|
Mask *mask = ED_space_image_get_mask(sima);
|
|
|
|
|
if (mask) {
|
2025-06-10 17:46:55 +02:00
|
|
|
ED_node_composite_job(C, scene->compositing_node_group, scene);
|
2012-08-03 20:56:04 +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
|
|
|
}
|
|
|
|
|
|
2021-01-19 12:59:00 +11:00
|
|
|
static void image_listener(const wmSpaceTypeListenerParams *params)
|
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
|
|
|
{
|
2021-01-18 17:28:47 -06:00
|
|
|
wmWindow *win = params->window;
|
|
|
|
|
ScrArea *area = params->area;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
2020-04-03 13:25:03 +02:00
|
|
|
SpaceImage *sima = (SpaceImage *)area->spacedata.first;
|
2019-04-17 06:17:24 +02: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) {
|
2013-04-02 12:41:11 +00:00
|
|
|
case NC_WINDOW:
|
|
|
|
|
/* notifier comes from editing color space */
|
2020-04-03 13:25:03 +02:00
|
|
|
image_scopes_tag_refresh(area);
|
|
|
|
|
ED_area_tag_redraw(area);
|
2013-04-02 12:41:11 +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
|
|
|
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:
|
2020-04-03 13:25:03 +02:00
|
|
|
image_scopes_tag_refresh(area);
|
|
|
|
|
ED_area_tag_refresh(area);
|
|
|
|
|
ED_area_tag_redraw(area);
|
2010-03-28 23:30:00 +00:00
|
|
|
break;
|
Overlay: Allow drawing UVs in Image Editor in any mode
**Problem**
When using Texture Paint mode, the Image Editor will show a UV Wireframe
to display the active object's UVs. In every other mode, this wireframe
is absent. This is currently a big problem for Sculpt Mode since the
Experimental Texture Paint system is a part of that mode, meaning that
the user can't see their UVs while they paint in Sculpt Mode. This is
also troublesome for users that would like to quickly view an object's
UVs without using Texture Paint Mode.
**Solution**
Since it's useful to be able to view an object's UVs at all times, the
Image Editor should display UV Wireframes in all Object Modes regardless
of the Image Editor's mode. This is the best solution since it means
that future Blender features, that would benefit from having a preview
of an object's UV Wireframes, will automatically have that option since
UV Wireframes are supported in all modes. Also, if a user doesn't want
to see UV Wireframes for any reason, it can be disabled with an Overlay
option.
Additionally, when multiple objects are selected, each object should
have its UV Wireframe drawn in the Image Editor. The selected objects
that aren't active should have less opaque wireframes to indicate which
wireframe belongs to the active object. This is the best approach for
having multiple objects selected since it allows the user to quickly
view the UV layout for all selected objects to troubleshoot UV problems,
like texture mapping. This is especially helpful when using a material
for multiple different objects.
An alternative solution would be to only show the UV Wireframe for the
active object, but this would be undesirable because it would make
troubleshooting UV positions tedious when working with multiple objects
since the user would need to select objects individually.
Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/135102
2025-04-04 21:30:05 +02:00
|
|
|
case ND_OB_ACTIVE:
|
|
|
|
|
case ND_OB_SELECT:
|
|
|
|
|
ED_area_tag_redraw(area);
|
|
|
|
|
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:
|
2022-06-08 12:37:29 -07:00
|
|
|
ED_paint_cursor_start(¶ms->scene->toolsettings->imapaint.paint,
|
2022-06-09 10:10:37 +10:00
|
|
|
ED_image_tools_paint_poll);
|
2022-06-08 12:37:29 -07:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (wmn->subtype == NS_EDITMODE_MESH) {
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_refresh(area);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
2012-09-19 17:09:14 +00:00
|
|
|
break;
|
2009-01-27 17:12:40 +00:00
|
|
|
case ND_RENDER_RESULT:
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
case ND_RENDER_OPTIONS:
|
2009-01-27 17:12:40 +00:00
|
|
|
case ND_COMPO_RESULT:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ED_space_image_show_render(sima)) {
|
2020-04-03 13:25:03 +02:00
|
|
|
image_scopes_tag_refresh(area);
|
2023-03-06 08:38:53 +01:00
|
|
|
BKE_image_partial_update_mark_full_update(sima->image);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
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) {
|
2013-05-15 14:37:05 +00:00
|
|
|
if (wmn->action != NA_PAINTING) {
|
2020-04-03 13:25:03 +02:00
|
|
|
image_scopes_tag_refresh(area);
|
|
|
|
|
ED_area_tag_refresh(area);
|
|
|
|
|
ED_area_tag_redraw(area);
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-02-11 19:16:14 +00:00
|
|
|
break;
|
2012-10-21 05:46:41 +00:00
|
|
|
case NC_SPACE:
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wmn->data == ND_SPACE_IMAGE) {
|
2020-04-03 13:25:03 +02:00
|
|
|
image_scopes_tag_refresh(area);
|
|
|
|
|
ED_area_tag_redraw(area);
|
2010-03-28 23:30:00 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
break;
|
2012-07-25 13:44:59 +00:00
|
|
|
case NC_MASK: {
|
2022-09-14 21:33:51 +02:00
|
|
|
Scene *scene = WM_window_get_active_scene(win);
|
2020-09-02 12:44:37 +10:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2022-09-01 10:00:53 +02:00
|
|
|
Object *obedit = BKE_view_layer_edit_object_get(view_layer);
|
2020-09-02 12:44:37 +10:00
|
|
|
if (ED_space_image_check_show_maskedit(sima, obedit)) {
|
2012-08-01 10:50:39 +00:00
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_SELECT:
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
2012-08-03 20:56:04 +00:00
|
|
|
break;
|
2012-08-01 10:50:39 +00:00
|
|
|
case ND_DATA:
|
|
|
|
|
case ND_DRAW:
|
2012-08-03 20:56:04 +00:00
|
|
|
/* causes node-recalc */
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
|
|
|
|
ED_area_tag_refresh(area);
|
2012-08-01 10:50:39 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
switch (wmn->action) {
|
|
|
|
|
case NA_SELECTED:
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
2012-08-01 10:50:39 +00:00
|
|
|
break;
|
|
|
|
|
case NA_EDITED:
|
2012-08-03 20:56:04 +00:00
|
|
|
/* causes node-recalc */
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
|
|
|
|
ED_area_tag_refresh(area);
|
2012-08-01 10:50:39 +00:00
|
|
|
break;
|
2012-07-25 13:44:59 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-07-25 13:44:59 +00:00
|
|
|
break;
|
2012-08-01 10:50:39 +00:00
|
|
|
}
|
2009-09-16 17:43:09 +00:00
|
|
|
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:
|
2020-04-03 13:25:03 +02:00
|
|
|
image_scopes_tag_refresh(area);
|
|
|
|
|
ED_area_tag_refresh(area);
|
|
|
|
|
ED_area_tag_redraw(area);
|
2013-07-21 17:04:54 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
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: {
|
2012-03-28 11:53:18 +00:00
|
|
|
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: {
|
2022-09-14 21:33:51 +02:00
|
|
|
const Scene *scene = WM_window_get_active_scene(win);
|
2018-07-04 15:14:57 +02:00
|
|
|
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
|
2022-09-14 21:33:51 +02:00
|
|
|
BKE_view_layer_synced_ensure(scene, view_layer);
|
2022-09-01 10:00:53 +02:00
|
|
|
Object *ob = BKE_view_layer_active_object_get(view_layer);
|
2023-01-27 16:38:12 +13:00
|
|
|
/* \note With a geometry nodes modifier, the UVs on `ob` can change in response to
|
|
|
|
|
* any change on `wmn->reference`. If we could track the upstream dependencies,
|
2023-02-12 14:37:16 +11:00
|
|
|
* unnecessary redraws could be reduced. Until then, just redraw. See #98594. */
|
Overlay: Allow drawing UVs in Image Editor in any mode
**Problem**
When using Texture Paint mode, the Image Editor will show a UV Wireframe
to display the active object's UVs. In every other mode, this wireframe
is absent. This is currently a big problem for Sculpt Mode since the
Experimental Texture Paint system is a part of that mode, meaning that
the user can't see their UVs while they paint in Sculpt Mode. This is
also troublesome for users that would like to quickly view an object's
UVs without using Texture Paint Mode.
**Solution**
Since it's useful to be able to view an object's UVs at all times, the
Image Editor should display UV Wireframes in all Object Modes regardless
of the Image Editor's mode. This is the best solution since it means
that future Blender features, that would benefit from having a preview
of an object's UV Wireframes, will automatically have that option since
UV Wireframes are supported in all modes. Also, if a user doesn't want
to see UV Wireframes for any reason, it can be disabled with an Overlay
option.
Additionally, when multiple objects are selected, each object should
have its UV Wireframe drawn in the Image Editor. The selected objects
that aren't active should have less opaque wireframes to indicate which
wireframe belongs to the active object. This is the best approach for
having multiple objects selected since it allows the user to quickly
view the UV layout for all selected objects to troubleshoot UV problems,
like texture mapping. This is especially helpful when using a material
for multiple different objects.
An alternative solution would be to only show the UV Wireframe for the
active object, but this would be undesirable because it would make
troubleshooting UV positions tedious when working with multiple objects
since the user would need to select objects individually.
Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/135102
2025-04-04 21:30:05 +02:00
|
|
|
if (ob && (ob->mode & OB_MODE_EDIT) && sima->mode == SI_MODE_UV) {
|
2014-01-29 20:28:18 +01:00
|
|
|
if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_refresh(area);
|
|
|
|
|
ED_area_tag_redraw(area);
|
2014-01-29 20:28:18 +01:00
|
|
|
}
|
* 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
|
|
|
}
|
Overlay: Allow drawing UVs in Image Editor in any mode
**Problem**
When using Texture Paint mode, the Image Editor will show a UV Wireframe
to display the active object's UVs. In every other mode, this wireframe
is absent. This is currently a big problem for Sculpt Mode since the
Experimental Texture Paint system is a part of that mode, meaning that
the user can't see their UVs while they paint in Sculpt Mode. This is
also troublesome for users that would like to quickly view an object's
UVs without using Texture Paint Mode.
**Solution**
Since it's useful to be able to view an object's UVs at all times, the
Image Editor should display UV Wireframes in all Object Modes regardless
of the Image Editor's mode. This is the best solution since it means
that future Blender features, that would benefit from having a preview
of an object's UV Wireframes, will automatically have that option since
UV Wireframes are supported in all modes. Also, if a user doesn't want
to see UV Wireframes for any reason, it can be disabled with an Overlay
option.
Additionally, when multiple objects are selected, each object should
have its UV Wireframe drawn in the Image Editor. The selected objects
that aren't active should have less opaque wireframes to indicate which
wireframe belongs to the active object. This is the best approach for
having multiple objects selected since it allows the user to quickly
view the UV layout for all selected objects to troubleshoot UV problems,
like texture mapping. This is especially helpful when using a material
for multiple different objects.
An alternative solution would be to only show the UV Wireframe for the
active object, but this would be undesirable because it would make
troubleshooting UV positions tedious when working with multiple objects
since the user would need to select objects individually.
Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/135102
2025-04-04 21:30:05 +02:00
|
|
|
else if (ob) {
|
2025-06-05 00:02:03 +02:00
|
|
|
if (sima->lock && !(sima->flag & SI_NO_DRAW_UV_GUIDE) &&
|
|
|
|
|
ELEM(sima->mode, SI_MODE_PAINT, SI_MODE_UV))
|
|
|
|
|
{
|
Overlay: Allow drawing UVs in Image Editor in any mode
**Problem**
When using Texture Paint mode, the Image Editor will show a UV Wireframe
to display the active object's UVs. In every other mode, this wireframe
is absent. This is currently a big problem for Sculpt Mode since the
Experimental Texture Paint system is a part of that mode, meaning that
the user can't see their UVs while they paint in Sculpt Mode. This is
also troublesome for users that would like to quickly view an object's
UVs without using Texture Paint Mode.
**Solution**
Since it's useful to be able to view an object's UVs at all times, the
Image Editor should display UV Wireframes in all Object Modes regardless
of the Image Editor's mode. This is the best solution since it means
that future Blender features, that would benefit from having a preview
of an object's UV Wireframes, will automatically have that option since
UV Wireframes are supported in all modes. Also, if a user doesn't want
to see UV Wireframes for any reason, it can be disabled with an Overlay
option.
Additionally, when multiple objects are selected, each object should
have its UV Wireframe drawn in the Image Editor. The selected objects
that aren't active should have less opaque wireframes to indicate which
wireframe belongs to the active object. This is the best approach for
having multiple objects selected since it allows the user to quickly
view the UV layout for all selected objects to troubleshoot UV problems,
like texture mapping. This is especially helpful when using a material
for multiple different objects.
An alternative solution would be to only show the UV Wireframe for the
active object, but this would be undesirable because it would make
troubleshooting UV positions tedious when working with multiple objects
since the user would need to select objects individually.
Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Co-authored-by: Sean Kim <SeanCTKim@protonmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/135102
2025-04-04 21:30:05 +02:00
|
|
|
ED_area_tag_refresh(area);
|
|
|
|
|
ED_area_tag_redraw(area);
|
|
|
|
|
}
|
|
|
|
|
}
|
* 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
|
|
|
break;
|
2014-03-11 17:46:11 +11:00
|
|
|
}
|
* 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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2010-11-15 07:07:14 +00:00
|
|
|
}
|
2014-05-30 16:26:29 +06:00
|
|
|
case NC_ID: {
|
|
|
|
|
if (wmn->action == NA_RENAME) {
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
2014-05-30 16:26:29 +06:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-09-16 14:28:58 +06:00
|
|
|
case NC_WM:
|
2014-09-18 09:37:49 +10:00
|
|
|
if (wmn->data == ND_UNDO) {
|
2020-04-03 13:25:03 +02:00
|
|
|
ED_area_tag_redraw(area);
|
|
|
|
|
ED_area_tag_refresh(area);
|
2014-09-16 14:28:58 +06: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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
const char *image_context_dir[] = {"edit_image", "edit_mask", nullptr};
|
2011-02-15 14:38:43 +00:00
|
|
|
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
static int /*eContextResult*/ 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);
|
2019-04-17 06:17:24 +02: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);
|
2023-09-25 16:56:17 +10:00
|
|
|
// return CTX_RESULT_OK; /* TODO(@sybren). */
|
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));
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
return CTX_RESULT_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-07-24 19:29:24 +00:00
|
|
|
else if (CTX_data_equals(member, "edit_mask")) {
|
2012-07-25 13:44:59 +00:00
|
|
|
Mask *mask = ED_space_image_get_mask(sima);
|
2012-07-24 19:29:24 +00:00
|
|
|
if (mask) {
|
|
|
|
|
CTX_data_id_pointer_set(result, &mask->id);
|
|
|
|
|
}
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
return CTX_RESULT_OK;
|
2012-07-24 19:29:24 +00:00
|
|
|
}
|
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
2020-10-02 18:56:25 +02:00
|
|
|
return CTX_RESULT_MEMBER_NOT_FOUND;
|
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
|
|
|
}
|
|
|
|
|
|
2018-07-15 14:24:10 +02:00
|
|
|
static void IMAGE_GGT_gizmo2d(wmGizmoGroupType *gzgt)
|
2017-06-16 07:30:27 +10:00
|
|
|
{
|
2018-07-15 14:24:10 +02:00
|
|
|
gzgt->name = "UV Transform Gizmo";
|
|
|
|
|
gzgt->idname = "IMAGE_GGT_gizmo2d";
|
2017-06-16 07:30:27 +10:00
|
|
|
|
2021-09-15 22:34:21 +10:00
|
|
|
gzgt->flag |= (WM_GIZMOGROUPTYPE_DRAW_MODAL_EXCLUDE | WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP |
|
2019-12-19 01:27:23 +11:00
|
|
|
WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK);
|
2019-12-13 19:33:49 +11:00
|
|
|
|
|
|
|
|
gzgt->gzmap_params.spaceid = SPACE_IMAGE;
|
|
|
|
|
gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
|
|
|
|
|
|
2025-02-18 01:27:04 +01:00
|
|
|
blender::ed::transform::ED_widgetgroup_gizmo2d_xform_callbacks_set(gzgt);
|
2019-12-13 19:33:49 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void IMAGE_GGT_gizmo2d_translate(wmGizmoGroupType *gzgt)
|
|
|
|
|
{
|
|
|
|
|
gzgt->name = "UV Translate Gizmo";
|
|
|
|
|
gzgt->idname = "IMAGE_GGT_gizmo2d_translate";
|
|
|
|
|
|
2021-09-15 22:34:21 +10:00
|
|
|
gzgt->flag |= (WM_GIZMOGROUPTYPE_DRAW_MODAL_EXCLUDE | WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP |
|
2019-12-19 01:27:23 +11:00
|
|
|
WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK);
|
2019-12-13 19:33:49 +11:00
|
|
|
|
|
|
|
|
gzgt->gzmap_params.spaceid = SPACE_IMAGE;
|
|
|
|
|
gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
|
|
|
|
|
|
2025-02-18 01:27:04 +01:00
|
|
|
blender::ed::transform::ED_widgetgroup_gizmo2d_xform_no_cage_callbacks_set(gzgt);
|
2019-12-13 19:33:49 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void IMAGE_GGT_gizmo2d_resize(wmGizmoGroupType *gzgt)
|
|
|
|
|
{
|
|
|
|
|
gzgt->name = "UV Transform Gizmo Resize";
|
|
|
|
|
gzgt->idname = "IMAGE_GGT_gizmo2d_resize";
|
|
|
|
|
|
2021-09-15 22:34:21 +10:00
|
|
|
gzgt->flag |= (WM_GIZMOGROUPTYPE_DRAW_MODAL_EXCLUDE | WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP |
|
2019-12-19 01:27:23 +11:00
|
|
|
WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK);
|
2019-12-13 19:33:49 +11:00
|
|
|
|
|
|
|
|
gzgt->gzmap_params.spaceid = SPACE_IMAGE;
|
|
|
|
|
gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
|
|
|
|
|
|
2025-02-18 01:27:04 +01:00
|
|
|
blender::ed::transform::ED_widgetgroup_gizmo2d_resize_callbacks_set(gzgt);
|
2019-12-13 19:33:49 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void IMAGE_GGT_gizmo2d_rotate(wmGizmoGroupType *gzgt)
|
|
|
|
|
{
|
|
|
|
|
gzgt->name = "UV Transform Gizmo Resize";
|
|
|
|
|
gzgt->idname = "IMAGE_GGT_gizmo2d_rotate";
|
|
|
|
|
|
2021-09-15 22:34:21 +10:00
|
|
|
gzgt->flag |= (WM_GIZMOGROUPTYPE_DRAW_MODAL_EXCLUDE | WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP |
|
2019-12-19 01:27:23 +11:00
|
|
|
WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK);
|
2019-12-13 19:33:49 +11:00
|
|
|
|
2018-10-04 12:04:36 +10:00
|
|
|
gzgt->gzmap_params.spaceid = SPACE_IMAGE;
|
|
|
|
|
gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
|
2017-06-16 07:30:27 +10:00
|
|
|
|
2025-02-18 01:27:04 +01:00
|
|
|
blender::ed::transform::ED_widgetgroup_gizmo2d_rotate_callbacks_set(gzgt);
|
2017-06-16 07:30:27 +10:00
|
|
|
}
|
|
|
|
|
|
2019-05-31 21:45:28 +10:00
|
|
|
static void IMAGE_GGT_navigate(wmGizmoGroupType *gzgt)
|
|
|
|
|
{
|
|
|
|
|
VIEW2D_GGT_navigate_impl(gzgt, "IMAGE_GGT_navigate");
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 09:54:02 +10:00
|
|
|
static void image_widgets()
|
2017-06-16 07:30:27 +10:00
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
const wmGizmoMapType_Params params{SPACE_IMAGE, RGN_TYPE_WINDOW};
|
|
|
|
|
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(¶ms);
|
2019-05-31 21:45:28 +10:00
|
|
|
|
2018-10-04 12:04:36 +10:00
|
|
|
WM_gizmogrouptype_append(IMAGE_GGT_gizmo2d);
|
2019-12-13 19:33:49 +11:00
|
|
|
WM_gizmogrouptype_append(IMAGE_GGT_gizmo2d_translate);
|
|
|
|
|
WM_gizmogrouptype_append(IMAGE_GGT_gizmo2d_resize);
|
|
|
|
|
WM_gizmogrouptype_append(IMAGE_GGT_gizmo2d_rotate);
|
2019-05-31 21:45:28 +10:00
|
|
|
|
|
|
|
|
WM_gizmogrouptype_append_and_link(gzmap_type, IMAGE_GGT_navigate);
|
2017-06-16 07:30:27 +10: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
|
|
|
/************************** main region ***************************/
|
|
|
|
|
|
|
|
|
|
/* sets up the fields of the View2D from zoom and offset */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_main_region_set_view2d(SpaceImage *sima, ARegion *region)
|
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);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2018-08-15 19:24:00 +02:00
|
|
|
int width, height;
|
2012-07-25 16:30:53 +00:00
|
|
|
ED_space_image_get_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
|
|
|
|
2018-08-15 19:24:00 +02:00
|
|
|
float w = width;
|
|
|
|
|
float h = height;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ima) {
|
2012-03-28 11:53:18 +00:00
|
|
|
h *= ima->aspy / ima->aspx;
|
2019-03-26 21:16:47 +11: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
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
int winx = BLI_rcti_size_x(®ion->winrct) + 1;
|
|
|
|
|
int winy = BLI_rcti_size_y(®ion->winrct) + 1;
|
2018-08-15 19:24:00 +02:00
|
|
|
|
|
|
|
|
/* For region overlap, move center so image doesn't overlap header. */
|
2020-03-06 16:56:42 +01:00
|
|
|
const rcti *visible_rect = ED_region_visible_rect(region);
|
2019-08-16 05:41:43 +10:00
|
|
|
const int visible_winy = BLI_rcti_size_y(visible_rect) + 1;
|
2018-08-15 19:24:00 +02:00
|
|
|
int visible_centerx = 0;
|
2019-08-16 05:41:43 +10:00
|
|
|
int visible_centery = visible_rect->ymin + (visible_winy - winy) / 2;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
region->v2d.tot.xmin = 0;
|
|
|
|
|
region->v2d.tot.ymin = 0;
|
|
|
|
|
region->v2d.tot.xmax = w;
|
|
|
|
|
region->v2d.tot.ymax = h;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
region->v2d.mask.xmin = region->v2d.mask.ymin = 0;
|
|
|
|
|
region->v2d.mask.xmax = winx;
|
|
|
|
|
region->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? */
|
2020-03-06 16:56:42 +01:00
|
|
|
float x1 = region->winrct.xmin + visible_centerx + (winx - sima->zoom * w) / 2.0f;
|
|
|
|
|
float y1 = region->winrct.ymin + visible_centery + (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;
|
2018-06-04 09:31:30 +02: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
|
|
|
/* relative display right */
|
2025-01-26 20:08:00 +01:00
|
|
|
region->v2d.cur.xmin = ((region->winrct.xmin - x1) / sima->zoom);
|
2023-07-13 09:54:02 +10:00
|
|
|
region->v2d.cur.xmax = region->v2d.cur.xmin + (float(winx) / sima->zoom);
|
2018-06-04 09:31:30 +02: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
|
|
|
/* relative display left */
|
2025-01-26 20:08:00 +01:00
|
|
|
region->v2d.cur.ymin = ((region->winrct.ymin - y1) / sima->zoom);
|
2023-07-13 09:54:02 +10:00
|
|
|
region->v2d.cur.ymax = region->v2d.cur.ymin + (float(winy) / sima->zoom);
|
2018-06-04 09:31:30 +02: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
|
|
|
/* normalize 0.0..1.0 */
|
2020-03-06 16:56:42 +01:00
|
|
|
region->v2d.cur.xmin /= w;
|
|
|
|
|
region->v2d.cur.xmax /= w;
|
|
|
|
|
region->v2d.cur.ymin /= h;
|
|
|
|
|
region->v2d.cur.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
|
|
|
}
|
2008-12-13 17:44:30 +00:00
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_main_region_init(wmWindowManager *wm, ARegion *region)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
wmKeyMap *keymap;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2021-01-19 20:29:05 +11:00
|
|
|
/* NOTE: don't use `UI_view2d_region_reinit(®ion->v2d, ...)`
|
|
|
|
|
* since the space clip manages own v2d in #image_main_region_set_view2d */
|
2009-02-19 23:53:40 +00:00
|
|
|
|
2012-07-25 14:46:38 +00:00
|
|
|
/* mask polls mode */
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler_v2d_mask(®ion->runtime->handlers, keymap);
|
2012-07-25 14:46:38 +00:00
|
|
|
|
2009-02-19 23:53:40 +00:00
|
|
|
/* image paint polls for mode */
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler_v2d_mask(®ion->runtime->handlers, keymap);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Paint Curve", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2014-07-21 12:02:05 +02:00
|
|
|
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Image Paint", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler_v2d_mask(®ion->runtime->handlers, keymap);
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "UV Editor", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* own keymaps */
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Image", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler_v2d_mask(®ion->runtime->handlers, keymap);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_main_region_draw(const bContext *C, ARegion *region)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
|
|
|
|
/* draw entirely, view changes should be handled here */
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
|
Object *obedit = CTX_data_edit_object(C);
|
2019-07-25 16:36:22 +02:00
|
|
|
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
Mask *mask = nullptr;
|
2012-03-28 11:53:18 +00:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2021-01-25 12:44:18 +01:00
|
|
|
Image *image = ED_space_image(sima);
|
2025-05-21 15:57:31 +02:00
|
|
|
/* Typically a render result or viewer image from the compositor. */
|
2021-01-25 12:44:18 +01:00
|
|
|
const bool show_viewer = (image && image->source == IMA_SRC_VIEWER);
|
2025-05-21 15:57:31 +02:00
|
|
|
const bool show_compositor_viewer = show_viewer && image->type == IMA_TYPE_COMPOSITE;
|
|
|
|
|
|
|
|
|
|
/* Text info and render region are only relevant for the compositor. */
|
2025-05-22 01:01:08 +00:00
|
|
|
const bool show_text_info = show_compositor_viewer &&
|
|
|
|
|
(sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS &&
|
2025-05-21 15:57:31 +02:00
|
|
|
sima->overlay.flag & SI_OVERLAY_DRAW_TEXT_INFO &&
|
2025-05-22 01:01:08 +00:00
|
|
|
ELEM(sima->mode, SI_MODE_MASK, SI_MODE_VIEW));
|
|
|
|
|
const bool show_render_region = show_compositor_viewer &&
|
|
|
|
|
(sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS &&
|
2025-05-21 15:57:31 +02:00
|
|
|
sima->overlay.flag & SI_OVERLAY_DRAW_RENDER_REGION &&
|
2025-05-22 01:01:08 +00:00
|
|
|
ELEM(sima->mode, SI_MODE_MASK, SI_MODE_VIEW));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-01-04 15:19:16 +00:00
|
|
|
/* XXX not supported yet, disabling for now */
|
|
|
|
|
scene->r.scemode &= ~R_COMP_CROP;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-01-17 10:00:14 +11:00
|
|
|
image_user_refresh_scene(C, sima);
|
2019-04-17 06:17:24 +02: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 */
|
2020-03-06 16:56:42 +01:00
|
|
|
image_main_region_set_view2d(sima, region);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-26 09:54:52 +00:00
|
|
|
/* check for mask (delay draw) */
|
2020-10-20 16:55:50 +02:00
|
|
|
if (!ED_space_image_show_uvedit(sima, obedit) && sima->mode == SI_MODE_MASK) {
|
2012-07-26 09:54:52 +00:00
|
|
|
mask = ED_space_image_get_mask(sima);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 12:44:18 +01:00
|
|
|
if (show_viewer) {
|
|
|
|
|
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
|
|
|
|
}
|
2020-10-20 16:55:50 +02:00
|
|
|
DRW_draw_view(C);
|
2021-01-25 12:44:18 +01:00
|
|
|
if (show_viewer) {
|
|
|
|
|
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-21 15:57:31 +02:00
|
|
|
if (show_render_region) {
|
|
|
|
|
int render_size_x, render_size_y;
|
|
|
|
|
|
|
|
|
|
BKE_render_resolution(&scene->r, true, &render_size_x, &render_size_y);
|
|
|
|
|
|
|
|
|
|
float zoomx, zoomy;
|
|
|
|
|
ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
|
|
|
|
|
int width, height;
|
|
|
|
|
ED_space_image_get_size(sima, &width, &height);
|
|
|
|
|
int center_x = width / 2;
|
|
|
|
|
int center_y = height / 2;
|
|
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
rcti render_region;
|
|
|
|
|
BLI_rcti_init(
|
|
|
|
|
&render_region, center_x, render_size_x + center_x, center_y, render_size_y + center_y);
|
|
|
|
|
UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y);
|
|
|
|
|
|
|
|
|
|
ED_region_image_render_region_draw(
|
|
|
|
|
x, y, &render_region, zoomx, zoomy, sima->overlay.passepartout_alpha);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 16:55:50 +02:00
|
|
|
draw_image_main_helpers(C, region);
|
|
|
|
|
|
|
|
|
|
/* Draw Meta data of the image isn't added to the DrawManager as it is
|
|
|
|
|
* used in other areas as well. */
|
2020-12-02 16:19:15 +01:00
|
|
|
if (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS && sima->flag & SI_DRAW_METADATA) {
|
2020-10-20 16:55:50 +02:00
|
|
|
void *lock;
|
2025-07-31 06:17:29 +00:00
|
|
|
/* #ED_space_image_get_zoom temporarily locks the image, so this needs to be done before
|
|
|
|
|
* the image is locked when calling #ED_space_image_acquire_buffer. */
|
2020-10-20 16:55:50 +02:00
|
|
|
float zoomx, zoomy;
|
|
|
|
|
ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
|
|
|
|
|
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
|
|
|
|
|
if (ibuf) {
|
|
|
|
|
int x, y;
|
|
|
|
|
rctf frame;
|
|
|
|
|
BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
|
|
|
|
|
UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y);
|
|
|
|
|
ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy);
|
2020-09-15 10:08:47 +02:00
|
|
|
}
|
2023-07-26 18:46:18 +02:00
|
|
|
ED_space_image_release_buffer(sima, ibuf, lock);
|
2012-12-17 02:34:53 +00:00
|
|
|
}
|
2020-09-11 07:59:48 +02:00
|
|
|
|
2025-05-21 15:57:31 +02:00
|
|
|
if (show_text_info) {
|
|
|
|
|
|
|
|
|
|
int render_size_x, render_size_y;
|
|
|
|
|
BKE_render_resolution(&scene->r, true, &render_size_x, &render_size_y);
|
|
|
|
|
|
|
|
|
|
/* Use same positioning convention as in 3D View. */
|
|
|
|
|
const rcti *rect = ED_region_visible_rect(region);
|
|
|
|
|
int xoffset = rect->xmin + (0.5f * U.widget_unit);
|
|
|
|
|
int yoffset = rect->ymax - (0.1f * U.widget_unit);
|
|
|
|
|
|
|
|
|
|
int viewer_size_x, viewer_size_y;
|
|
|
|
|
ED_space_image_get_size(sima, &viewer_size_x, &viewer_size_y);
|
|
|
|
|
|
|
|
|
|
ED_region_image_overlay_info_text_draw(
|
|
|
|
|
render_size_x, render_size_y, viewer_size_x, viewer_size_y, xoffset, yoffset);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-20 16:55:50 +02:00
|
|
|
/* sample line */
|
|
|
|
|
UI_view2d_view_ortho(v2d);
|
|
|
|
|
draw_image_sample_line(sima);
|
|
|
|
|
UI_view2d_view_restore(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-26 09:54:52 +00:00
|
|
|
if (mask) {
|
2021-01-25 12:44:18 +01:00
|
|
|
int width, height;
|
2012-09-13 02:28:48 +00:00
|
|
|
float aspx, aspy;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-15 07:56:38 +00:00
|
|
|
if (show_viewer) {
|
2013-01-15 07:56:50 +00:00
|
|
|
/* ED_space_image_get* will acquire image buffer which requires
|
2013-01-15 07:56:38 +00:00
|
|
|
* lock here by the same reason why lock is needed in draw_image_main
|
|
|
|
|
*/
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
2013-01-15 07:56:38 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-26 22:41:40 +00:00
|
|
|
ED_space_image_get_size(sima, &width, &height);
|
2012-09-13 02:28:48 +00:00
|
|
|
ED_space_image_get_aspect(sima, &aspx, &aspy);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (show_viewer) {
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-21 17:29:58 +02:00
|
|
|
ED_mask_draw_region(depsgraph,
|
|
|
|
|
mask,
|
2023-07-12 13:43:00 +02:00
|
|
|
region, /* Mask overlay is drawn by image/overlay engine. */
|
2021-01-05 13:43:32 +01:00
|
|
|
sima->mask_info.draw_flag & ~MASK_DRAWFLAG_OVERLAY,
|
2013-10-12 14:09:05 +00:00
|
|
|
sima->mask_info.draw_type,
|
2023-07-12 13:43:00 +02:00
|
|
|
eMaskOverlayMode(sima->mask_info.overlay_mode),
|
2022-06-15 15:15:23 +02:00
|
|
|
sima->mask_info.blend_factor,
|
2012-07-26 09:54:52 +00:00
|
|
|
width,
|
|
|
|
|
height,
|
2012-09-13 02:28:48 +00:00
|
|
|
aspx,
|
|
|
|
|
aspy,
|
2014-04-01 11:34:00 +11:00
|
|
|
true,
|
|
|
|
|
false,
|
2023-07-12 13:43:00 +02:00
|
|
|
nullptr,
|
2012-07-26 09:54:52 +00:00
|
|
|
C);
|
2012-07-24 19:29:24 +00:00
|
|
|
}
|
2023-08-09 08:31:15 +02:00
|
|
|
if ((sima->gizmo_flag & SI_GIZMO_HIDE) == 0) {
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_gizmomap_draw(region->runtime->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
|
2023-08-09 08:31:15 +02:00
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
draw_image_cache(C, region);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 12:59:00 +11:00
|
|
|
static void image_main_region_listener(const wmRegionListenerParams *params)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2021-01-18 17:28:47 -06:00
|
|
|
ScrArea *area = params->area;
|
|
|
|
|
ARegion *region = params->region;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
2021-01-18 17:28:47 -06: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) {
|
2017-06-16 07:30:27 +10:00
|
|
|
case NC_GEOM:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ELEM(wmn->data, ND_DATA, ND_SELECT)) {
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_gizmomap_tag_refresh(region->runtime->gizmo_map);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2017-06-16 07:30:27 +10:00
|
|
|
break;
|
2012-10-05 19:51:11 +00:00
|
|
|
case NC_GPENCIL:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else if (wmn->data & ND_GPENCIL_EDITMODE) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2012-03-28 11:53:18 +00:00
|
|
|
break;
|
2013-05-15 14:37:05 +00:00
|
|
|
case NC_IMAGE:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (wmn->action == NA_PAINTING) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_gizmomap_tag_refresh(region->runtime->gizmo_map);
|
2013-05-15 14:37:05 +00:00
|
|
|
break;
|
2025-08-06 09:44:24 +00:00
|
|
|
case NC_MASK:
|
|
|
|
|
if (ELEM(wmn->data, ND_DATA, ND_SELECT)) {
|
|
|
|
|
WM_gizmomap_tag_refresh(region->runtime->gizmo_map);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-11-14 13:50:10 +01:00
|
|
|
case NC_MATERIAL:
|
|
|
|
|
if (wmn->data == ND_SHADING_LINKS) {
|
2023-07-12 13:43:00 +02:00
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-06-12 13:25:22 +10:00
|
|
|
if (sima->iuser.scene &&
|
|
|
|
|
(sima->iuser.scene->toolsettings->uv_flag & UV_FLAG_SHOW_SAME_IMAGE))
|
|
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2014-11-14 13:50:10 +01:00
|
|
|
}
|
|
|
|
|
break;
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02:00
|
|
|
case NC_SCREEN:
|
|
|
|
|
if (ELEM(wmn->data, ND_LAYER)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
Main Workspace Integration
This commit does the main integration of workspaces, which is a design we agreed on during the 2.8 UI workshop (see https://wiki.blender.org/index.php/Dev:2.8/UI/Workshop_Writeup)
Workspaces should generally be stable, I'm not aware of any remaining bugs (or I've forgotten them :) ). If you find any, let me know!
(Exception: mode switching button might get out of sync with actual mode in some cases, would consider that a limitation/ToDo. Needs to be resolved at some point.)
== Main Changes/Features
* Introduces the new Workspaces as data-blocks.
* Allow storing a number of custom workspaces as part of the user configuration. Needs further work to allow adding and deleting individual workspaces.
* Bundle a default workspace configuration with Blender (current screen-layouts converted to workspaces).
* Pressing button to add a workspace spawns a menu to select between "Duplicate Current" and the workspaces from the user configuration. If no workspaces are stored in the user configuration, the default workspaces are listed instead.
* Store screen-layouts (`bScreen`) per workspace.
* Store an active screen-layout per workspace. Changing the workspace will enable this layout.
* Store active mode in workspace. Changing the workspace will also enter the mode of the new workspace. (Note that we still store the active mode in the object, moving this completely to workspaces is a separate project.)
* Store an active render layer per workspace.
* Moved mode switch from 3D View header to Info Editor header.
* Store active scene in window (not directly workspace related, but overlaps quite a bit).
* Removed 'Use Global Scene' User Preference option.
* Compatibility with old files - a new workspace is created for every screen-layout of old files. Old Blender versions should be able to read files saved with workspace support as well.
* Default .blend only contains one workspace ("General").
* Support appending workspaces.
Opening files without UI and commandline rendering should work fine.
Note that the UI is temporary! We plan to introduce a new global topbar
that contains the workspace options and tabs for switching workspaces.
== Technical Notes
* Workspaces are data-blocks.
* Adding and removing `bScreen`s should be done through `ED_workspace_layout` API now.
* A workspace can be active in multiple windows at the same time.
* The mode menu (which is now in the Info Editor header) doesn't display "Grease Pencil Edit" mode anymore since its availability depends on the active editor. Will be fixed by making Grease Pencil an own object type (as planned).
* The button to change the active workspace object mode may get out of sync with the mode of the active object. Will either be resolved by moving mode out of object data, or we'll disable workspace modes again (there's a `#define USE_WORKSPACE_MODE` for that).
* Screen-layouts (`bScreen`) are IDs and thus stored in a main list-base. Had to add a wrapper `WorkSpaceLayout` so we can store them in a list-base within workspaces, too. On the long run we could completely replace `bScreen` by workspace structs.
* `WorkSpace` types use some special compiler trickery to allow marking structs and struct members as private. BKE_workspace API should be used for accessing those.
* Added scene operators `SCENE_OT_`. Was previously done through screen operators.
== BPY API Changes
* Removed `Screen.scene`, added `Window.scene`
* Removed `UserPreferencesView.use_global_scene`
* Added `Context.workspace`, `Window.workspace` and `BlendData.workspaces`
* Added `bpy.types.WorkSpace` containing `screens`, `object_mode` and `render_layer`
* Added Screen.layout_name for the layout name that'll be displayed in the UI (may differ from internal name)
== What's left?
* There are a few open design questions (T50521). We should find the needed answers and implement them.
* Allow adding and removing individual workspaces from workspace configuration (needs UI design).
* Get the override system ready and support overrides per workspace.
* Support custom UI setups as part of workspaces (hidden panels, hidden buttons, customizable toolbars, etc).
* Allow enabling add-ons per workspace.
* Support custom workspace keymaps.
* Remove special exception for workspaces in linking code (so they're always appended, never linked). Depends on a few things, so best to solve later.
* Get the topbar done.
* Workspaces need a proper icon, current one is just a placeholder :)
Reviewed By: campbellbarton, mont29
Tags: #user_interface, #bf_blender_2.8
Maniphest Tasks: T50521
Differential Revision: https://developer.blender.org/D2451
2017-06-01 19:56:58 +02: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 */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_buttons_region_init(wmWindowManager *wm, ARegion *region)
|
2009-02-21 15:31:01 +00:00
|
|
|
{
|
2009-10-22 23:22:05 +00:00
|
|
|
wmKeyMap *keymap;
|
2009-05-19 17:13:33 +00:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
|
|
|
|
|
ED_region_panels_init(wm, region);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2009-02-21 15:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_buttons_region_layout(const bContext *C, ARegion *region)
|
2019-05-01 12:35:00 +10:00
|
|
|
{
|
|
|
|
|
const enum eContextObjectMode mode = CTX_data_mode_enum(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
const char *contexts_base[3] = {nullptr};
|
2019-05-01 12:35:00 +10:00
|
|
|
|
|
|
|
|
const char **contexts = contexts_base;
|
|
|
|
|
|
|
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
|
switch (sima->mode) {
|
|
|
|
|
case SI_MODE_VIEW:
|
|
|
|
|
break;
|
|
|
|
|
case SI_MODE_PAINT:
|
|
|
|
|
ARRAY_SET_ITEMS(contexts, ".paint_common_2d", ".imagepaint_2d");
|
|
|
|
|
break;
|
|
|
|
|
case SI_MODE_MASK:
|
|
|
|
|
break;
|
|
|
|
|
case SI_MODE_UV:
|
|
|
|
|
if (mode == CTX_MODE_EDIT_MESH) {
|
|
|
|
|
ARRAY_SET_ITEMS(contexts, ".uv_sculpt");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-21 19:34:53 +01:00
|
|
|
ED_region_panels_layout_ex(C,
|
|
|
|
|
region,
|
|
|
|
|
®ion->runtime->type->paneltypes,
|
2025-07-15 03:08:04 +02:00
|
|
|
blender::wm::OpCallContext::InvokeRegionWin,
|
2024-11-21 19:34:53 +01:00
|
|
|
contexts_base,
|
|
|
|
|
nullptr);
|
2019-05-01 12:35:00 +10:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_buttons_region_draw(const bContext *C, ARegion *region)
|
2009-02-21 15:31:01 +00:00
|
|
|
{
|
2019-01-24 14:36:52 +01:00
|
|
|
SpaceImage *sima = CTX_wm_space_image(C);
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
void *lock;
|
Add support for tiled images and the UDIM naming scheme
This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender.
With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser.
Therefore, code that is not yet aware of tiles will just access the default tile as usual.
The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10*<y coordinate of the tile> + <x coordinate of the tile>), where the x coordinate never goes above 9.
Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator.
The following features are supported so far:
- Automatic detection and loading of all tiles when opening the first tile (1001)
- Saving all tiles
- Adding and removing tiles
- Filling tiles with generated images
- Drawing all tiles in the Image Editor
- Viewing a tiled grid even if no image is selected
- Rendering tiled images in Eevee
- Rendering tiled images in Cycles (in SVM mode)
- Automatically skipping loading of unused tiles in Cycles
- 2D texture painting (also across tiles)
- 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders)
- Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID)
- Different resolutions between tiles
There still are some missing features that will be added later (see T72390):
- Workbench engine support
- Packing/Unpacking support
- Baking support
- Cycles OSL support
- many other Blender features that rely on images
Thanks to Brecht for the review and to all who tested the intermediate versions!
Differential Revision: https://developer.blender.org/D3509
2019-12-12 16:06:08 +01:00
|
|
|
/* TODO(lukas): Support tiles in scopes? */
|
|
|
|
|
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
|
2019-01-24 14:36:52 +01:00
|
|
|
/* XXX performance regression if name of scopes category changes! */
|
2020-03-06 16:56:42 +01:00
|
|
|
PanelCategoryStack *category = UI_panel_category_active_find(region, "Scopes");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-24 14:36:52 +01:00
|
|
|
/* only update scopes if scope category is active */
|
|
|
|
|
if (category) {
|
|
|
|
|
if (ibuf) {
|
|
|
|
|
if (!sima->scopes.ok) {
|
|
|
|
|
BKE_histogram_update_sample_line(
|
|
|
|
|
&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
|
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
if (sima->image->flag & IMA_VIEW_AS_RENDER) {
|
2019-01-24 14:36:52 +01:00
|
|
|
ED_space_image_scopes_update(C, sima, ibuf, true);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
|
else {
|
2019-01-24 14:36:52 +01:00
|
|
|
ED_space_image_scopes_update(C, sima, ibuf, false);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2019-01-24 14:36:52 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ED_space_image_release_buffer(sima, ibuf, lock);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-01 12:35:00 +10:00
|
|
|
/* Layout handles details. */
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_panels_draw(C, region);
|
2009-02-21 15:31:01 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 12:59:00 +11:00
|
|
|
static void image_buttons_region_listener(const wmRegionListenerParams *params)
|
2009-02-21 15:31:01 +00:00
|
|
|
{
|
2021-01-18 17:28:47 -06:00
|
|
|
ARegion *region = params->region;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
2021-01-18 17:28:47 -06:00
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->category) {
|
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 */
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2012-02-17 16:06:32 +00:00
|
|
|
break;
|
2014-02-28 18:12:05 +01:00
|
|
|
case NC_SCENE:
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_MODE:
|
|
|
|
|
case ND_RENDER_RESULT:
|
|
|
|
|
case ND_COMPO_RESULT:
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2014-02-28 18:12:05 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NC_IMAGE:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (wmn->action != NA_PAINTING) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2014-02-28 18:12:05 +01:00
|
|
|
break;
|
|
|
|
|
case NC_NODE:
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2014-02-28 18:12:05 +01:00
|
|
|
break;
|
2015-01-07 13:12:37 +13:00
|
|
|
case NC_GPENCIL:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2015-01-07 13:12:37 +13:00
|
|
|
break;
|
2019-07-04 13:12:42 +02:00
|
|
|
case NC_BRUSH:
|
|
|
|
|
if (wmn->action == NA_EDITED) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-07-04 13:12:42 +02:00
|
|
|
}
|
|
|
|
|
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 */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_tools_region_init(wmWindowManager *wm, ARegion *region)
|
2010-01-19 01:32:06 +00:00
|
|
|
{
|
|
|
|
|
wmKeyMap *keymap;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
|
|
|
|
|
ED_region_panels_init(wm, region);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2023-09-14 13:32:42 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_tools_region_draw(const bContext *C, ARegion *region)
|
2010-01-19 01:32:06 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_panels(C, region);
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 12:59:00 +11:00
|
|
|
static void image_tools_region_listener(const wmRegionListenerParams *params)
|
2010-01-19 01:32:06 +00:00
|
|
|
{
|
2021-01-18 17:28:47 -06:00
|
|
|
ARegion *region = params->region;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
2021-01-18 17:28:47 -06:00
|
|
|
|
2010-01-19 01:32:06 +00:00
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
switch (wmn->category) {
|
2014-02-28 18:12:05 +01:00
|
|
|
case NC_GPENCIL:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2014-02-28 18:12:05 +01:00
|
|
|
break;
|
|
|
|
|
case NC_BRUSH:
|
2015-09-21 10:32:14 +10:00
|
|
|
/* NA_SELECTED is used on brush changes */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2014-02-28 18:12:05 +01:00
|
|
|
break;
|
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:
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2010-01-28 07:26:21 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NC_IMAGE:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (wmn->action != NA_PAINTING) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2010-01-28 07:26:21 +00:00
|
|
|
break;
|
|
|
|
|
case NC_NODE:
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2010-01-28 07:26:21 +00:00
|
|
|
break;
|
2010-01-19 01:32:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-27 15:46:54 +02:00
|
|
|
/************************* Tool header region **************************/
|
|
|
|
|
|
|
|
|
|
static void image_tools_header_region_draw(const bContext *C, ARegion *region)
|
|
|
|
|
{
|
|
|
|
|
ScrArea *area = CTX_wm_area(C);
|
|
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
|
|
|
|
|
|
|
|
|
image_user_refresh_scene(C, sima);
|
|
|
|
|
|
2023-09-27 19:53:11 +02:00
|
|
|
ED_region_header_with_button_sections(
|
|
|
|
|
C,
|
|
|
|
|
region,
|
|
|
|
|
(RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ?
|
|
|
|
|
uiButtonSectionsAlign::Top :
|
|
|
|
|
uiButtonSectionsAlign::Bottom);
|
2023-09-27 15:46:54 +02: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 */
|
2023-07-12 13:43:00 +02:00
|
|
|
static void image_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_header_init(region);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void image_header_region_draw(const bContext *C, ARegion *region)
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2023-07-12 13:43:00 +02:00
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
2018-01-17 10:00:14 +11:00
|
|
|
|
|
|
|
|
image_user_refresh_scene(C, sima);
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_header(C, region);
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 12:59:00 +11:00
|
|
|
static void image_header_region_listener(const wmRegionListenerParams *params)
|
2010-03-09 06:49:58 +00:00
|
|
|
{
|
2021-01-18 17:28:47 -06:00
|
|
|
ARegion *region = params->region;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
2021-01-18 17:28:47 -06:00
|
|
|
|
2010-03-09 06:49:58 +00:00
|
|
|
/* 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:
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2010-03-09 06:49:58 +00:00
|
|
|
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:
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2010-03-09 06:49:58 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2013-07-21 17:04:54 +00:00
|
|
|
break;
|
2019-07-04 13:12:42 +02:00
|
|
|
case NC_BRUSH:
|
|
|
|
|
if (wmn->action == NA_EDITED) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2019-07-04 13:12:42 +02:00
|
|
|
}
|
|
|
|
|
break;
|
2024-03-28 12:15:33 +01:00
|
|
|
case NC_GPENCIL:
|
|
|
|
|
if (wmn->data & ND_GPENCIL_EDITMODE) {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
}
|
|
|
|
|
else if (wmn->action == NA_EDITED) {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2010-03-09 06:49:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-24 17:55:37 +02:00
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
|
static void image_asset_shelf_region_init(wmWindowManager *wm, ARegion *region)
|
|
|
|
|
{
|
|
|
|
|
using namespace blender::ed;
|
|
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(
|
|
|
|
|
wm->defaultconf, "Image Generic", SPACE_IMAGE, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2024-04-24 17:55:37 +02:00
|
|
|
|
|
|
|
|
asset::shelf::region_init(wm, region);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-13 15:36:38 +01:00
|
|
|
static void image_id_remap(ScrArea * /*area*/,
|
|
|
|
|
SpaceLink *slink,
|
|
|
|
|
const blender::bke::id::IDRemapper &mappings)
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
{
|
|
|
|
|
SpaceImage *simg = (SpaceImage *)slink;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-02-13 15:36:38 +01:00
|
|
|
if (!mappings.contains_mappings_for_any(FILTER_ID_IM | FILTER_ID_GD_LEGACY | FILTER_ID_MSK)) {
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-06 18:32:11 -05:00
|
|
|
mappings.apply(reinterpret_cast<ID **>(&simg->image), ID_REMAP_APPLY_ENSURE_REAL);
|
|
|
|
|
mappings.apply(reinterpret_cast<ID **>(&simg->gpd), ID_REMAP_APPLY_UPDATE_REFCOUNT);
|
|
|
|
|
mappings.apply(reinterpret_cast<ID **>(&simg->mask_info.mask), ID_REMAP_APPLY_ENSURE_REAL);
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 14:42:04 +02:00
|
|
|
static void image_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data)
|
|
|
|
|
{
|
|
|
|
|
SpaceImage *simg = reinterpret_cast<SpaceImage *>(space_link);
|
|
|
|
|
const int data_flags = BKE_lib_query_foreachid_process_flags_get(data);
|
|
|
|
|
const bool is_readonly = (data_flags & IDWALK_READONLY) != 0;
|
|
|
|
|
|
2024-05-24 13:28:34 +02:00
|
|
|
BKE_LIB_FOREACHID_PROCESS_IDSUPER(
|
|
|
|
|
data, simg->image, IDWALK_CB_USER_ONE | IDWALK_CB_DIRECT_WEAK_LINK);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, simg->iuser.scene, IDWALK_CB_DIRECT_WEAK_LINK);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_IDSUPER(
|
|
|
|
|
data, simg->mask_info.mask, IDWALK_CB_USER_ONE | IDWALK_CB_DIRECT_WEAK_LINK);
|
|
|
|
|
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, simg->gpd, IDWALK_CB_USER | IDWALK_CB_DIRECT_WEAK_LINK);
|
2023-08-17 14:42:04 +02:00
|
|
|
if (!is_readonly) {
|
|
|
|
|
simg->scopes.ok = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-05 14:35:45 +11:00
|
|
|
/**
|
|
|
|
|
* \note Used for splitting out a subset of modes is more involved,
|
|
|
|
|
* The previous non-uv-edit mode is stored so switching back to the
|
|
|
|
|
* image doesn't always reset the sub-mode.
|
|
|
|
|
*/
|
2020-04-03 13:25:03 +02:00
|
|
|
static int image_space_subtype_get(ScrArea *area)
|
2018-12-05 14:35:45 +11:00
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
2018-12-05 14:35:45 +11:00
|
|
|
return sima->mode == SI_MODE_UV ? SI_MODE_UV : SI_MODE_VIEW;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
static void image_space_subtype_set(ScrArea *area, int value)
|
2018-12-05 14:35:45 +11:00
|
|
|
{
|
2023-07-12 13:43:00 +02:00
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
2025-02-18 14:09:42 +01:00
|
|
|
if (value == SI_MODE_UV) {
|
|
|
|
|
if (sima->mode != SI_MODE_UV) {
|
|
|
|
|
sima->mode_prev = sima->mode;
|
|
|
|
|
}
|
|
|
|
|
sima->mode = value;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
sima->mode = sima->mode_prev;
|
|
|
|
|
}
|
2018-12-05 14:35:45 +11:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
static void image_space_subtype_item_extend(bContext * /*C*/,
|
2018-12-05 14:35:45 +11:00
|
|
|
EnumPropertyItem **item,
|
|
|
|
|
int *totitem)
|
|
|
|
|
{
|
|
|
|
|
RNA_enum_items_add(item, totitem, rna_enum_space_image_mode_items);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 01:13:44 +02:00
|
|
|
static blender::StringRefNull image_space_name_get(const ScrArea *area)
|
2024-07-11 20:40:06 +02:00
|
|
|
{
|
|
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
2024-08-24 00:16:42 +02:00
|
|
|
int index = RNA_enum_from_value(rna_enum_space_image_mode_items, sima->mode);
|
|
|
|
|
if (index < 0) {
|
|
|
|
|
index = SI_MODE_VIEW;
|
|
|
|
|
}
|
2024-08-24 21:32:17 +02:00
|
|
|
const EnumPropertyItem item = rna_enum_space_image_mode_items[index];
|
2024-07-11 20:40:06 +02:00
|
|
|
return item.name;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 00:08:19 +02:00
|
|
|
static int image_space_icon_get(const ScrArea *area)
|
|
|
|
|
{
|
|
|
|
|
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
|
2024-08-24 00:16:42 +02:00
|
|
|
int index = RNA_enum_from_value(rna_enum_space_image_mode_items, sima->mode);
|
|
|
|
|
if (index < 0) {
|
|
|
|
|
index = SI_MODE_VIEW;
|
|
|
|
|
}
|
2024-07-12 00:08:19 +02:00
|
|
|
const EnumPropertyItem item = rna_enum_space_image_mode_items[index];
|
|
|
|
|
return item.icon;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
static void image_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *sl)
|
2022-09-28 11:52:22 +02:00
|
|
|
{
|
|
|
|
|
SpaceImage *sima = (SpaceImage *)sl;
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
sima->iuser.scene = nullptr;
|
|
|
|
|
sima->scopes.waveform_1 = nullptr;
|
|
|
|
|
sima->scopes.waveform_2 = nullptr;
|
|
|
|
|
sima->scopes.waveform_3 = nullptr;
|
|
|
|
|
sima->scopes.vecscope = nullptr;
|
2024-02-26 14:54:05 +02:00
|
|
|
sima->scopes.vecscope_rgb = nullptr;
|
2022-09-28 11:52:22 +02:00
|
|
|
sima->scopes.ok = 0;
|
|
|
|
|
|
2023-07-12 13:43:00 +02:00
|
|
|
/* WARNING: gpencil data is no longer stored directly in sima after 2.5
|
|
|
|
|
* so sacrifice a few old files for now to avoid crashes with new files!
|
|
|
|
|
* committed: r28002 */
|
2022-09-28 11:52:22 +02:00
|
|
|
#if 0
|
2023-07-12 13:43:00 +02:00
|
|
|
sima->gpd = newdataadr(fd, sima->gpd);
|
|
|
|
|
if (sima->gpd) {
|
|
|
|
|
BKE_gpencil_blend_read_data(fd, sima->gpd);
|
|
|
|
|
}
|
2022-09-28 11:52:22 +02:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-27 14:42:21 +10:00
|
|
|
static void image_space_blend_write(BlendWriter *writer, SpaceLink *sl)
|
2022-09-28 11:52:22 +02:00
|
|
|
{
|
|
|
|
|
BLO_write_struct(writer, SpaceImage, sl);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2023-07-13 09:54:02 +10:00
|
|
|
void ED_spacetype_image()
|
2008-12-13 17:44:30 +00:00
|
|
|
{
|
2024-04-24 17:55:37 +02:00
|
|
|
using namespace blender::ed;
|
2024-02-02 20:59:20 +01:00
|
|
|
std::unique_ptr<SpaceType> st = std::make_unique<SpaceType>();
|
2008-12-13 17:44:30 +00:00
|
|
|
ARegionType *art;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
st->spaceid = SPACE_IMAGE;
|
2025-07-27 16:41:19 +10:00
|
|
|
STRNCPY_UTF8(st->name, "Image");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-04 14:39:53 +02:00
|
|
|
st->create = image_create;
|
2012-03-28 11:53:18 +00:00
|
|
|
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;
|
2018-07-14 23:49:00 +02:00
|
|
|
st->gizmos = image_widgets;
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
st->id_remap = image_id_remap;
|
2023-08-17 14:42:04 +02:00
|
|
|
st->foreach_id = image_foreach_id;
|
2018-12-05 14:35:45 +11:00
|
|
|
st->space_subtype_item_extend = image_space_subtype_item_extend;
|
|
|
|
|
st->space_subtype_get = image_space_subtype_get;
|
|
|
|
|
st->space_subtype_set = image_space_subtype_set;
|
2024-07-11 20:40:06 +02:00
|
|
|
st->space_name_get = image_space_name_get;
|
2024-07-12 00:08:19 +02:00
|
|
|
st->space_icon_get = image_space_icon_get;
|
2023-04-27 14:42:21 +10:00
|
|
|
st->blend_read_data = image_space_blend_read_data;
|
2023-03-11 18:07:59 +01:00
|
|
|
st->blend_read_after_liblink = nullptr;
|
2023-04-27 14:42:21 +10:00
|
|
|
st->blend_write = image_space_blend_write;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* regions: main window */
|
2025-04-12 17:17:24 +02:00
|
|
|
art = MEM_callocN<ARegionType>("spacetype image region");
|
2008-12-13 17:44:30 +00:00
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2019-02-20 14:29:29 +11:00
|
|
|
art->keymapflag = ED_KEYMAP_GIZMO | ED_KEYMAP_TOOL | ED_KEYMAP_FRAMES | ED_KEYMAP_GPENCIL;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = image_main_region_init;
|
|
|
|
|
art->draw = image_main_region_draw;
|
|
|
|
|
art->listener = image_main_region_listener;
|
2025-07-14 16:17:46 +02:00
|
|
|
art->lock = REGION_DRAW_LOCK_BAKING;
|
2008-12-13 17:44:30 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-24 11:21:18 +10:00
|
|
|
/* regions: list-view/buttons/scopes */
|
2025-04-12 17:17:24 +02:00
|
|
|
art = MEM_callocN<ARegionType>("spacetype image region");
|
2009-02-21 15:31:01 +00:00
|
|
|
art->regionid = RGN_TYPE_UI;
|
2019-05-15 16:17:23 +02:00
|
|
|
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
|
2012-03-28 11:53:18 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->listener = image_buttons_region_listener;
|
2019-05-03 14:15:38 +10:00
|
|
|
art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_ui;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = image_buttons_region_init;
|
2025-06-12 20:38:35 +02:00
|
|
|
art->snap_size = ED_region_generic_panel_region_snap_size;
|
2019-05-01 12:35:00 +10:00
|
|
|
art->layout = image_buttons_region_layout;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->draw = image_buttons_region_draw;
|
2009-02-21 15:31:01 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-05-02 11:11:57 +00:00
|
|
|
ED_uvedit_buttons_register(art);
|
2014-02-13 19:49:26 +02:00
|
|
|
image_buttons_register(art);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-24 14:36:52 +01:00
|
|
|
/* regions: tool(bar) */
|
2025-04-12 17:17:24 +02:00
|
|
|
art = MEM_callocN<ARegionType>("spacetype image region");
|
2014-02-13 19:49:26 +02:00
|
|
|
art->regionid = RGN_TYPE_TOOLS;
|
2023-07-13 09:54:02 +10:00
|
|
|
art->prefsizex = int(UI_TOOLBAR_WIDTH);
|
2018-10-04 08:54:48 +10:00
|
|
|
art->prefsizey = 50; /* XXX */
|
2012-03-28 11:53:18 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->listener = image_tools_region_listener;
|
2018-10-04 08:54:48 +10:00
|
|
|
art->message_subscribe = ED_region_generic_tools_region_message_subscribe;
|
|
|
|
|
art->snap_size = ED_region_generic_tools_region_snap_size;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = image_tools_region_init;
|
|
|
|
|
art->draw = image_tools_region_draw;
|
2010-01-19 01:32:06 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-18 21:13:22 +02:00
|
|
|
/* regions: tool header */
|
2025-04-12 17:17:24 +02:00
|
|
|
art = MEM_callocN<ARegionType>("spacetype image tool header region");
|
2019-04-18 21:13:22 +02:00
|
|
|
art->regionid = RGN_TYPE_TOOL_HEADER;
|
|
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
|
|
|
|
|
art->listener = image_header_region_listener;
|
|
|
|
|
art->init = image_header_region_init;
|
2023-09-27 15:46:54 +02:00
|
|
|
art->draw = image_tools_header_region_draw;
|
2019-04-18 21:13:22 +02:00
|
|
|
art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
/* regions: header */
|
2025-04-12 17:17:24 +02:00
|
|
|
art = MEM_callocN<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;
|
2015-11-28 17:14:45 +01:00
|
|
|
art->listener = image_header_region_listener;
|
|
|
|
|
art->init = image_header_region_init;
|
|
|
|
|
art->draw = image_header_region_draw;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-13 17:44:30 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-04-24 17:55:37 +02:00
|
|
|
/* regions: asset shelf */
|
2025-03-05 16:35:09 +01:00
|
|
|
art = MEM_callocN<ARegionType>("spacetype image asset shelf region");
|
2024-04-24 17:55:37 +02:00
|
|
|
art->regionid = RGN_TYPE_ASSET_SHELF;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_FRAMES;
|
|
|
|
|
art->duplicate = asset::shelf::region_duplicate;
|
|
|
|
|
art->free = asset::shelf::region_free;
|
2024-05-02 10:27:55 -04:00
|
|
|
art->on_poll_success = asset::shelf::region_on_poll_success;
|
2024-04-24 17:55:37 +02:00
|
|
|
art->listener = asset::shelf::region_listen;
|
2024-07-07 18:47:33 +02:00
|
|
|
art->message_subscribe = asset::shelf::region_message_subscribe;
|
2024-04-24 17:55:37 +02:00
|
|
|
art->poll = asset::shelf::regions_poll;
|
|
|
|
|
art->snap_size = asset::shelf::region_snap;
|
|
|
|
|
art->on_user_resize = asset::shelf::region_on_user_resize;
|
|
|
|
|
art->context = asset::shelf::context;
|
|
|
|
|
art->init = image_asset_shelf_region_init;
|
|
|
|
|
art->layout = asset::shelf::region_layout;
|
|
|
|
|
art->draw = asset::shelf::region_draw;
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
|
|
/* regions: asset shelf header */
|
2025-03-05 16:35:09 +01:00
|
|
|
art = MEM_callocN<ARegionType>("spacetype image asset shelf header region");
|
2024-04-24 17:55:37 +02:00
|
|
|
art->regionid = RGN_TYPE_ASSET_SHELF_HEADER;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_ASSET_SHELF | ED_KEYMAP_VIEW2D | ED_KEYMAP_FOOTER;
|
|
|
|
|
art->init = asset::shelf::header_region_init;
|
|
|
|
|
art->poll = asset::shelf::regions_poll;
|
|
|
|
|
art->draw = asset::shelf::header_region;
|
|
|
|
|
art->listener = asset::shelf::header_region_listen;
|
|
|
|
|
art->context = asset::shelf::context;
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2024-07-07 20:00:35 +02:00
|
|
|
asset::shelf::types_register(art, SPACE_IMAGE);
|
2024-04-24 17:55:37 +02:00
|
|
|
|
2018-06-12 10:11:32 +02:00
|
|
|
/* regions: hud */
|
|
|
|
|
art = ED_area_type_hud(st->spaceid);
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-02-02 20:59:20 +01:00
|
|
|
BKE_spacetype_register(std::move(st));
|
2008-12-13 17:44:30 +00:00
|
|
|
}
|