forked from bartvdbraak/blender
UI: split UV editor out of the image space
This commit is contained in:
parent
d59c4c9d61
commit
5c8f1053b5
@ -523,7 +523,8 @@ class IMAGE_HT_header(Header):
|
||||
row = layout.row(align=True)
|
||||
row.template_header()
|
||||
|
||||
layout.prop(sima, "mode", text="")
|
||||
if sima.mode != 'UV':
|
||||
layout.prop(sima, "ui_mode", text="")
|
||||
|
||||
# UV editing.
|
||||
if show_uvedit:
|
||||
|
@ -53,6 +53,10 @@
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_workspace.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "IMB_imbuf_types.h"
|
||||
@ -69,8 +73,6 @@
|
||||
|
||||
#include "BIF_gl.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
#include "WM_message.h"
|
||||
@ -954,6 +956,37 @@ static void image_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \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.
|
||||
*/
|
||||
static int image_space_subtype_get(ScrArea *sa)
|
||||
{
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
return sima->mode == SI_MODE_UV ? SI_MODE_UV : SI_MODE_VIEW;
|
||||
}
|
||||
|
||||
static void image_space_subtype_set(ScrArea *sa, int value)
|
||||
{
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
static void image_space_subtype_item_extend(
|
||||
bContext *UNUSED(C), EnumPropertyItem **item, int *totitem)
|
||||
{
|
||||
RNA_enum_items_add(item, totitem, rna_enum_space_image_mode_items);
|
||||
}
|
||||
|
||||
/**************************** spacetype *****************************/
|
||||
|
||||
/* only called once, from space/spacetypes.c */
|
||||
@ -977,6 +1010,9 @@ void ED_spacetype_image(void)
|
||||
st->context = image_context;
|
||||
st->gizmos = image_widgets;
|
||||
st->id_remap = image_id_remap;
|
||||
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;
|
||||
|
||||
/* regions: main window */
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
||||
|
@ -909,8 +909,11 @@ typedef struct SpaceImage {
|
||||
float centx, centy; /* storage for offset while render drawing */
|
||||
|
||||
char mode; /* view/paint/mask */
|
||||
/* Storage for sub-space types. */
|
||||
char mode_prev;
|
||||
|
||||
char pin;
|
||||
short pad;
|
||||
char _pad;
|
||||
short curtile; /* the currently active tile of the image when tile is enabled, is kept in sync with the active faces tile */
|
||||
short lock;
|
||||
char dt_uv; /* UV draw type */
|
||||
|
@ -167,14 +167,42 @@ const EnumPropertyItem rna_enum_space_action_mode_items[] = {
|
||||
#undef SACT_ITEM_MASK
|
||||
#undef SACT_ITEM_CACHEFILE
|
||||
|
||||
const EnumPropertyItem rna_enum_space_image_mode_items[] = {
|
||||
{SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image"},
|
||||
{SI_MODE_UV, "UV", ICON_GROUP_UVS, "UV Edit", "UV edit in mesh editmode"},
|
||||
{SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"},
|
||||
{SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"},
|
||||
|
||||
#define SI_ITEM_VIEW(name, icon) \
|
||||
{SI_MODE_VIEW, "VIEW", icon, name, "View the image"}
|
||||
#define SI_ITEM_UV \
|
||||
{SI_MODE_UV, "UV", ICON_GROUP_UVS, "UV Edit", "UV edit in mesh editmode"}
|
||||
#define SI_ITEM_PAINT \
|
||||
{SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"}
|
||||
#define SI_ITEM_MASK \
|
||||
{SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"}
|
||||
|
||||
static const EnumPropertyItem rna_enum_space_image_mode_all_items[] = {
|
||||
SI_ITEM_VIEW("View", ICON_FILE_IMAGE),
|
||||
SI_ITEM_UV,
|
||||
SI_ITEM_PAINT,
|
||||
SI_ITEM_MASK,
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static const EnumPropertyItem rna_enum_space_image_mode_ui_items[] = {
|
||||
SI_ITEM_VIEW("View", ICON_FILE_IMAGE),
|
||||
SI_ITEM_PAINT,
|
||||
SI_ITEM_MASK,
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
const EnumPropertyItem rna_enum_space_image_mode_items[] = {
|
||||
SI_ITEM_VIEW("Image Editor", ICON_IMAGE),
|
||||
SI_ITEM_UV,
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
#undef SI_ITEM_VIEW
|
||||
#undef SI_ITEM_UV
|
||||
#undef SI_ITEM_PAINT
|
||||
#undef SI_ITEM_MASK
|
||||
|
||||
#define V3D_S3D_CAMERA_LEFT {STEREO_LEFT_ID, "LEFT", ICON_RESTRICT_RENDER_OFF, "Left", ""},
|
||||
#define V3D_S3D_CAMERA_RIGHT {STEREO_RIGHT_ID, "RIGHT", ICON_RESTRICT_RENDER_OFF, "Right", ""},
|
||||
#define V3D_S3D_CAMERA_S3D {STEREO_3D_ID, "S3D", ICON_CAMERA_STEREO, "3D", ""},
|
||||
@ -3539,10 +3567,16 @@ static void rna_def_space_image(BlenderRNA *brna)
|
||||
RNA_def_property_pointer_funcs(prop, "rna_SpaceImageEditor_uvedit_get", NULL, NULL, NULL);
|
||||
RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings");
|
||||
|
||||
/* mode */
|
||||
/* mode (hidden in the UI, see 'ui_mode') */
|
||||
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "mode");
|
||||
RNA_def_property_enum_items(prop, rna_enum_space_image_mode_items);
|
||||
RNA_def_property_enum_items(prop, rna_enum_space_image_mode_all_items);
|
||||
RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mode_update");
|
||||
|
||||
prop = RNA_def_property(srna, "ui_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "mode");
|
||||
RNA_def_property_enum_items(prop, rna_enum_space_image_mode_ui_items);
|
||||
RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mode_update");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user