2.5
Support for listview/buttons region in ImageWindow. Now all code is in this commit :)
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
/* internal exports only */
|
||||
struct bContext;
|
||||
struct ARegion;
|
||||
struct ScrArea;
|
||||
struct SpaceImage;
|
||||
struct Object;
|
||||
struct Image;
|
||||
@@ -39,6 +40,9 @@ struct ImBuf;
|
||||
struct wmOperatorType;
|
||||
struct Scene;
|
||||
|
||||
/* space_image.c */
|
||||
struct ARegion *image_has_buttons_region(struct ScrArea *sa);
|
||||
|
||||
/* image_header.c */
|
||||
void image_header_buttons(const struct bContext *C, struct ARegion *ar);
|
||||
|
||||
@@ -77,5 +81,9 @@ void IMAGE_OT_record_composite(struct wmOperatorType *ot);
|
||||
/* uvedit_draw.c */
|
||||
void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene, struct Object *obedit);
|
||||
|
||||
/* image_panels.c */
|
||||
void image_buttons_area_defbuts(const struct bContext *C, struct ARegion *ar);
|
||||
void IMAGE_OT_properties(struct wmOperatorType *ot);
|
||||
|
||||
#endif /* ED_IMAGE_INTERN_H */
|
||||
|
||||
|
||||
@@ -25,6 +25,55 @@
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_editVert.h"
|
||||
#include "BLI_rand.h"
|
||||
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "ED_image.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_space_api.h"
|
||||
#include "ED_screen.h"
|
||||
#include "ED_uvedit.h"
|
||||
|
||||
#include "BIF_gl.h"
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "image_intern.h"
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/* ************ panel stuff ************* */
|
||||
@@ -237,21 +286,6 @@ void image_info(Image *ima, ImBuf *ibuf, char *str)
|
||||
|
||||
}
|
||||
|
||||
static void image_panel_properties(short cntrl) // IMAGE_HANDLER_PROPERTIES
|
||||
{
|
||||
uiBlock *block;
|
||||
|
||||
block= uiNewBlock(&curarea->uiblocks, "image_panel_properties", UI_EMBOSS, UI_HELV, curarea->win);
|
||||
uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
|
||||
uiSetPanelHandler(IMAGE_HANDLER_PROPERTIES); // for close and esc
|
||||
if(uiNewPanel(curarea, block, "Image Properties", "Image", 10, 10, 318, 204)==0)
|
||||
return;
|
||||
|
||||
/* note, it draws no bottom half in facemode, for vertex buttons */
|
||||
uiblock_image_panel(block, &G.sima->image, &G.sima->iuser, B_REDR, B_REDR);
|
||||
image_editvertex_buts(block);
|
||||
}
|
||||
|
||||
static void image_panel_game_properties(short cntrl) // IMAGE_HANDLER_GAME_PROPERTIES
|
||||
{
|
||||
ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
|
||||
@@ -629,3 +663,60 @@ static void image_blockhandlers(ScrArea *sa)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void image_panel_properties(const bContext *C, ARegion *ar)
|
||||
{
|
||||
uiBlock *block;
|
||||
|
||||
block= uiBeginBlock(C, ar, "image_panel_properties", UI_EMBOSS, UI_HELV);
|
||||
if(uiNewPanel(C, ar, block, "Image Properties", "Image", 10, 10, 318, 204)==0)
|
||||
return;
|
||||
|
||||
/* note, it draws no bottom half in facemode, for vertex buttons */
|
||||
// uiblock_image_panel(block, &G.sima->image, &G.sima->iuser, B_REDR, B_REDR);
|
||||
// image_editvertex_buts(block);
|
||||
|
||||
uiEndBlock(C, block);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void image_buttons_area_defbuts(const bContext *C, ARegion *ar)
|
||||
{
|
||||
|
||||
image_panel_properties(C, ar);
|
||||
|
||||
uiDrawPanels(C, 1); /* 1 = align */
|
||||
uiMatchPanelsView2d(ar); /* sets v2d->totrct */
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int image_properties(bContext *C, wmOperator *op)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= image_has_buttons_region(sa);
|
||||
|
||||
if(ar) {
|
||||
ar->flag ^= RGN_FLAG_HIDDEN;
|
||||
ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */
|
||||
|
||||
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void IMAGE_OT_properties(wmOperatorType *ot)
|
||||
{
|
||||
ot->name= "Properties";
|
||||
ot->idname= "IMAGE_OT_properties";
|
||||
|
||||
ot->exec= image_properties;
|
||||
ot->poll= ED_operator_image_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag= 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -73,6 +73,35 @@
|
||||
|
||||
#include "image_intern.h"
|
||||
|
||||
/* ******************** manage regions ********************* */
|
||||
|
||||
ARegion *image_has_buttons_region(ScrArea *sa)
|
||||
{
|
||||
ARegion *ar, *arnew;
|
||||
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if(ar->regiontype==RGN_TYPE_UI)
|
||||
return ar;
|
||||
|
||||
/* add subdiv level; after header */
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if(ar->regiontype==RGN_TYPE_HEADER)
|
||||
break;
|
||||
|
||||
/* is error! */
|
||||
if(ar==NULL) return NULL;
|
||||
|
||||
arnew= MEM_callocN(sizeof(ARegion), "buttons for image");
|
||||
|
||||
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
|
||||
arnew->regiontype= RGN_TYPE_UI;
|
||||
arnew->alignment= RGN_ALIGN_LEFT;
|
||||
|
||||
arnew->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
return arnew;
|
||||
}
|
||||
|
||||
/* ******************** default callbacks for image space ***************** */
|
||||
|
||||
static SpaceLink *image_new(const bContext *C)
|
||||
@@ -95,6 +124,14 @@ static SpaceLink *image_new(const bContext *C)
|
||||
ar->regiontype= RGN_TYPE_HEADER;
|
||||
ar->alignment= RGN_ALIGN_BOTTOM;
|
||||
|
||||
/* buttons/list view */
|
||||
ar= MEM_callocN(sizeof(ARegion), "buttons for image");
|
||||
|
||||
BLI_addtail(&simage->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_UI;
|
||||
ar->alignment= RGN_ALIGN_LEFT;
|
||||
ar->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
/* main area */
|
||||
ar= MEM_callocN(sizeof(ARegion), "main area for image");
|
||||
|
||||
@@ -160,11 +197,20 @@ void image_operatortypes(void)
|
||||
WM_operatortype_append(IMAGE_OT_record_composite);
|
||||
|
||||
WM_operatortype_append(IMAGE_OT_toolbox);
|
||||
WM_operatortype_append(IMAGE_OT_properties);
|
||||
}
|
||||
|
||||
void image_keymap(struct wmWindowManager *wm)
|
||||
{
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "Image", SPACE_IMAGE, 0);
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "Image Generic", SPACE_IMAGE, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0);
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "Image", SPACE_IMAGE, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
|
||||
@@ -184,11 +230,6 @@ void image_keymap(struct wmWindowManager *wm)
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
|
||||
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "PAINT_OT_image_paint", ACTIONMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", SELECTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", SELECTMOUSE, KM_PRESS, 0, 0);
|
||||
@@ -362,7 +403,9 @@ static void image_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
keymap= WM_keymap_listbase(wm, "ImagePaint", SPACE_IMAGE, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
|
||||
/* own keymap */
|
||||
/* own keymaps */
|
||||
keymap= WM_keymap_listbase(wm, "Image Generic", SPACE_IMAGE, 0);
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
keymap= WM_keymap_listbase(wm, "Image", SPACE_IMAGE, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
}
|
||||
@@ -433,6 +476,46 @@ static void image_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
}
|
||||
}
|
||||
|
||||
/* *********************** buttons region ************************ */
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void image_buttons_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
{
|
||||
ListBase *keymap;
|
||||
|
||||
keymap= WM_keymap_listbase(wm, "Image Generic", SPACE_IMAGE, 0);
|
||||
WM_event_add_keymap_handler(&ar->handlers, keymap);
|
||||
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST_UI, ar->winx, ar->winy);
|
||||
}
|
||||
|
||||
static void image_buttons_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
float col[3];
|
||||
|
||||
/* clear */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
|
||||
glClearColor(col[0], col[1], col[2], 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* set view2d view matrix for scrolling (without scrollers) */
|
||||
UI_view2d_view_ortho(C, &ar->v2d);
|
||||
|
||||
image_buttons_area_defbuts(C, ar);
|
||||
|
||||
/* restore view matrix? */
|
||||
UI_view2d_view_restore(C);
|
||||
}
|
||||
|
||||
static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/************************* header region **************************/
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
@@ -494,12 +577,21 @@ void ED_spacetype_image(void)
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: listview/buttons */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
||||
art->regionid = RGN_TYPE_UI;
|
||||
art->minsizex= 220; // XXX
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES;
|
||||
art->listener= image_buttons_area_listener;
|
||||
art->init= image_buttons_area_init;
|
||||
art->draw= image_buttons_area_draw;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: header */
|
||||
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->minsizey= HEADERY;
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
|
||||
|
||||
art->init= image_header_area_init;
|
||||
art->draw= image_header_area_draw;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user