2.5: Added simple toolbox menu in image window as a test,
can uses same menus as header now since code doesn't depend on being in the header anymore.
This commit is contained in:
@@ -1117,3 +1117,38 @@ void image_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiDrawBlock(C, block);
|
||||
}
|
||||
|
||||
/********************** toolbox operator *********************/
|
||||
|
||||
static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
uiMenuItem *head;
|
||||
int show_uvedit;
|
||||
|
||||
show_uvedit= get_space_image_show_uvedit(sima, obedit);
|
||||
|
||||
head= uiPupMenuBegin("Toolbox");
|
||||
|
||||
uiMenuLevel(head, "View", image_viewmenu);
|
||||
if(show_uvedit) uiMenuLevel(head, "Select", image_selectmenu);
|
||||
uiMenuLevel(head, "Image", image_imagemenu);
|
||||
if(show_uvedit) uiMenuLevel(head, "UVs", image_uvsmenu);
|
||||
|
||||
uiPupMenuEnd(C, head);
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void IMAGE_OT_toolbox(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Toolbox";
|
||||
ot->idname= "IMAGE_OT_toolbox";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= toolbox_invoke;
|
||||
ot->poll= space_image_main_area_poll;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -57,10 +57,14 @@ int get_space_image_show_uvshadow(struct SpaceImage *sima, struct Object *obedit
|
||||
/* image_header.c */
|
||||
void image_header_buttons(const struct bContext *C, struct ARegion *ar);
|
||||
|
||||
void IMAGE_OT_toolbox(struct wmOperatorType *ot);
|
||||
|
||||
/* image_draw.c */
|
||||
void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene);
|
||||
|
||||
/* image_ops.c */
|
||||
int space_image_main_area_poll(struct bContext *C);
|
||||
|
||||
void IMAGE_OT_view_all(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_view_pan(struct wmOperatorType *ot);
|
||||
void IMAGE_OT_view_selected(struct wmOperatorType *ot);
|
||||
|
||||
@@ -144,7 +144,7 @@ static void sima_zoom_set_factor(SpaceImage *sima, ARegion *ar, float zoomfac)
|
||||
sima_zoom_set(sima, ar, sima->zoom*zoomfac);
|
||||
}
|
||||
|
||||
static int space_image_main_area_poll(bContext *C)
|
||||
int space_image_main_area_poll(bContext *C)
|
||||
{
|
||||
SpaceLink *slink= CTX_wm_space_data(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
|
||||
@@ -146,6 +146,8 @@ void image_operatortypes(void)
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_in);
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_out);
|
||||
WM_operatortype_append(IMAGE_OT_view_zoom_ratio);
|
||||
|
||||
WM_operatortype_append(IMAGE_OT_toolbox);
|
||||
}
|
||||
|
||||
void image_keymap(struct wmWindowManager *wm)
|
||||
@@ -169,6 +171,8 @@ void image_keymap(struct wmWindowManager *wm)
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "IMAGE_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
|
||||
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_toolbox", SPACEKEY, KM_PRESS, 0, 0);
|
||||
}
|
||||
|
||||
static void image_refresh(const bContext *C, ScrArea *sa)
|
||||
|
||||
Reference in New Issue
Block a user