Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-08-30 17:32:08 +0400
committerJoshua Leung <aligorith@gmail.com>2009-08-30 17:32:08 +0400
commit7df39b5ea2bd8bfd0c5a2a08aa2c52d051aa5fd5 (patch)
tree8436bb3fe595e2235836aee4fdbad329a4bfe428 /source/blender/editors/space_image
parentd4d520c9a2312e1b03872f92b1e9be1150d167d5 (diff)
Grease Pencil: Basic Support for Image Editor Again
* Grease Pencil works again from Image Editor now. For now, the GPencil datablock is linked to the Image Editor space, but this can be changed if need be. * Made Grease Pencil hotkeys into a separate Grease Pencil keymap, which can get included automagically like for frames/ui/v2d/etc. by supplying ED_KEYMAP_GPENCIL as part of st->keymapflag * Temporarily restored the nasty hack to make View2D-aligned sketches in Image Editor to use OpenGL lines only. I still dunno why this doesn't work normally. (Probably related is that strokes are not visible when there's no image visible atm).
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_buttons.c7
-rw-r--r--source/blender/editors/space_image/image_draw.c39
-rw-r--r--source/blender/editors/space_image/image_intern.h1
-rw-r--r--source/blender/editors/space_image/space_image.c16
4 files changed, 40 insertions, 23 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index ac0a5c7f53a..2eb070e0e6d 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -67,6 +67,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "ED_gpencil.h"
#include "ED_image.h"
#include "ED_mesh.h"
#include "ED_space_api.h"
@@ -1438,6 +1439,12 @@ void image_buttons_register(ARegionType *art)
strcpy(pt->label, "Curves");
pt->draw= image_panel_curves;
BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
+ strcpy(pt->idname, "IMAGE_PT_gpencil");
+ strcpy(pt->label, "Grease Pencil");
+ pt->draw= gpencil_panel_standard;
+ BLI_addtail(&art->paneltypes, pt);
}
static int image_properties(bContext *C, wmOperator *op)
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 2f5fc805367..cf9bac1ebee 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -44,6 +44,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "BKE_context.h"
#include "BKE_colortools.h"
#include "BKE_global.h"
#include "BKE_image.h"
@@ -53,6 +54,7 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "ED_gpencil.h"
#include "ED_image.h"
#include "ED_screen.h"
@@ -525,22 +527,26 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce
/* draw uv edit */
/* draw grease pencil */
-
-static void draw_image_grease_pencil(SpaceImage *sima, ImBuf *ibuf)
+void draw_image_grease_pencil(bContext *C, short onlyv2d)
{
- /* XXX bring back */
- /* draw grease-pencil ('image' strokes) */
- if (sima->flag & SI_DISPGP)
- ; // XXX draw_gpencil_2dimage(sa, ibuf);
-
-#if 0
- mywinset(sa->win); /* restore scissor after gla call... */
- wmOrtho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375);
-#endif
-
- /* draw grease-pencil (screen strokes) */
- if (sima->flag & SI_DISPGP)
- ; // XXX draw_gpencil_2dview(sa, NULL);
+ /* draw in View2D space? */
+ if (onlyv2d) {
+ /* assume that UI_view2d_ortho(C) has been called... */
+ SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C);
+ ImBuf *ibuf= ED_space_image_buffer(sima);
+
+ /* draw grease-pencil ('image' strokes) */
+ //if (sima->flag & SI_DISPGP)
+ draw_gpencil_2dimage(C, ibuf);
+ }
+ else {
+ /* assume that UI_view2d_restore(C) has been called... */
+ SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C);
+
+ /* draw grease-pencil ('screen' strokes) */
+ //if (sima->flag & SI_DISPGP)
+ draw_gpencil_2dview(C, 0);
+ }
}
/* XXX becomes WM paint cursor */
@@ -689,9 +695,6 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
else
draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);
- /* grease pencil */
- draw_image_grease_pencil(sima, ibuf);
-
/* paint helpers */
draw_image_paint_helpers(sima, ar, scene, zoomx, zoomy);
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index aa97e339c68..a33475c1213 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -53,6 +53,7 @@ void IMAGE_OT_toolbox(struct wmOperatorType *ot);
/* image_draw.c */
void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
void draw_image_info(struct ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf);
+void draw_image_grease_pencil(struct bContext *C, short onlyv2d);
/* image_ops.c */
int space_image_main_area_poll(struct bContext *C);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 1506df89c45..bb647e68917 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -54,6 +54,7 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
+#include "ED_gpencil.h"
#include "ED_image.h"
#include "ED_mesh.h"
#include "ED_space_api.h"
@@ -430,16 +431,22 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
/* we set view2d from own zoom and offset each time */
image_main_area_set_view2d(sima, ar, scene);
-
+
/* we draw image in pixelspace */
draw_image_main(sima, ar, scene);
/* and uvs in 0.0-1.0 space */
UI_view2d_view_ortho(C, v2d);
- draw_uvedit_main(sima, ar, scene, obedit);
- ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST);
+ draw_uvedit_main(sima, ar, scene, obedit);
+ ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST);
+
+ /* Grease Pencil too (in addition to UV's) */
+ draw_image_grease_pencil((bContext *)C, 1);
UI_view2d_view_restore(C);
+ /* draw Grease Pencil - screen space only */
+ draw_image_grease_pencil((bContext *)C, 0);
+
/* scrollers? */
/*scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
UI_view2d_scrollers_draw(C, v2d, scrollers);
@@ -558,11 +565,10 @@ void ED_spacetype_image(void)
/* regions: main window */
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag= ED_KEYMAP_FRAMES;
+ art->keymapflag= ED_KEYMAP_FRAMES|ED_KEYMAP_GPENCIL;
art->init= image_main_area_init;
art->draw= image_main_area_draw;
art->listener= image_main_area_listener;
- art->keymapflag= 0;
BLI_addhead(&st->regiontypes, art);