Use tabs for image editor.

For initial discussion see T38371

This commit organized panels for image editor to new tab categories dependent
on the image editor mode:

View Mode:
Tools - contains UV tools (currently only transform and UV Sculpting)
Scopes - contains scopes
Grease Pencil - contains Grease Pencil operators

Paint Mode:
Tools - contains brush options
Scopes - as above
Grease Pencil - as above

Mask Mode
Mask - contains mask tools
Scopes - as above
Grease Pencil - as above

Grease Pencil panel/tab now includes operators, not view options which have been
moved to the UI region on the right.
To make this work better, image editor toolbar now is of type TOOLS instead
of PREVIEW as was the case previously. A nice version patch makes sure all
works predictably, but opening newer files with older blender executables
could backfire.

This commit does not address which UV Tools will be included in the
Tools tab for the view mode, but does include some basic tools (transform)
and provides a class to inherit from to avoid conflicts with UV Sculpting.

Reviewers: brecht, dingto, sergey

Differential Revision: https://developer.blender.org/D315
This commit is contained in:
Antony Riakiotakis 2014-02-13 19:49:26 +02:00
parent 6b1a4fc66e
commit eb7485389b
9 changed files with 318 additions and 206 deletions

@ -43,6 +43,7 @@ _modules = [
"properties_material",
"properties_object",
"properties_paint_common",
"properties_grease_pencil_common",
"properties_particle",
"properties_physics_cloth",
"properties_physics_common",

@ -0,0 +1,43 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
class GreasePencilPanel():
# subclass must set
# bl_space_type = 'IMAGE_EDITOR'
# bl_region_type = 'TOOLS'
bl_label = "Grease Pencil"
@staticmethod
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
row = col.row(align=True)
row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
row = col.row(align=True)
row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
row = col.row(align=True)
row.prop(context.tool_settings, "use_grease_pencil_sessions")

@ -21,7 +21,7 @@
import bpy
from bpy.types import Panel, Header, Menu, UIList
from bpy.app.translations import pgettext_iface as iface_
from bl_ui.properties_grease_pencil_common import GreasePencilPanel
class CLIP_UL_tracking_objects(UIList):
def draw_item(self, context, layout, data, item, icon,
@ -1043,28 +1043,11 @@ class CLIP_PT_tools_mask(MASK_PT_tools, Panel):
# --- end mask ---
class CLIP_PT_tools_grease_pencil(Panel):
class CLIP_PT_tools_grease_pencil(GreasePencilPanel, Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Grease Pencil"
bl_category = "Grease Pencil"
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
row = col.row(align=True)
row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
row = col.row(align=True)
row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
row = col.row(align=True)
row.prop(context.tool_settings, "use_grease_pencil_sessions")
class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
bl_space_type = 'CLIP_EDITOR'

@ -24,17 +24,20 @@ from bl_ui.properties_paint_common import (
brush_texture_settings,
brush_mask_texture_settings,
)
from bl_ui.properties_grease_pencil_common import GreasePencilPanel
from bpy.app.translations import pgettext_iface as iface_
class ImagePaintPanel(UnifiedPaintPanel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
bl_region_type = 'TOOLS'
bl_category = "Tools"
class BrushButtonsPanel:
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
bl_region_type = 'TOOLS'
bl_category = "Tools"
@classmethod
def poll(cls, context):
@ -42,6 +45,15 @@ class BrushButtonsPanel:
toolsettings = context.tool_settings.image_paint
return sima.show_paint and toolsettings.brush
class UVToolsPanel:
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_category = "Tools"
@classmethod
def poll(cls, context):
sima = context.space_data
return sima.show_uvedit and not context.tool_settings.use_uv_sculpt
class IMAGE_MT_view(Menu):
bl_label = "View"
@ -466,6 +478,42 @@ class MASK_MT_editor_menus(Menu):
layout.menu("MASK_MT_mask")
# -----------------------------------------------------------------------------
# Mask (similar code in space_clip.py, keep in sync)
# note! - panel placement does _not_ fit well with image panels... need to fix
from bl_ui.properties_mask_common import (MASK_PT_mask,
MASK_PT_layers,
MASK_PT_spline,
MASK_PT_point,
MASK_PT_display,
MASK_PT_tools)
class IMAGE_PT_mask(MASK_PT_mask, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_mask_display(MASK_PT_display, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
class IMAGE_PT_image_properties(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
@ -494,7 +542,7 @@ class IMAGE_PT_game_properties(Panel):
def poll(cls, context):
sima = context.space_data
# display even when not in game mode because these settings effect the 3d view
return (sima and sima.image) # and (rd.engine == 'BLENDER_GAME')
return (sima and sima.image and not sima.show_maskedit) # and (rd.engine == 'BLENDER_GAME')
def draw(self, context):
layout = self.layout
@ -526,112 +574,6 @@ class IMAGE_PT_game_properties(Panel):
col.prop(ima, "mapping", expand=True)
class IMAGE_PT_view_histogram(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
bl_label = "Histogram"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
hist = sima.scopes.histogram
layout.template_histogram(sima.scopes, "histogram")
row = layout.row(align=True)
row.prop(hist, "mode", expand=True)
row.prop(hist, "show_line", text="")
class IMAGE_PT_view_waveform(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
bl_label = "Waveform"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
layout.template_waveform(sima, "scopes")
row = layout.split(percentage=0.75)
row.prop(sima.scopes, "waveform_alpha")
row.prop(sima.scopes, "waveform_mode", icon_only=True)
class IMAGE_PT_view_vectorscope(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
bl_label = "Vectorscope"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
layout.template_vectorscope(sima, "scopes")
layout.prop(sima.scopes, "vectorscope_alpha")
class IMAGE_PT_sample_line(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
bl_label = "Sample Line"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
hist = sima.sample_histogram
layout.operator("image.sample_line")
layout.template_histogram(sima, "sample_histogram")
row = layout.row(align=True)
row.prop(hist, "mode", expand=True)
row.prop(hist, "show_line", text="")
class IMAGE_PT_scope_sample(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
bl_label = "Scope Samples"
@classmethod
def poll(cls, context):
sima = context.space_data
return sima
def draw(self, context):
layout = self.layout
sima = context.space_data
row = layout.row()
row.prop(sima.scopes, "use_full_resolution")
sub = row.row()
sub.active = not sima.scopes.use_full_resolution
sub.prop(sima.scopes, "accuracy")
class IMAGE_PT_view_properties(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
@ -692,9 +634,26 @@ class IMAGE_PT_view_properties(Panel):
sub.row().prop(uvedit, "draw_stretch_type", expand=True)
class IMAGE_PT_tools_transform_uvs(Panel, UVToolsPanel):
bl_label = "Transform"
@classmethod
def poll(cls, context):
sima = context.space_data
return sima.show_uvedit and not context.tool_settings.use_uv_sculpt
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.operator("transform.translate")
col.operator("transform.rotate")
col.operator("transform.resize", text="Scale")
col.separator()
col.operator("transform.shear")
class IMAGE_PT_paint(Panel, ImagePaintPanel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
bl_label = "Paint"
@classmethod
@ -952,8 +911,9 @@ class IMAGE_PT_tools_brush_appearance(BrushButtonsPanel, Panel):
class IMAGE_UV_sculpt_curve(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
bl_region_type = 'TOOLS'
bl_label = "UV Sculpt Curve"
bl_category = "Tools"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
@ -982,7 +942,8 @@ class IMAGE_UV_sculpt_curve(Panel):
class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
bl_region_type = 'TOOLS'
bl_category = "Tools"
bl_label = "UV Sculpt"
@classmethod
@ -1018,48 +979,129 @@ class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
col.prop(toolsettings, "uv_relax_method")
# -----------------------------------------------------------------------------
# Mask (similar code in space_clip.py, keep in sync)
# note! - panel placement does _not_ fit well with image panels... need to fix
from bl_ui.properties_mask_common import (MASK_PT_mask,
MASK_PT_layers,
MASK_PT_spline,
MASK_PT_point,
MASK_PT_display,
MASK_PT_tools)
class IMAGE_PT_mask(MASK_PT_mask, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
class IMAGE_PT_mask_display(MASK_PT_display, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'PREVIEW'
class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI' # is 'TOOLS' in the clip editor
bl_region_type = 'TOOLS'
bl_category = 'Mask'
# --- end mask ---
class IMAGE_PT_view_histogram(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Histogram"
bl_category = "Scopes"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
hist = sima.scopes.histogram
layout.template_histogram(sima.scopes, "histogram")
row = layout.row(align=True)
row.prop(hist, "mode", expand=True)
row.prop(hist, "show_line", text="")
class IMAGE_PT_view_waveform(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Waveform"
bl_category = "Scopes"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
layout.template_waveform(sima, "scopes")
row = layout.split(percentage=0.75)
row.prop(sima.scopes, "waveform_alpha")
row.prop(sima.scopes, "waveform_mode", icon_only=True)
class IMAGE_PT_view_vectorscope(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Vectorscope"
bl_category = "Scopes"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
layout.template_vectorscope(sima, "scopes")
layout.prop(sima.scopes, "vectorscope_alpha")
class IMAGE_PT_sample_line(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Sample Line"
bl_category = "Scopes"
@classmethod
def poll(cls, context):
sima = context.space_data
return (sima and sima.image)
def draw(self, context):
layout = self.layout
sima = context.space_data
hist = sima.sample_histogram
layout.operator("image.sample_line")
layout.template_histogram(sima, "sample_histogram")
row = layout.row(align=True)
row.prop(hist, "mode", expand=True)
row.prop(hist, "show_line", text="")
class IMAGE_PT_scope_sample(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Scope Samples"
bl_category = "Scopes"
@classmethod
def poll(cls, context):
sima = context.space_data
return sima
def draw(self, context):
layout = self.layout
sima = context.space_data
row = layout.row()
row.prop(sima.scopes, "use_full_resolution")
sub = row.row()
sub.active = not sima.scopes.use_full_resolution
sub.prop(sima.scopes, "accuracy")
class IMAGE_PT_tools_grease_pencil(GreasePencilPanel, Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'TOOLS'
bl_category = "Grease Pencil"
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 269
#define BLENDER_SUBVERSION 10
#define BLENDER_SUBVERSION 11
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
#define BLENDER_MINSUBVERSION 0

@ -2672,6 +2672,41 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
if (!MAIN_VERSION_ATLEAST(main, 269, 11)) {
bScreen *sc;
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *space_link;
for (space_link = sa->spacedata.first; space_link; space_link = space_link->next) {
if (space_link->spacetype == SPACE_IMAGE) {
ARegion *ar;
ListBase *lb;
if (space_link == sa->spacedata.first) {
lb = &sa->regionbase;
}
else {
lb = &space_link->regionbase;
}
for (ar = lb->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_PREVIEW) {
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
}
else if (ar->regiontype == RGN_TYPE_UI) {
ar->alignment = RGN_ALIGN_RIGHT;
}
}
}
}
}
}
}
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "float", "profile")) {
Object *ob;

@ -948,6 +948,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser
void image_buttons_register(ARegionType *art)
{
PanelType *pt;
const char *category = "Grease Pencil";
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
strcpy(pt->idname, "IMAGE_PT_gpencil");
@ -955,6 +956,7 @@ void image_buttons_register(ARegionType *art)
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
BLI_strncpy(pt->category, category, BLI_strlen_utf8(category));
BLI_addtail(&art->paneltypes, pt);
}
@ -985,7 +987,7 @@ void IMAGE_OT_properties(wmOperatorType *ot)
static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = image_has_scope_region(sa);
ARegion *ar = image_has_tools_region(sa);
if (ar)
ED_region_toggle_hidden(C, ar);
@ -993,11 +995,11 @@ static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
void IMAGE_OT_scopes(wmOperatorType *ot)
void IMAGE_OT_toolshelf(wmOperatorType *ot)
{
ot->name = "Scopes";
ot->idname = "IMAGE_OT_scopes";
ot->description = "Toggle display scopes panel";
ot->name = "Tool Shelf";
ot->idname = "IMAGE_OT_toolshelf";
ot->description = "Toggles tool shelf display";
ot->exec = image_scopes_toggle_exec;
ot->poll = ED_operator_image_active;

@ -47,7 +47,7 @@ struct bNodeTree;
/* space_image.c */
struct ARegion *image_has_buttons_region(struct ScrArea *sa);
struct ARegion *image_has_scope_region(struct ScrArea *sa);
struct ARegion *image_has_tools_region(struct ScrArea *sa);
extern const char *image_context_dir[]; /* doc access */
@ -91,7 +91,7 @@ void IMAGE_OT_curves_point_set(struct wmOperatorType *ot);
struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree);
void image_buttons_register(struct ARegionType *art);
void IMAGE_OT_properties(struct wmOperatorType *ot);
void IMAGE_OT_scopes(struct wmOperatorType *ot);
void IMAGE_OT_toolshelf(struct wmOperatorType *ot);
#endif /* __IMAGE_INTERN_H__ */

@ -69,6 +69,7 @@
#include "WM_types.h"
#include "UI_resources.h"
#include "UI_interface.h"
#include "UI_view2d.h"
#include "image_intern.h"
@ -82,7 +83,7 @@ static void image_scopes_tag_refresh(ScrArea *sa)
/* only while histogram is visible */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_PREVIEW && ar->flag & RGN_FLAG_HIDDEN)
if (ar->regiontype == RGN_TYPE_TOOLS && ar->flag & RGN_FLAG_HIDDEN)
return;
}
@ -116,11 +117,11 @@ ARegion *image_has_buttons_region(ScrArea *sa)
return arnew;
}
ARegion *image_has_scope_region(ScrArea *sa)
ARegion *image_has_tools_region(ScrArea *sa)
{
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
if (ar) return ar;
/* add subdiv level; after buttons */
@ -132,7 +133,7 @@ ARegion *image_has_scope_region(ScrArea *sa)
arnew = MEM_callocN(sizeof(ARegion), "scopes for image");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
arnew->regiontype = RGN_TYPE_PREVIEW;
arnew->regiontype = RGN_TYPE_TOOLS;
arnew->alignment = RGN_ALIGN_LEFT;
arnew->flag = RGN_FLAG_HIDDEN;
@ -177,11 +178,11 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
ar->alignment = RGN_ALIGN_RIGHT;
ar->flag = RGN_FLAG_HIDDEN;
/* scopes */
/* scopes/uv sculpt/paint */
ar = MEM_callocN(sizeof(ARegion), "buttons for image");
BLI_addtail(&simage->regionbase, ar);
ar->regiontype = RGN_TYPE_PREVIEW;
ar->regiontype = RGN_TYPE_TOOLS;
ar->alignment = RGN_ALIGN_LEFT;
ar->flag = RGN_FLAG_HIDDEN;
@ -255,7 +256,7 @@ static void image_operatortypes(void)
WM_operatortype_append(IMAGE_OT_curves_point_set);
WM_operatortype_append(IMAGE_OT_properties);
WM_operatortype_append(IMAGE_OT_scopes);
WM_operatortype_append(IMAGE_OT_toolshelf);
}
static void image_keymap(struct wmKeyConfig *keyconf)
@ -270,7 +271,7 @@ static void image_keymap(struct wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_scopes", TKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_toolshelf", TKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, KM_ALT, 0)->ptr, "reverse", TRUE);
@ -808,7 +809,7 @@ static void image_buttons_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa)
/* *********************** scopes region ************************ */
/* add handlers, stuff you only do once or on area/region changes */
static void image_scope_area_init(wmWindowManager *wm, ARegion *ar)
static void image_tools_area_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;
@ -819,28 +820,33 @@ static void image_scope_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
static void image_scope_area_draw(const bContext *C, ARegion *ar)
static void image_tools_area_draw(const bContext *C, ARegion *ar)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
/* XXX performance regression if name of scopes category changes! */
PanelCategoryStack *category = UI_panel_category_active_find(ar, "Scopes");
if (ibuf) {
if (!sima->scopes.ok) {
BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
/* 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);
}
if (sima->image->flag & IMA_VIEW_AS_RENDER)
scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
else
scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings);
}
if (sima->image->flag & IMA_VIEW_AS_RENDER)
scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
else
scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings);
}
ED_space_image_release_buffer(sima, ibuf, lock);
ED_region_panels(C, ar, 1, NULL, -1);
}
static void image_scope_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
static void image_tools_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
{
/* context changes */
switch (wmn->category) {
@ -942,17 +948,17 @@ void ED_spacetype_image(void)
art->draw = image_buttons_area_draw;
BLI_addhead(&st->regiontypes, art);
image_buttons_register(art);
ED_uvedit_buttons_register(art);
image_buttons_register(art);
/* regions: statistics/scope buttons */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_PREVIEW;
art->regionid = RGN_TYPE_TOOLS;
art->prefsizex = 220; // XXX
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
art->listener = image_scope_area_listener;
art->init = image_scope_area_init;
art->draw = image_scope_area_draw;
art->listener = image_tools_area_listener;
art->init = image_tools_area_init;
art->draw = image_tools_area_draw;
BLI_addhead(&st->regiontypes, art);
/* regions: header */