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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-05-19 21:13:33 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-05-19 21:13:33 +0400
commit40ae17d2f6e2d5dbbe89321491572035c304872c (patch)
tree7f39fe42977a45878352e34d7bfdc1820ed980ff /source/blender/editors/space_image
parent861398542f8ba71dd4783886adda21544d939763 (diff)
UI
* Fix buttons jumping around when resizing and zoom. Part of this was adding a tiny a 0.001f offset in UI_view2d_view_ortho, otherwise the rounding is unpredictable (used to be 0.375f, but that was disabled). * Fix various issues with zooming, panning panels. V2D_LOCKOFS_X/Y is now taken into account in more places in the view2d code, to avoid zooming into the center or panning out of the view. * Remove "Free" align mode in buttons window (it's not really useful). * View3D/Graph/Image editors now use the same PanelType system as the buttons window, means some deprecated panel code could be removed. * Some small visual tweaks for panels. * View 2D Reset operator (Home key), to reset zoom and panning for panels. * Added argument to set number buttons as sliders (slider=True for itemR). * Ignore labels for button alignment (doesn't look right). * Fix some use of context.main in py scripts, should get data from active object instead. * Fix autotexspace -> auto_texspace in py script.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_buttons.c (renamed from source/blender/editors/space_image/image_panels.c)121
-rw-r--r--source/blender/editors/space_image/image_header.c14
-rw-r--r--source/blender/editors/space_image/image_intern.h3
-rw-r--r--source/blender/editors/space_image/space_image.c24
4 files changed, 81 insertions, 81 deletions
diff --git a/source/blender/editors/space_image/image_panels.c b/source/blender/editors/space_image/image_buttons.c
index 971f3a70a8a..35004a4bdef 100644
--- a/source/blender/editors/space_image/image_panels.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -383,15 +383,13 @@ static void image_editcursor_buts(const bContext *C, View2D *v2d, uiBlock *block
}
}
-static void image_panel_game_properties(const bContext *C, ARegion *ar)
+static void image_panel_game_properties(const bContext *C, Panel *pa)
{
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
uiBlock *block;
- block= uiBeginBlock(C, ar, "image_panel_game_properties", UI_EMBOSS);
- if(uiNewPanel(C, ar, block, "Real-time Properties", "Image", 10, 10, 318, 204)==0)
- return;
+ block= uiLayoutFreeBlock(pa->layout);
uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
if (ibuf) {
@@ -420,15 +418,14 @@ static void image_panel_game_properties(const bContext *C, ARegion *ar)
}
}
-static void image_panel_view_properties(const bContext *C, ARegion *ar)
+static void image_panel_view_properties(const bContext *C, Panel *pa)
{
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+ ARegion *ar= CTX_wm_region(C);
Object *obedit= CTX_data_edit_object(C);
uiBlock *block;
- block= uiBeginBlock(C, ar, "image_view_properties", UI_EMBOSS);
- if(uiNewPanel(C, ar, block, "View Properties", "Image", 10, 30, 318, 204)==0)
- return;
+ block= uiLayoutFreeBlock(pa->layout);
uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
uiDefButBitI(block, TOG, SI_DRAW_TILE, B_REDR, "Repeat Image", 10,160,140,19, &sima->flag, 0, 0, 0, 0, "Repeat/Tile the image display");
@@ -599,7 +596,14 @@ void brush_buttons(const bContext *C, uiBlock *block, short fromsima,
#endif
}
-static void image_panel_paintcolor(const bContext *C, ARegion *ar)
+static int image_panel_paint_poll(const bContext *C, PanelType *pt)
+{
+ SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
+
+ return (sima->image && (sima->flag & SI_DRAWTOOL));
+}
+
+static void image_panel_paintcolor(const bContext *C, Panel *pa)
{
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
ToolSettings *settings= CTX_data_tool_settings(C);
@@ -608,37 +612,26 @@ static void image_panel_paintcolor(const bContext *C, ARegion *ar)
static float hsv[3], old[3]; // used as temp mem for picker
static char hexcol[128];
- block= uiBeginBlock(C, ar, "image_panel_paintcolor", UI_EMBOSS);
- uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
- if(uiNewPanel(C, ar, block, "Paint Color", "Image", 10, 22, 318, 204)==0)
+ if(!sima->image || (sima->flag & SI_DRAWTOOL)==0)
return;
- if ( (brush && sima->image && (sima->flag & SI_DRAWTOOL))==0) {
- uiNewPanelHeight(block, 0);
- return;
- }
- uiNewPanelHeight(block, 204);
-
- uiBlockPickerButtons(block, brush->rgb, hsv, old, hexcol, 'f', B_REDR);
-}
-
+ block= uiLayoutFreeBlock(pa->layout);
+ uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
+ if(brush)
+ uiBlockPickerButtons(block, brush->rgb, hsv, old, hexcol, 'f', B_REDR);
+}
-static void image_panel_paint(const bContext *C, ARegion *ar)
+static void image_panel_paint(const bContext *C, Panel *pa)
{
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
uiBlock *block;
- block= uiBeginBlock(C, ar, "image_panel_paint", UI_EMBOSS);
- uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
- if(uiNewPanel(C, ar, block, "Image Paint", "Image", 10, 20, 318, 204)==0)
+ if(!sima->image || (sima->flag & SI_DRAWTOOL)==0)
return;
- if ((sima->image && (sima->flag & SI_DRAWTOOL))==0) {
- uiNewPanelHeight(block, 0);
- return;
- }
- uiNewPanelHeight(block, 204);
+ block= uiLayoutFreeBlock(pa->layout);
+ uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
brush_buttons(C, block, 1, B_SIMANOTHING, B_SIMABRUSHCHANGE, B_SIMABRUSHBROWSE, B_SIMABRUSHLOCAL, B_SIMABRUSHDELETE, B_KEEPDATA, B_SIMABTEXBROWSE, B_SIMABTEXDELETE);
}
@@ -663,7 +656,7 @@ static void image_panel_curves_reset(bContext *C, void *cumap_v, void *ibuf_v)
}
-static void image_panel_curves(const bContext *C, ARegion *ar)
+static void image_panel_curves(const bContext *C, Panel *pa)
{
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
ImBuf *ibuf;
@@ -673,9 +666,7 @@ static void image_panel_curves(const bContext *C, ARegion *ar)
/* and we check for spare */
ibuf= ED_space_image_buffer(sima);
- block= uiBeginBlock(C, ar, "image_panel_curves", UI_EMBOSS);
- if(uiNewPanel(C, ar, block, "Curves", "Image", 10, 40, 318, 204)==0)
- return;
+ block= uiLayoutFreeBlock(pa->layout);
uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
if (ibuf) {
@@ -1398,40 +1389,62 @@ void ED_image_uiblock_panel(const bContext *C, uiBlock *block, Image **ima_pp, I
}
-static void image_panel_properties(const bContext *C, ARegion *ar)
+static void image_panel_properties(const bContext *C, Panel *pa)
{
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
uiBlock *block;
- block= uiBeginBlock(C, ar, "image_panel_properties", UI_EMBOSS);
- if(uiNewPanel(C, ar, block, "Image Properties", "Image", 10, 50, 318, 204)==0)
- return;
+ block= uiLayoutFreeBlock(pa->layout);
uiBlockSetHandleFunc(block, do_image_panel_events, NULL);
/* note, it draws no bottom half in facemode, for vertex buttons */
ED_image_uiblock_panel(C, block, &sima->image, &sima->iuser, B_REDR, B_REDR);
image_editvertex_buts(C, block);
-
- uiEndBlock(C, block);
}
-
-
-void image_buttons_area_defbuts(const bContext *C, ARegion *ar)
+void image_buttons_register(ARegionType *art)
{
- uiBeginPanels(C, ar);
-
- image_panel_properties(C, ar);
- image_panel_game_properties(C, ar);
- image_panel_view_properties(C, ar);
- image_panel_paint(C, ar);
- image_panel_paintcolor(C, ar);
- image_panel_curves(C, ar);
-
- uiEndPanels(C, ar);
+ PanelType *pt;
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype image panel properties");
+ strcpy(pt->idname, "IMAGE_PT_properties");
+ strcpy(pt->label, "Image Properties");
+ pt->draw= image_panel_properties;
+ BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype image panel game properties");
+ strcpy(pt->idname, "IMAGE_PT_game_properties");
+ strcpy(pt->label, "Game Properties");
+ pt->draw= image_panel_game_properties;
+ BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype image view properties");
+ strcpy(pt->idname, "IMAGE_PT_view_properties");
+ strcpy(pt->label, "View Properties");
+ pt->draw= image_panel_view_properties;
+ BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype image panel paint");
+ strcpy(pt->idname, "IMAGE_PT_paint");
+ strcpy(pt->label, "Paint");
+ pt->draw= image_panel_paint;
+ pt->poll= image_panel_paint_poll;
+ BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype image panel paint color");
+ strcpy(pt->idname, "IMAGE_PT_paint_color");
+ strcpy(pt->label, "Paint Color");
+ pt->draw= image_panel_paintcolor;
+ pt->poll= image_panel_paint_poll;
+ BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype image panel curves");
+ strcpy(pt->idname, "IMAGE_PT_curves");
+ strcpy(pt->label, "Curves");
+ pt->draw= image_panel_curves;
+ BLI_addtail(&art->paneltypes, pt);
}
-
static int image_properties(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);
diff --git a/source/blender/editors/space_image/image_header.c b/source/blender/editors/space_image/image_header.c
index 7a28499009b..2accef990d3 100644
--- a/source/blender/editors/space_image/image_header.c
+++ b/source/blender/editors/space_image/image_header.c
@@ -150,8 +150,8 @@ static void image_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
uiItemS(layout);
- uiItemR(layout, NULL, 0, &spaceptr, "update_automatically", 0);
- // XXX if(show_uvedit) uiItemR(layout, NULL, 0, &uvptr, "local_view", 0); // "UV Local View", Numpad /
+ uiItemR(layout, NULL, 0, &spaceptr, "update_automatically", 0, 0);
+ // XXX if(show_uvedit) uiItemR(layout, NULL, 0, &uvptr, "local_view", 0, 0); // "UV Local View", Numpad /
uiItemS(layout);
@@ -234,7 +234,7 @@ static void image_imagemenu(bContext *C, uiLayout *layout, void *arg_unused)
uiItemS(layout);
- uiItemR(layout, NULL, 0, &spaceptr, "image_painting", 0);
+ uiItemR(layout, NULL, 0, &spaceptr, "image_painting", 0, 0);
/* move to realtime properties panel */
RNA_id_pointer_create(&ima->id, &imaptr);
@@ -338,12 +338,12 @@ static void image_uvsmenu(bContext *C, uiLayout *layout, void *arg_unused)
RNA_id_pointer_create(&scene->id, &sceneptr);
/* create menu */
- uiItemR(layout, NULL, 0, &uvptr, "snap_to_pixels", 0);
- uiItemR(layout, NULL, 0, &uvptr, "constrain_to_image_bounds", 0);
+ uiItemR(layout, NULL, 0, &uvptr, "snap_to_pixels", 0, 0);
+ uiItemR(layout, NULL, 0, &uvptr, "constrain_to_image_bounds", 0, 0);
uiItemS(layout);
- uiItemR(layout, NULL, 0, &uvptr, "live_unwrap", 0);
+ uiItemR(layout, NULL, 0, &uvptr, "live_unwrap", 0, 0);
uiItemO(layout, NULL, 0, "UV_OT_unwrap");
uiItemBooleanO(layout, "Unpin", 0, "UV_OT_pin", "clear", 1);
uiItemO(layout, NULL, 0, "UV_OT_pin");
@@ -363,7 +363,7 @@ static void image_uvsmenu(bContext *C, uiLayout *layout, void *arg_unused)
uiItemS(layout);
- uiItemR(layout, NULL, 0, &sceneptr, "proportional_editing", 0);
+ uiItemR(layout, NULL, 0, &sceneptr, "proportional_editing", 0, 0);
uiItemMenuEnumR(layout, NULL, 0, &sceneptr, "proportional_editing_falloff");
uiItemS(layout);
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index c592e2cb004..aa97e339c68 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -32,6 +32,7 @@
/* internal exports only */
struct bContext;
struct ARegion;
+struct ARegionType;
struct ScrArea;
struct SpaceImage;
struct Object;
@@ -84,7 +85,7 @@ void draw_uvedit_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene
/* image_panels.c */
struct ImageUser *ntree_get_active_iuser(struct bNodeTree *ntree);
-void image_buttons_area_defbuts(const struct bContext *C, struct ARegion *ar);
+void image_buttons_register(struct ARegionType *art);
void IMAGE_OT_properties(struct wmOperatorType *ot);
#endif /* ED_IMAGE_INTERN_H */
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 5f743afd65d..c82018a3aac 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -483,32 +483,16 @@ static void image_main_area_listener(ARegion *ar, wmNotifier *wmn)
static void image_buttons_area_init(wmWindowManager *wm, ARegion *ar)
{
ListBase *keymap;
+
+ ED_region_panels_init(wm, ar);
- keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0);
- WM_event_add_keymap_handler(&ar->handlers, 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_PANEL, 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);
+ ED_region_panels(C, ar, 1, NULL);
}
static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn)
@@ -590,6 +574,8 @@ void ED_spacetype_image(void)
art->draw= image_buttons_area_draw;
BLI_addhead(&st->regiontypes, art);
+ image_buttons_register(art);
+
/* regions: header */
art= MEM_callocN(sizeof(ARegionType), "spacetype image region");
art->regionid = RGN_TYPE_HEADER;