2011-02-23 10:52:22 +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
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
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
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spimage
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2009-02-21 18:33:09 +00:00
|
|
|
#include "DNA_node_types.h"
|
2009-02-21 15:31:01 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-02-21 15:31:01 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2012-05-25 17:58:15 +00:00
|
|
|
|
2009-02-21 15:31:01 +00:00
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_image.h"
|
2009-02-21 18:33:09 +00:00
|
|
|
#include "BKE_node.h"
|
2009-02-21 15:31:01 +00:00
|
|
|
#include "BKE_screen.h"
|
2015-04-06 10:40:12 -03:00
|
|
|
#include "BKE_scene.h"
|
2009-02-21 15:31:01 +00:00
|
|
|
|
2009-02-21 18:33:09 +00:00
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
|
2019-05-18 20:52:20 +02:00
|
|
|
#include "IMB_colormanagement.h"
|
2009-02-21 15:31:01 +00:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
2009-08-30 13:32:08 +00:00
|
|
|
#include "ED_gpencil.h"
|
2009-02-21 15:31:01 +00:00
|
|
|
#include "ED_screen.h"
|
2015-11-16 07:13:40 +11:00
|
|
|
#include "ED_image.h"
|
2009-02-21 15:31:01 +00:00
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
|
|
#include "image_intern.h"
|
|
|
|
|
|
2014-02-12 00:08:54 +11:00
|
|
|
#define B_NOP -1
|
2019-04-17 06:17:24 +02:00
|
|
|
#define MAX_IMAGE_INFO_LEN 128
|
2014-02-12 00:08:54 +11:00
|
|
|
|
2009-02-21 18:33:09 +00:00
|
|
|
/* gets active viewer user */
|
2012-04-21 12:51:47 +00:00
|
|
|
struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
|
|
if (ntree) {
|
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
|
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
|
|
|
|
if (node->flag & NODE_DO_OUTPUT) {
|
|
|
|
|
return node->storage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
2009-02-21 18:33:09 +00:00
|
|
|
}
|
2009-02-21 15:31:01 +00:00
|
|
|
|
2009-02-21 18:33:09 +00:00
|
|
|
/* ********************* callbacks for standard image buttons *************** */
|
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
|
|
|
|
2014-10-09 11:15:47 +02:00
|
|
|
static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p)
|
2010-02-09 19:37:37 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
|
|
|
|
Image *image = image_p;
|
|
|
|
|
int slot_id;
|
|
|
|
|
|
|
|
|
|
uiDefBut(block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
IFACE_("Slot"),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
NULL,
|
|
|
|
|
0.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
|
|
slot_id = BLI_listbase_count(&image->renderslots) - 1;
|
|
|
|
|
for (RenderSlot *slot = image->renderslots.last; slot; slot = slot->prev) {
|
|
|
|
|
char str[64];
|
|
|
|
|
if (slot->name[0] != '\0') {
|
|
|
|
|
BLI_strncpy(str, slot->name, sizeof(str));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1);
|
|
|
|
|
}
|
|
|
|
|
uiDefButS(block,
|
|
|
|
|
UI_BTYPE_BUT_MENU,
|
|
|
|
|
B_NOP,
|
|
|
|
|
str,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_X,
|
|
|
|
|
&image->render_slot,
|
|
|
|
|
(float)slot_id,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
-1,
|
|
|
|
|
"");
|
|
|
|
|
slot_id--;
|
|
|
|
|
}
|
2010-02-09 19:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-16 07:13:40 +11:00
|
|
|
static bool ui_imageuser_slot_menu_step(bContext *C, int direction, void *image_p)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *image = image_p;
|
|
|
|
|
|
|
|
|
|
if (ED_image_slot_cycle(image, direction)) {
|
|
|
|
|
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-11-16 07:13:40 +11:00
|
|
|
}
|
|
|
|
|
|
2014-02-12 00:08:54 +11:00
|
|
|
static const char *ui_imageuser_layer_fake_name(RenderResult *rr)
|
2009-02-21 18:33:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
RenderView *rv = RE_RenderViewGetById(rr, 0);
|
|
|
|
|
if (rv->rectf) {
|
|
|
|
|
return IFACE_("Composite");
|
|
|
|
|
}
|
|
|
|
|
else if (rv->rect32) {
|
|
|
|
|
return IFACE_("Sequence");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2014-02-12 00:08:54 +11:00
|
|
|
}
|
|
|
|
|
|
2015-11-16 06:44:18 +11:00
|
|
|
/* workaround for passing many args */
|
|
|
|
|
struct ImageUI_Data {
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *image;
|
|
|
|
|
ImageUser *iuser;
|
|
|
|
|
int rpass_index;
|
2015-11-16 06:44:18 +11:00
|
|
|
};
|
|
|
|
|
|
2016-07-19 02:44:14 +10:00
|
|
|
static struct ImageUI_Data *ui_imageuser_data_copy(const struct ImageUI_Data *rnd_pt_src)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data *rnd_pt_dst = MEM_mallocN(sizeof(*rnd_pt_src), __func__);
|
|
|
|
|
memcpy(rnd_pt_dst, rnd_pt_src, sizeof(*rnd_pt_src));
|
|
|
|
|
return rnd_pt_dst;
|
2016-07-19 02:44:14 +10:00
|
|
|
}
|
|
|
|
|
|
2014-02-12 00:08:54 +11:00
|
|
|
static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
|
|
|
|
Image *image = rnd_data->image;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
|
|
|
|
Scene *scene = iuser->scene;
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
RenderLayer *rl;
|
|
|
|
|
RenderLayer rl_fake = {NULL};
|
|
|
|
|
const char *fake_name;
|
|
|
|
|
int nr;
|
|
|
|
|
|
|
|
|
|
/* may have been freed since drawing */
|
|
|
|
|
rr = BKE_image_acquire_renderresult(scene, image);
|
|
|
|
|
if (UNLIKELY(rr == NULL)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_block_layout_set_current(block, layout);
|
|
|
|
|
uiLayoutColumn(layout, false);
|
|
|
|
|
|
|
|
|
|
uiDefBut(block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
IFACE_("Layer"),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
NULL,
|
|
|
|
|
0.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
|
|
nr = BLI_listbase_count(&rr->layers) - 1;
|
|
|
|
|
fake_name = ui_imageuser_layer_fake_name(rr);
|
|
|
|
|
|
|
|
|
|
if (fake_name) {
|
|
|
|
|
BLI_strncpy(rl_fake.name, fake_name, sizeof(rl_fake.name));
|
|
|
|
|
nr += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (rl = rr->layers.last; rl; rl = rl->prev, nr--) {
|
|
|
|
|
final:
|
|
|
|
|
uiDefButS(block,
|
|
|
|
|
UI_BTYPE_BUT_MENU,
|
|
|
|
|
B_NOP,
|
|
|
|
|
rl->name,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_X,
|
|
|
|
|
&iuser->layer,
|
|
|
|
|
(float)nr,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
-1,
|
|
|
|
|
"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fake_name) {
|
|
|
|
|
fake_name = NULL;
|
|
|
|
|
rl = &rl_fake;
|
|
|
|
|
goto final;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_assert(nr == -1);
|
|
|
|
|
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
2014-02-12 00:08:54 +11:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
|
2009-02-21 18:33:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
|
|
|
|
Image *image = rnd_data->image;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
|
|
|
|
/* (rpass_index == -1) means composite result */
|
|
|
|
|
const int rpass_index = rnd_data->rpass_index;
|
|
|
|
|
Scene *scene = iuser->scene;
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
RenderLayer *rl;
|
|
|
|
|
RenderPass *rpass;
|
|
|
|
|
int nr;
|
|
|
|
|
|
|
|
|
|
/* may have been freed since drawing */
|
|
|
|
|
rr = BKE_image_acquire_renderresult(scene, image);
|
|
|
|
|
if (UNLIKELY(rr == NULL)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rl = BLI_findlink(&rr->layers, rpass_index);
|
|
|
|
|
|
|
|
|
|
UI_block_layout_set_current(block, layout);
|
|
|
|
|
uiLayoutColumn(layout, false);
|
|
|
|
|
|
|
|
|
|
uiDefBut(block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
IFACE_("Pass"),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
NULL,
|
|
|
|
|
0.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
|
|
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
|
|
nr = (rl == NULL) ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
ListBase added_passes;
|
|
|
|
|
BLI_listbase_clear(&added_passes);
|
|
|
|
|
|
|
|
|
|
/* rendered results don't have a Combined pass */
|
|
|
|
|
/* multiview: the ordering must be ascending, so the left-most pass is always the one picked */
|
|
|
|
|
for (rpass = rl ? rl->passes.first : NULL; rpass; rpass = rpass->next, nr++) {
|
|
|
|
|
/* just show one pass of each kind */
|
|
|
|
|
if (BLI_findstring_ptr(&added_passes, rpass->name, offsetof(LinkData, data))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
BLI_addtail(&added_passes, BLI_genericNodeN(rpass->name));
|
|
|
|
|
|
|
|
|
|
uiDefButS(block,
|
|
|
|
|
UI_BTYPE_BUT_MENU,
|
|
|
|
|
B_NOP,
|
|
|
|
|
IFACE_(rpass->name),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_X,
|
|
|
|
|
&iuser->pass,
|
|
|
|
|
(float)nr,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
-1,
|
|
|
|
|
"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_freelistN(&added_passes);
|
|
|
|
|
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
2009-02-21 18:33:09 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/**************************** view menus *****************************/
|
|
|
|
|
static void ui_imageuser_view_menu_rr(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
|
|
|
|
Image *image = rnd_data->image;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
RenderView *rview;
|
|
|
|
|
int nr;
|
|
|
|
|
Scene *scene = iuser->scene;
|
|
|
|
|
|
|
|
|
|
/* may have been freed since drawing */
|
|
|
|
|
rr = BKE_image_acquire_renderresult(scene, image);
|
|
|
|
|
if (UNLIKELY(rr == NULL)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UI_block_layout_set_current(block, layout);
|
|
|
|
|
uiLayoutColumn(layout, false);
|
|
|
|
|
|
|
|
|
|
uiDefBut(block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
IFACE_("View"),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
NULL,
|
|
|
|
|
0.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
|
|
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
|
|
nr = (rr ? BLI_listbase_count(&rr->views) : 0) - 1;
|
|
|
|
|
for (rview = rr ? rr->views.last : NULL; rview; rview = rview->prev, nr--) {
|
|
|
|
|
uiDefButS(block,
|
|
|
|
|
UI_BTYPE_BUT_MENU,
|
|
|
|
|
B_NOP,
|
|
|
|
|
IFACE_(rview->name),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_X,
|
|
|
|
|
&iuser->view,
|
|
|
|
|
(float)nr,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
-1,
|
|
|
|
|
"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ui_imageuser_view_menu_multiview(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
|
|
|
|
Image *image = rnd_data->image;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
|
|
|
|
int nr;
|
|
|
|
|
ImageView *iv;
|
|
|
|
|
|
|
|
|
|
UI_block_layout_set_current(block, layout);
|
|
|
|
|
uiLayoutColumn(layout, false);
|
|
|
|
|
|
|
|
|
|
uiDefBut(block,
|
|
|
|
|
UI_BTYPE_LABEL,
|
|
|
|
|
0,
|
|
|
|
|
IFACE_("View"),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
NULL,
|
|
|
|
|
0.0,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
"");
|
|
|
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
|
|
nr = BLI_listbase_count(&image->views) - 1;
|
|
|
|
|
for (iv = image->views.last; iv; iv = iv->prev, nr--) {
|
|
|
|
|
uiDefButS(block,
|
|
|
|
|
UI_BTYPE_BUT_MENU,
|
|
|
|
|
B_NOP,
|
|
|
|
|
IFACE_(iv->name),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
UI_UNIT_X * 5,
|
|
|
|
|
UI_UNIT_X,
|
|
|
|
|
&iuser->view,
|
|
|
|
|
(float)nr,
|
|
|
|
|
0.0,
|
|
|
|
|
0,
|
|
|
|
|
-1,
|
|
|
|
|
"");
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2009-02-21 18:33:09 +00:00
|
|
|
/* 5 layer button callbacks... */
|
2016-07-19 02:44:14 +10:00
|
|
|
static void image_multi_cb(bContext *C, void *rnd_pt, void *rr_v)
|
2009-02-21 18:33:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
2010-02-09 19:37:37 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_multilayer_index(rr_v, iuser);
|
|
|
|
|
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
|
2009-02-21 18:33:09 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-11-16 07:13:40 +11:00
|
|
|
static bool ui_imageuser_layer_menu_step(bContext *C, int direction, void *rnd_pt)
|
2009-02-21 18:33:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
Image *image = rnd_data->image;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
|
|
rr = BKE_image_acquire_renderresult(scene, image);
|
|
|
|
|
if (UNLIKELY(rr == NULL)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (direction == -1) {
|
|
|
|
|
if (iuser->layer > 0) {
|
|
|
|
|
iuser->layer--;
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (direction == 1) {
|
|
|
|
|
int tot = BLI_listbase_count(&rr->layers);
|
|
|
|
|
|
|
|
|
|
if (RE_HasCombinedLayer(rr)) {
|
|
|
|
|
tot++; /* fake compo/sequencer layer */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (iuser->layer < tot - 1) {
|
|
|
|
|
iuser->layer++;
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
|
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
|
BKE_image_multilayer_index(rr, iuser);
|
|
|
|
|
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
2009-02-21 18:33:09 +00:00
|
|
|
}
|
2015-11-16 07:13:40 +11:00
|
|
|
|
|
|
|
|
static bool ui_imageuser_pass_menu_step(bContext *C, int direction, void *rnd_pt)
|
2009-02-21 18:33:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
Image *image = rnd_data->image;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
bool changed = false;
|
|
|
|
|
int layer = iuser->layer;
|
|
|
|
|
RenderLayer *rl;
|
|
|
|
|
RenderPass *rpass;
|
|
|
|
|
|
|
|
|
|
rr = BKE_image_acquire_renderresult(scene, image);
|
|
|
|
|
if (UNLIKELY(rr == NULL)) {
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RE_HasCombinedLayer(rr)) {
|
|
|
|
|
layer -= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rl = BLI_findlink(&rr->layers, layer);
|
|
|
|
|
if (rl == NULL) {
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rpass = BLI_findlink(&rl->passes, iuser->pass);
|
|
|
|
|
if (rpass == NULL) {
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* note, this looks reversed, but matches menu direction */
|
|
|
|
|
if (direction == -1) {
|
|
|
|
|
RenderPass *rp;
|
|
|
|
|
int rp_index = iuser->pass + 1;
|
|
|
|
|
|
|
|
|
|
for (rp = rpass->next; rp; rp = rp->next, rp_index++) {
|
|
|
|
|
if (!STREQ(rp->name, rpass->name)) {
|
|
|
|
|
iuser->pass = rp_index;
|
|
|
|
|
changed = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (direction == 1) {
|
|
|
|
|
RenderPass *rp;
|
|
|
|
|
int rp_index = 0;
|
|
|
|
|
|
|
|
|
|
if (iuser->pass == 0) {
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (rp = rl->passes.first; rp; rp = rp->next, rp_index++) {
|
|
|
|
|
if (STREQ(rp->name, rpass->name)) {
|
|
|
|
|
iuser->pass = rp_index - 1;
|
|
|
|
|
changed = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_image_release_renderresult(scene, image);
|
|
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
|
BKE_image_multilayer_index(rr, iuser);
|
|
|
|
|
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
2009-02-21 18:33:09 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* 5 view button callbacks... */
|
2016-07-19 02:44:14 +10:00
|
|
|
static void image_multiview_cb(bContext *C, void *rnd_pt, void *UNUSED(arg_v))
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data *rnd_data = rnd_pt;
|
|
|
|
|
Image *ima = rnd_data->image;
|
|
|
|
|
ImageUser *iuser = rnd_data->iuser;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_multiview_index(ima, iuser);
|
|
|
|
|
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2015-11-16 05:31:03 +11:00
|
|
|
static void uiblock_layer_pass_buttons(
|
2019-04-17 06:17:24 +02:00
|
|
|
uiLayout *layout, Image *image, RenderResult *rr, ImageUser *iuser, int w, short *render_slot)
|
2009-02-21 18:33:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
struct ImageUI_Data rnd_pt_local, *rnd_pt = NULL;
|
|
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
|
|
|
|
uiBut *but;
|
|
|
|
|
RenderLayer *rl = NULL;
|
|
|
|
|
int wmenu1, wmenu2, wmenu3, wmenu4;
|
|
|
|
|
const char *fake_name;
|
|
|
|
|
const char *display_name = "";
|
|
|
|
|
const bool show_stereo = (iuser->flag & IMA_SHOW_STEREO) != 0;
|
|
|
|
|
|
|
|
|
|
if (iuser->scene == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiLayoutRow(layout, true);
|
|
|
|
|
|
|
|
|
|
/* layer menu is 1/3 larger than pass */
|
|
|
|
|
wmenu1 = (2 * w) / 5;
|
|
|
|
|
wmenu2 = (3 * w) / 5;
|
|
|
|
|
wmenu3 = (3 * w) / 6;
|
|
|
|
|
wmenu4 = (3 * w) / 6;
|
|
|
|
|
|
|
|
|
|
rnd_pt_local.image = image;
|
|
|
|
|
rnd_pt_local.iuser = iuser;
|
|
|
|
|
rnd_pt_local.rpass_index = 0;
|
|
|
|
|
|
|
|
|
|
/* menu buts */
|
|
|
|
|
if (render_slot) {
|
|
|
|
|
char str[64];
|
|
|
|
|
RenderSlot *slot = BKE_image_get_renderslot(image, *render_slot);
|
|
|
|
|
if (slot && slot->name[0] != '\0') {
|
|
|
|
|
BLI_strncpy(str, slot->name, sizeof(str));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rnd_pt = ui_imageuser_data_copy(&rnd_pt_local);
|
|
|
|
|
but = uiDefMenuBut(
|
|
|
|
|
block, ui_imageuser_slot_menu, image, str, 0, 0, wmenu1, UI_UNIT_Y, TIP_("Select Slot"));
|
|
|
|
|
UI_but_func_menu_step_set(but, ui_imageuser_slot_menu_step);
|
|
|
|
|
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
|
|
|
|
|
UI_but_type_set_menu_from_pulldown(but);
|
|
|
|
|
rnd_pt = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rr) {
|
|
|
|
|
RenderPass *rpass;
|
|
|
|
|
RenderView *rview;
|
|
|
|
|
int rpass_index;
|
|
|
|
|
|
|
|
|
|
/* layer */
|
|
|
|
|
fake_name = ui_imageuser_layer_fake_name(rr);
|
|
|
|
|
rpass_index = iuser->layer - (fake_name ? 1 : 0);
|
|
|
|
|
rl = BLI_findlink(&rr->layers, rpass_index);
|
|
|
|
|
rnd_pt_local.rpass_index = rpass_index;
|
|
|
|
|
|
|
|
|
|
if (RE_layers_have_name(rr)) {
|
|
|
|
|
display_name = rl ? rl->name : (fake_name ? fake_name : "");
|
|
|
|
|
rnd_pt = ui_imageuser_data_copy(&rnd_pt_local);
|
|
|
|
|
but = uiDefMenuBut(block,
|
|
|
|
|
ui_imageuser_layer_menu,
|
|
|
|
|
rnd_pt,
|
|
|
|
|
display_name,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
wmenu2,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
TIP_("Select Layer"));
|
|
|
|
|
UI_but_func_menu_step_set(but, ui_imageuser_layer_menu_step);
|
|
|
|
|
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
|
|
|
|
|
UI_but_type_set_menu_from_pulldown(but);
|
|
|
|
|
rnd_pt = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* pass */
|
|
|
|
|
rpass = (rl ? BLI_findlink(&rl->passes, iuser->pass) : NULL);
|
|
|
|
|
|
|
|
|
|
if (rpass && RE_passes_have_name(rl)) {
|
|
|
|
|
display_name = rpass->name;
|
|
|
|
|
rnd_pt = ui_imageuser_data_copy(&rnd_pt_local);
|
|
|
|
|
but = uiDefMenuBut(block,
|
|
|
|
|
ui_imageuser_pass_menu,
|
|
|
|
|
rnd_pt,
|
|
|
|
|
IFACE_(display_name),
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
wmenu3,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
TIP_("Select Pass"));
|
|
|
|
|
UI_but_func_menu_step_set(but, ui_imageuser_pass_menu_step);
|
|
|
|
|
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
|
|
|
|
|
UI_but_type_set_menu_from_pulldown(but);
|
|
|
|
|
rnd_pt = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* view */
|
|
|
|
|
if (BLI_listbase_count_at_most(&rr->views, 2) > 1 &&
|
|
|
|
|
((!show_stereo) || (!RE_RenderResult_is_stereo(rr)))) {
|
|
|
|
|
rview = BLI_findlink(&rr->views, iuser->view);
|
|
|
|
|
display_name = rview ? rview->name : "";
|
|
|
|
|
|
|
|
|
|
rnd_pt = ui_imageuser_data_copy(&rnd_pt_local);
|
|
|
|
|
but = uiDefMenuBut(block,
|
|
|
|
|
ui_imageuser_view_menu_rr,
|
|
|
|
|
rnd_pt,
|
|
|
|
|
display_name,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
wmenu4,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
TIP_("Select View"));
|
|
|
|
|
UI_but_funcN_set(but, image_multi_cb, rnd_pt, rr);
|
|
|
|
|
UI_but_type_set_menu_from_pulldown(but);
|
|
|
|
|
rnd_pt = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* stereo image */
|
|
|
|
|
else if ((BKE_image_is_stereo(image) && (!show_stereo)) ||
|
|
|
|
|
(BKE_image_is_multiview(image) && !BKE_image_is_stereo(image))) {
|
|
|
|
|
ImageView *iv;
|
|
|
|
|
int nr = 0;
|
|
|
|
|
|
|
|
|
|
for (iv = image->views.first; iv; iv = iv->next) {
|
|
|
|
|
if (nr++ == iuser->view) {
|
|
|
|
|
display_name = iv->name;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rnd_pt = ui_imageuser_data_copy(&rnd_pt_local);
|
|
|
|
|
but = uiDefMenuBut(block,
|
|
|
|
|
ui_imageuser_view_menu_multiview,
|
|
|
|
|
rnd_pt,
|
|
|
|
|
display_name,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
wmenu1,
|
|
|
|
|
UI_UNIT_Y,
|
|
|
|
|
TIP_("Select View"));
|
|
|
|
|
UI_but_funcN_set(but, image_multiview_cb, rnd_pt, NULL);
|
|
|
|
|
UI_but_type_set_menu_from_pulldown(but);
|
|
|
|
|
rnd_pt = NULL;
|
|
|
|
|
}
|
2009-02-21 18:33:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// XXX HACK!
|
2009-09-16 19:27:08 +00:00
|
|
|
// static int packdummy=0;
|
|
|
|
|
|
|
|
|
|
typedef struct RNAUpdateCb {
|
2019-04-17 06:17:24 +02:00
|
|
|
PointerRNA ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
ImageUser *iuser;
|
2009-09-16 19:27:08 +00:00
|
|
|
} RNAUpdateCb;
|
|
|
|
|
|
2010-10-14 12:24:08 +00:00
|
|
|
static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
|
2009-09-16 19:27:08 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb;
|
2009-09-16 19:27:08 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* ideally this would be done by RNA itself, but there we have
|
|
|
|
|
* no image user available, so we just update this flag here */
|
|
|
|
|
cb->iuser->ok = 1;
|
2009-02-21 18:33:09 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* we call update here on the pointer property, this way the
|
|
|
|
|
* owner of the image pointer can still define it's own update
|
|
|
|
|
* and notifier */
|
|
|
|
|
RNA_property_update(C, &cb->ptr, cb->prop);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
static bool image_has_alpha(Image *ima, ImageUser *iuser)
|
|
|
|
|
{
|
|
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
|
|
|
|
|
if (ibuf == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int imtype = BKE_image_ftype_to_imtype(ibuf->ftype, &ibuf->foptions);
|
|
|
|
|
char valid_channels = BKE_imtype_valid_channels(imtype, false);
|
|
|
|
|
bool has_alpha = (valid_channels & IMA_CHAN_FLAG_ALPHA) != 0;
|
|
|
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, ibuf, NULL);
|
|
|
|
|
|
|
|
|
|
return has_alpha;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void uiTemplateImage(uiLayout *layout,
|
|
|
|
|
bContext *C,
|
|
|
|
|
PointerRNA *ptr,
|
|
|
|
|
const char *propname,
|
|
|
|
|
PointerRNA *userptr,
|
|
|
|
|
bool compact,
|
|
|
|
|
bool multiview)
|
2009-02-21 18:33:09 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!ptr->data) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!prop) {
|
|
|
|
|
printf(
|
|
|
|
|
"%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RNA_property_type(prop) != PROP_POINTER) {
|
|
|
|
|
printf("%s: expected pointer property for %s.%s\n",
|
|
|
|
|
__func__,
|
|
|
|
|
RNA_struct_identifier(ptr->type),
|
|
|
|
|
propname);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiBlock *block = uiLayoutGetBlock(layout);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
PointerRNA imaptr = RNA_property_pointer_get(ptr, prop);
|
|
|
|
|
Image *ima = imaptr.data;
|
|
|
|
|
ImageUser *iuser = userptr->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_user_frame_calc(iuser, (int)scene->r.cfra);
|
|
|
|
|
|
|
|
|
|
uiLayoutSetContextPointer(layout, "edit_image", &imaptr);
|
|
|
|
|
uiLayoutSetContextPointer(layout, "edit_image_user", userptr);
|
|
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
SpaceImage *space_image = CTX_wm_space_image(C);
|
2019-05-17 15:10:34 +02:00
|
|
|
if (!compact && (space_image == NULL || iuser != &space_image->iuser)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
uiTemplateID(layout,
|
|
|
|
|
C,
|
|
|
|
|
ptr,
|
|
|
|
|
propname,
|
|
|
|
|
ima ? NULL : "IMAGE_OT_new",
|
|
|
|
|
"IMAGE_OT_open",
|
|
|
|
|
NULL,
|
|
|
|
|
UI_TEMPLATE_ID_FILTER_ALL,
|
|
|
|
|
false);
|
2019-05-19 14:51:21 +02:00
|
|
|
|
|
|
|
|
if (ima != NULL) {
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
if (ima == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
if (ima->source == IMA_SRC_VIEWER) {
|
|
|
|
|
/* Viewer images. */
|
|
|
|
|
uiTemplateImageInfo(layout, C, ima, iuser);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
if (ima->type == IMA_TYPE_COMPOSITE) {
|
|
|
|
|
}
|
|
|
|
|
else if (ima->type == IMA_TYPE_R_RESULT) {
|
|
|
|
|
/* browse layer/passes */
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
const float dpi_fac = UI_DPI_FAC;
|
|
|
|
|
const int menus_width = 230 * dpi_fac;
|
|
|
|
|
|
|
|
|
|
/* use BKE_image_acquire_renderresult so we get the correct slot in the menu */
|
|
|
|
|
rr = BKE_image_acquire_renderresult(scene, ima);
|
|
|
|
|
uiblock_layer_pass_buttons(layout, ima, rr, iuser, menus_width, &ima->render_slot);
|
|
|
|
|
BKE_image_release_renderresult(scene, ima);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set custom callback for property updates. */
|
|
|
|
|
RNAUpdateCb *cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
|
|
|
|
|
cb->ptr = *ptr;
|
|
|
|
|
cb->prop = prop;
|
|
|
|
|
cb->iuser = iuser;
|
|
|
|
|
UI_block_funcN_set(block, rna_update_cb, cb, NULL);
|
|
|
|
|
|
|
|
|
|
/* Disable editing if image was modified, to avoid losing changes. */
|
|
|
|
|
const bool is_dirty = BKE_image_is_dirty(ima);
|
|
|
|
|
if (is_dirty) {
|
|
|
|
|
uiLayout *row = uiLayoutRow(layout, true);
|
|
|
|
|
uiItemO(row, IFACE_("Save"), ICON_NONE, "image.save");
|
2019-05-19 18:56:17 +02:00
|
|
|
uiItemO(row, IFACE_("Discard"), ICON_NONE, "image.reload");
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemS(layout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layout = uiLayoutColumn(layout, false);
|
|
|
|
|
uiLayoutSetEnabled(layout, !is_dirty);
|
|
|
|
|
uiLayoutSetPropDecorate(layout, false);
|
|
|
|
|
|
|
|
|
|
/* Image source */
|
|
|
|
|
{
|
|
|
|
|
uiLayout *col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiLayoutSetPropSep(col, true);
|
|
|
|
|
uiItemR(col, &imaptr, "source", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Filepath */
|
|
|
|
|
const bool is_packed = BKE_image_has_packedfile(ima);
|
|
|
|
|
const bool no_filepath = is_packed && !BKE_image_has_filepath(ima);
|
|
|
|
|
|
|
|
|
|
if ((ima->source != IMA_SRC_GENERATED) && !no_filepath) {
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
|
|
uiLayout *row = uiLayoutRow(layout, true);
|
|
|
|
|
if (is_packed) {
|
|
|
|
|
uiItemO(row, "", ICON_PACKAGE, "image.unpack");
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
|
|
|
|
|
}
|
2019-05-17 15:10:34 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
row = uiLayoutRow(row, true);
|
|
|
|
|
uiLayoutSetEnabled(row, is_packed == false);
|
|
|
|
|
uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
|
|
|
|
|
uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
|
|
|
|
|
}
|
2019-05-17 15:10:34 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
/* Image layers and Info */
|
|
|
|
|
if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
|
|
|
|
|
uiItemS(layout);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
const float dpi_fac = UI_DPI_FAC;
|
|
|
|
|
uiblock_layer_pass_buttons(layout, ima, ima->rr, iuser, 230 * dpi_fac, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (ima->source == IMA_SRC_GENERATED) {
|
|
|
|
|
uiItemS(layout);
|
2018-03-04 22:45:22 +01:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
/* Generated */
|
|
|
|
|
uiLayout *col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiLayoutSetPropSep(col, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiLayout *sub = uiLayoutColumn(col, true);
|
|
|
|
|
uiItemR(sub, &imaptr, "generated_width", 0, "X", ICON_NONE);
|
|
|
|
|
uiItemR(sub, &imaptr, "generated_height", 0, "Y", ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemS(col);
|
2019-05-17 15:10:34 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemR(col, &imaptr, "generated_type", UI_ITEM_R_EXPAND, IFACE_("Type"), ICON_NONE);
|
|
|
|
|
if (ima->gen_type == IMA_GENTYPE_BLANK) {
|
|
|
|
|
uiItemR(col, &imaptr, "generated_color", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (compact == 0) {
|
|
|
|
|
uiTemplateImageInfo(layout, C, ima, iuser);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
if (BKE_image_is_animated(ima)) {
|
|
|
|
|
/* Animation */
|
|
|
|
|
uiItemS(layout);
|
2019-05-17 15:10:34 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiLayout *col = uiLayoutColumn(layout, true);
|
|
|
|
|
uiLayoutSetPropSep(col, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiLayout *sub = uiLayoutColumn(col, true);
|
|
|
|
|
uiLayout *row = uiLayoutRow(sub, true);
|
|
|
|
|
uiItemR(row, userptr, "frame_duration", 0, IFACE_("Frames"), ICON_NONE);
|
|
|
|
|
uiItemO(row, "", ICON_FILE_REFRESH, "IMAGE_OT_match_movie_length");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemR(sub, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
|
|
|
|
|
uiItemR(sub, userptr, "frame_offset", 0, NULL, ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
if (ima->source == IMA_SRC_MOVIE && compact == 0) {
|
|
|
|
|
uiItemR(col, &imaptr, "use_deinterlace", 0, IFACE_("Deinterlace"), ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Multiview */
|
|
|
|
|
if (multiview && compact == 0) {
|
|
|
|
|
if ((scene->r.scemode & R_MULTIVIEW) != 0) {
|
|
|
|
|
uiItemS(layout);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiLayout *col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiLayoutSetPropSep(col, true);
|
|
|
|
|
uiItemR(col, &imaptr, "use_multiview", 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
|
|
if (RNA_boolean_get(&imaptr, "use_multiview")) {
|
|
|
|
|
uiTemplateImageViews(layout, &imaptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-05-19 14:51:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
/* Colorspace and alpha */
|
|
|
|
|
{
|
|
|
|
|
uiItemS(layout);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiLayout *col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiLayoutSetPropSep(col, true);
|
|
|
|
|
uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
if (compact == 0) {
|
|
|
|
|
if (ima->source != IMA_SRC_GENERATED) {
|
|
|
|
|
if (image_has_alpha(ima, iuser)) {
|
|
|
|
|
uiLayout *sub = uiLayoutColumn(col, false);
|
|
|
|
|
uiItemR(sub, &imaptr, "alpha_mode", 0, IFACE_("Alpha"), ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
bool is_data = IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name);
|
|
|
|
|
uiLayoutSetActive(sub, !is_data);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiItemR(col, &imaptr, "use_view_as_render", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
UI_block_funcN_set(block, NULL, NULL, NULL);
|
2009-09-16 19:27:08 +00:00
|
|
|
}
|
2009-02-21 18:33:09 +00:00
|
|
|
|
2018-07-01 15:47:09 +02:00
|
|
|
void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, bool color_management)
|
2011-11-21 20:19:58 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImageFormatData *imf = imfptr->data;
|
|
|
|
|
ID *id = imfptr->id.data;
|
|
|
|
|
PointerRNA display_settings_ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
const int depth_ok = BKE_imtype_valid_depths(imf->imtype);
|
|
|
|
|
/* some settings depend on this being a scene that's rendered */
|
|
|
|
|
const bool is_render_out = (id && GS(id->name) == ID_SCE);
|
|
|
|
|
|
|
|
|
|
uiLayout *col;
|
|
|
|
|
bool show_preview = false;
|
|
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(col, true);
|
|
|
|
|
uiLayoutSetPropDecorate(col, false);
|
|
|
|
|
|
|
|
|
|
uiItemR(col, imfptr, "file_format", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(
|
|
|
|
|
uiLayoutRow(col, true), imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE);
|
|
|
|
|
|
|
|
|
|
/* only display depth setting if multiple depths can be used */
|
|
|
|
|
if ((ELEM(depth_ok,
|
|
|
|
|
R_IMF_CHAN_DEPTH_1,
|
|
|
|
|
R_IMF_CHAN_DEPTH_8,
|
|
|
|
|
R_IMF_CHAN_DEPTH_10,
|
|
|
|
|
R_IMF_CHAN_DEPTH_12,
|
|
|
|
|
R_IMF_CHAN_DEPTH_16,
|
|
|
|
|
R_IMF_CHAN_DEPTH_24,
|
|
|
|
|
R_IMF_CHAN_DEPTH_32)) == 0) {
|
|
|
|
|
uiItemR(uiLayoutRow(col, true), imfptr, "color_depth", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BKE_imtype_supports_quality(imf->imtype)) {
|
|
|
|
|
uiItemR(col, imfptr, "quality", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BKE_imtype_supports_compress(imf->imtype)) {
|
|
|
|
|
uiItemR(col, imfptr, "compression", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
|
|
|
|
|
uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BKE_imtype_supports_zbuf(imf->imtype)) {
|
|
|
|
|
uiItemR(col, imfptr, "use_zbuffer", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_render_out && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) {
|
|
|
|
|
show_preview = true;
|
|
|
|
|
uiItemR(col, imfptr, "use_preview", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (imf->imtype == R_IMF_IMTYPE_JP2) {
|
|
|
|
|
uiItemR(col, imfptr, "jpeg2k_codec", 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
|
|
uiItemR(col, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
|
|
uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (imf->imtype == R_IMF_IMTYPE_DPX) {
|
|
|
|
|
uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (imf->imtype == R_IMF_IMTYPE_CINEON) {
|
2011-11-21 20:19:58 +00:00
|
|
|
#if 1
|
2019-04-17 06:17:24 +02:00
|
|
|
uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma:1.7"), ICON_NONE);
|
2011-11-21 20:19:58 +00:00
|
|
|
#else
|
2019-04-17 06:17:24 +02:00
|
|
|
uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, imfptr, "cineon_white", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, imfptr, "cineon_gamma", 0, NULL, ICON_NONE);
|
2011-11-21 20:19:58 +00:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
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-04-17 06:17:24 +02:00
|
|
|
if (imf->imtype == R_IMF_IMTYPE_TIFF) {
|
|
|
|
|
uiItemR(col, imfptr, "tiff_codec", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
2016-01-14 15:02:13 +05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* color management */
|
|
|
|
|
if (color_management && (!BKE_imtype_requires_linear_float(imf->imtype) ||
|
|
|
|
|
(show_preview && imf->flag & R_IMF_FLAG_PREVIEW_JPG))) {
|
|
|
|
|
prop = RNA_struct_find_property(imfptr, "display_settings");
|
|
|
|
|
display_settings_ptr = RNA_property_pointer_get(imfptr, prop);
|
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-04-17 06:17:24 +02:00
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiItemL(col, IFACE_("Color Management"), ICON_NONE);
|
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-04-17 06:17:24 +02:00
|
|
|
uiItemR(col, &display_settings_ptr, "display_device", 0, NULL, ICON_NONE);
|
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-04-17 06:17:24 +02:00
|
|
|
uiTemplateColormanagedViewSettings(col, NULL, imfptr, "view_settings");
|
|
|
|
|
}
|
2011-11-21 20:19:58 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void uiTemplateImageStereo3d(uiLayout *layout, PointerRNA *stereo3d_format_ptr)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Stereo3dFormat *stereo3d_format = stereo3d_format_ptr->data;
|
|
|
|
|
uiLayout *col;
|
|
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiItemR(col, stereo3d_format_ptr, "display_mode", 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
|
|
switch (stereo3d_format->display_mode) {
|
|
|
|
|
case S3D_DISPLAY_ANAGLYPH: {
|
|
|
|
|
uiItemR(col, stereo3d_format_ptr, "anaglyph_type", 0, NULL, ICON_NONE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case S3D_DISPLAY_INTERLACE: {
|
|
|
|
|
uiItemR(col, stereo3d_format_ptr, "interlace_type", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, stereo3d_format_ptr, "use_interlace_swap", 0, NULL, ICON_NONE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case S3D_DISPLAY_SIDEBYSIDE: {
|
|
|
|
|
uiItemR(col, stereo3d_format_ptr, "use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
|
|
|
|
|
ATTR_FALLTHROUGH;
|
|
|
|
|
}
|
|
|
|
|
case S3D_DISPLAY_TOPBOTTOM: {
|
|
|
|
|
uiItemR(col, stereo3d_format_ptr, "use_squeezed_frame", 0, NULL, ICON_NONE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void uiTemplateViewsFormat(uiLayout *layout,
|
|
|
|
|
PointerRNA *ptr,
|
|
|
|
|
PointerRNA *stereo3d_format_ptr)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
uiLayout *col;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
uiLayoutSetPropSep(col, true);
|
|
|
|
|
uiLayoutSetPropDecorate(col, false);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
uiItemR(col, ptr, "views_format", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2018-09-03 17:23:48 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (stereo3d_format_ptr && RNA_enum_get(ptr, "views_format") == R_IMF_VIEWS_STEREO_3D) {
|
|
|
|
|
uiTemplateImageStereo3d(col, stereo3d_format_ptr);
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void uiTemplateImageViews(uiLayout *layout, PointerRNA *imaptr)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Image *ima = imaptr->data;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ima->type != IMA_TYPE_MULTILAYER) {
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
PointerRNA stereo3d_format_ptr;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
prop = RNA_struct_find_property(imaptr, "stereo_3d_format");
|
|
|
|
|
stereo3d_format_ptr = RNA_property_pointer_get(imaptr, prop);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
uiTemplateViewsFormat(layout, imaptr, &stereo3d_format_ptr);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
uiTemplateViewsFormat(layout, imaptr, NULL);
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA *ptr)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
ImageFormatData *imf = imfptr->data;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-05-23 12:29:55 +02:00
|
|
|
if (ptr != NULL) {
|
|
|
|
|
uiItemR(layout, ptr, "use_multiview", 0, NULL, ICON_NONE);
|
|
|
|
|
if (!RNA_boolean_get(ptr, "use_multiview")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-05-23 12:29:55 +02:00
|
|
|
if (imf->imtype != R_IMF_IMTYPE_MULTILAYER) {
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
PointerRNA stereo3d_format_ptr;
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-05-23 12:29:55 +02:00
|
|
|
prop = RNA_struct_find_property(imfptr, "stereo_3d_format");
|
|
|
|
|
stereo3d_format_ptr = RNA_property_pointer_get(imfptr, prop);
|
2015-04-08 00:28:03 +02:00
|
|
|
|
2019-05-23 12:29:55 +02:00
|
|
|
uiTemplateViewsFormat(layout, imfptr, &stereo3d_format_ptr);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
uiTemplateViewsFormat(layout, imfptr, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2009-06-23 00:45:41 +00:00
|
|
|
void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
|
|
|
|
|
/* render layers and passes */
|
|
|
|
|
if (ima && iuser) {
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
const float dpi_fac = UI_DPI_FAC;
|
|
|
|
|
const int menus_width = 160 * dpi_fac;
|
|
|
|
|
const bool is_render_result = (ima->type == IMA_TYPE_R_RESULT);
|
|
|
|
|
|
|
|
|
|
/* use BKE_image_acquire_renderresult so we get the correct slot in the menu */
|
|
|
|
|
rr = BKE_image_acquire_renderresult(scene, ima);
|
|
|
|
|
uiblock_layer_pass_buttons(
|
|
|
|
|
layout, ima, rr, iuser, menus_width, is_render_result ? &ima->render_slot : NULL);
|
|
|
|
|
BKE_image_release_renderresult(scene, ima);
|
|
|
|
|
}
|
2009-06-23 00:45:41 +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
|
|
|
|
2015-02-09 23:11:30 +01:00
|
|
|
void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *iuser)
|
|
|
|
|
{
|
2019-05-19 14:51:21 +02:00
|
|
|
if (ima == NULL || iuser == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Acquire image buffer. */
|
2019-04-17 06:17:24 +02:00
|
|
|
void *lock;
|
2019-05-19 14:51:21 +02:00
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock);
|
2015-02-09 23:11:30 +01:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
uiLayout *col = uiLayoutColumn(layout, true);
|
2019-05-20 17:30:37 +02:00
|
|
|
uiLayoutSetAlignment(col, UI_LAYOUT_ALIGN_RIGHT);
|
2019-05-19 14:51:21 +02:00
|
|
|
|
|
|
|
|
if (ibuf == NULL) {
|
|
|
|
|
uiItemL(col, IFACE_("Can't Load Image"), ICON_NONE);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-05-19 14:51:21 +02:00
|
|
|
else {
|
|
|
|
|
char str[MAX_IMAGE_INFO_LEN] = {0};
|
|
|
|
|
const int len = MAX_IMAGE_INFO_LEN;
|
|
|
|
|
int ofs = 0;
|
2015-02-09 23:11:30 +01:00
|
|
|
|
2019-05-19 14:51:21 +02:00
|
|
|
ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_("%d x %d, "), ibuf->x, ibuf->y);
|
|
|
|
|
|
|
|
|
|
if (ibuf->rect_float) {
|
|
|
|
|
if (ibuf->channels != 4) {
|
|
|
|
|
ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_("%d float channel(s)"), ibuf->channels);
|
|
|
|
|
}
|
|
|
|
|
else if (ibuf->planes == R_IMF_PLANES_RGBA) {
|
|
|
|
|
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA float"), len - ofs);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB float"), len - ofs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (ibuf->planes == R_IMF_PLANES_RGBA) {
|
|
|
|
|
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA byte"), len - ofs);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB byte"), len - ofs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ibuf->zbuf || ibuf->zbuf_float) {
|
|
|
|
|
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" + Z"), len - ofs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiItemL(col, str, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Frame number, even if we can't load the image. */
|
|
|
|
|
if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
|
|
|
|
|
/* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
const int framenr = BKE_image_user_frame_get(iuser, CFRA, NULL);
|
|
|
|
|
char str[MAX_IMAGE_INFO_LEN];
|
|
|
|
|
int duration = 0;
|
|
|
|
|
|
|
|
|
|
if (ima->source == IMA_SRC_MOVIE && BKE_image_has_anim(ima)) {
|
2019-05-20 13:43:25 +02:00
|
|
|
struct anim *anim = ((ImageAnim *)ima->anims.first)->anim;
|
|
|
|
|
if (anim) {
|
|
|
|
|
duration = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN);
|
|
|
|
|
}
|
2019-05-19 14:51:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (duration > 0) {
|
|
|
|
|
/* Movie duration */
|
|
|
|
|
BLI_snprintf(str, MAX_IMAGE_INFO_LEN, IFACE_("Frame %d / %d"), framenr, duration);
|
|
|
|
|
}
|
|
|
|
|
else if (ima->source == IMA_SRC_SEQUENCE && ibuf) {
|
|
|
|
|
/* Image sequence frame number + filename */
|
|
|
|
|
const char *filename = BLI_last_slash(ibuf->name);
|
|
|
|
|
filename = (filename == NULL) ? ibuf->name : filename + 1;
|
|
|
|
|
BLI_snprintf(str, MAX_IMAGE_INFO_LEN, IFACE_("Frame %d: %s"), framenr, filename);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Frame number */
|
|
|
|
|
BLI_snprintf(str, MAX_IMAGE_INFO_LEN, IFACE_("Frame %d"), framenr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiItemL(col, str, ICON_NONE);
|
|
|
|
|
}
|
2015-02-09 23:11:30 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_image_release_ibuf(ima, ibuf, lock);
|
2015-02-09 23:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#undef MAX_IMAGE_INFO_LEN
|
|
|
|
|
|
2019-02-06 11:49:41 +01:00
|
|
|
static bool metadata_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
|
2009-02-21 15:31:01 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
SpaceImage *space_image = CTX_wm_space_image(C);
|
|
|
|
|
return space_image != NULL && space_image->image != NULL;
|
2019-02-06 11:49:41 +01:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-02-06 11:49:41 +01:00
|
|
|
static void metadata_panel_context_draw(const bContext *C, Panel *panel)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
void *lock;
|
|
|
|
|
SpaceImage *space_image = CTX_wm_space_image(C);
|
|
|
|
|
Image *image = space_image->image;
|
|
|
|
|
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &space_image->iuser, &lock);
|
|
|
|
|
if (ibuf != NULL) {
|
|
|
|
|
ED_region_image_metadata_panel_draw(ibuf, panel->layout);
|
|
|
|
|
}
|
|
|
|
|
BKE_image_release_ibuf(image, ibuf, lock);
|
2019-02-06 11:49:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void image_buttons_register(ARegionType *art)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
PanelType *pt;
|
|
|
|
|
|
|
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel metadata");
|
|
|
|
|
strcpy(pt->idname, "IMAGE_PT_metadata");
|
|
|
|
|
strcpy(pt->label, N_("Metadata"));
|
2019-05-01 12:35:00 +10:00
|
|
|
strcpy(pt->category, "Image");
|
2019-04-17 06:17:24 +02:00
|
|
|
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2019-05-19 18:56:17 +02:00
|
|
|
pt->order = 10;
|
2019-04-17 06:17:24 +02:00
|
|
|
pt->poll = metadata_panel_context_poll;
|
|
|
|
|
pt->draw = metadata_panel_context_draw;
|
|
|
|
|
pt->flag |= PNL_DEFAULT_CLOSED;
|
|
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
2009-02-21 15:31:01 +00:00
|
|
|
}
|