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_graph
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_graph')
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c163
-rw-r--r--source/blender/editors/space_graph/graph_intern.h3
-rw-r--r--source/blender/editors/space_graph/space_graph.c23
3 files changed, 101 insertions, 88 deletions
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 16628f31b63..a4babaad74c 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -104,18 +104,49 @@ static void do_graph_region_buttons(bContext *C, void *arg, int event)
//WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
}
-static void graph_panel_properties(const bContext *C, ARegion *ar, short cntrl, bAnimListElem *ale)
+static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
{
- FCurve *fcu= (FCurve *)ale->data;
+ bAnimContext ac;
+ bAnimListElem *elem= NULL;
+
+ /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
+ * to work correctly is able to be correctly retrieved. There's no point showing empty panels?
+ */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return 0;
+
+ /* try to find 'active' F-Curve */
+ elem= get_active_fcurve_channel(&ac);
+ if(elem == NULL)
+ return 0;
+
+ if(fcu)
+ *fcu= (FCurve*)elem->data;
+ if(ale)
+ *ale= elem;
+ else
+ MEM_freeN(elem);
+
+ return 1;
+}
+
+static int graph_panel_poll(const bContext *C, PanelType *pt)
+{
+ return graph_panel_context(C, NULL, NULL);
+}
+
+static void graph_panel_properties(const bContext *C, Panel *pa)
+{
+ bAnimListElem *ale;
+ FCurve *fcu;
uiBlock *block;
char name[128];
- block= uiBeginBlock(C, ar, "graph_panel_properties", UI_EMBOSS);
- if (uiNewPanel(C, ar, block, "Properties", "Graph", 340, 30, 318, 254)==0) return;
- uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
+ if(!graph_panel_context(C, &ale, &fcu))
+ return;
- /* to force height */
- uiNewPanelHeight(block, 204);
+ block= uiLayoutFreeBlock(pa->layout);
+ uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
/* Info - Active F-Curve */
uiDefBut(block, LABEL, 1, "Active F-Curve:", 10, 200, 150, 19, NULL, 0.0, 0.0, 0, 0, "");
@@ -136,6 +167,8 @@ static void graph_panel_properties(const bContext *C, ARegion *ar, short cntrl,
* - Access details (ID-block + RNA-Path + Array Index)
* - ...
*/
+
+ MEM_freeN(ale);
}
/* ******************* drivers ******************************** */
@@ -206,11 +239,23 @@ static void driver_update_flags_cb (bContext *C, void *fcu_v, void *dummy_v)
driver->flag &= ~DRIVER_FLAG_INVALID;
}
+/* drivers panel poll */
+static int graph_panel_drivers_poll(const bContext *C, PanelType *pt)
+{
+ SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
+
+ if(sipo->mode != SIPO_MODE_DRIVERS)
+ return 0;
+
+ return graph_panel_context(C, NULL, NULL);
+}
-static void graph_panel_drivers(const bContext *C, ARegion *ar, short cntrl, bAnimListElem *ale)
+/* driver settings for active F-Curve (only for 'Drivers' mode) */
+static void graph_panel_drivers(const bContext *C, Panel *pa)
{
- FCurve *fcu= (FCurve *)ale->data;
- ChannelDriver *driver= fcu->driver;
+ bAnimListElem *ale;
+ FCurve *fcu;
+ ChannelDriver *driver;
DriverTarget *dtar;
PointerRNA rna_ptr;
@@ -218,12 +263,13 @@ static void graph_panel_drivers(const bContext *C, ARegion *ar, short cntrl, bAn
uiBut *but;
int yco=85, i=0;
- block= uiBeginBlock(C, ar, "graph_panel_drivers", UI_EMBOSS);
- if (uiNewPanel(C, ar, block, "Drivers", "Graph", 340, 30, 318, 254)==0) return;
- uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
+ if(!graph_panel_context(C, &ale, &fcu))
+ return;
- /* to force height */
- uiNewPanelHeight(block, 204);
+ driver= fcu->driver;
+
+ block= uiLayoutFreeBlock(pa->layout);
+ uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
/* general actions */
but= uiDefBut(block, BUT, B_IPO_DEPCHANGE, "Update Dependencies", 10, 200, 180, 22, NULL, 0.0, 0.0, 0, 0, "Force updates of dependencies");
@@ -296,12 +342,8 @@ static void graph_panel_drivers(const bContext *C, ARegion *ar, short cntrl, bAn
yco -= height;
i++;
}
-
- /* since these buttons can have variable height */
- if (yco < 0)
- uiNewPanelHeight(block, (204 - yco));
- else
- uiNewPanelHeight(block, 204);
+
+ MEM_freeN(ale);
}
/* ******************* f-modifiers ******************************** */
@@ -928,18 +970,19 @@ static void graph_panel_modifier_draw(uiBlock *block, FCurve *fcu, FModifier *fc
(*yco) -= (height + 27);
}
-static void graph_panel_modifiers(const bContext *C, ARegion *ar, short cntrl, bAnimListElem *ale)
+static void graph_panel_modifiers(const bContext *C, Panel *pa)
{
- FCurve *fcu= (FCurve *)ale->data;
+ bAnimListElem *ale;
+ FCurve *fcu;
FModifier *fcm;
uiBlock *block;
int yco= 190;
- block= uiBeginBlock(C, ar, "graph_panel_modifiers", UI_EMBOSS);
- if (uiNewPanel(C, ar, block, "Modifiers", "Graph", 340, 30, 318, 254)==0) return;
- uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL);
+ if(!graph_panel_context(C, &ale, &fcu))
+ return;
- uiNewPanelHeight(block, 204);
+ block= uiLayoutFreeBlock(pa->layout);
+ uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL);
/* 'add modifier' button at top of panel */
// XXX for now, this will be a operator button which calls a temporary 'add modifier' operator
@@ -948,12 +991,8 @@ static void graph_panel_modifiers(const bContext *C, ARegion *ar, short cntrl, b
/* draw each modifier */
for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next)
graph_panel_modifier_draw(block, fcu, fcm, &yco);
-
- /* since these buttons can have variable height */
- if (yco < 0)
- uiNewPanelHeight(block, (204 - yco));
- else
- uiNewPanelHeight(block, 204);
+
+ MEM_freeN(ale);
}
/* ******************* general ******************************** */
@@ -986,44 +1025,32 @@ bAnimListElem *get_active_fcurve_channel (bAnimContext *ac)
return NULL;
}
-void graph_region_buttons(const bContext *C, ARegion *ar)
+void graph_buttons_register(ARegionType *art)
{
- SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
- bAnimContext ac;
- bAnimListElem *ale= NULL;
-
- /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
- * to work correctly is able to be correctly retrieved. There's no point showing empty panels?
- */
- if (ANIM_animdata_get_context(C, &ac) == 0)
- return;
-
-
- /* try to find 'active' F-Curve */
- ale= get_active_fcurve_channel(&ac);
- if (ale == NULL)
- return;
-
- uiBeginPanels(C, ar);
-
- /* for now, the properties panel displays info about the selected channels */
- graph_panel_properties(C, ar, 0, ale);
-
- /* driver settings for active F-Curve (only for 'Drivers' mode) */
- if (sipo->mode == SIPO_MODE_DRIVERS)
- graph_panel_drivers(C, ar, 0, ale);
-
- /* modifiers */
- graph_panel_modifiers(C, ar, 0, ale);
-
-
- uiEndPanels(C, ar);
-
- /* free temp data */
- MEM_freeN(ale);
+ PanelType *pt;
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
+ strcpy(pt->idname, "GRAPH_PT_properties");
+ strcpy(pt->label, "Properties");
+ pt->draw= graph_panel_properties;
+ pt->poll= graph_panel_poll;
+ BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
+ strcpy(pt->idname, "GRAPH_PT_drivers");
+ strcpy(pt->label, "Drivers");
+ pt->draw= graph_panel_drivers;
+ pt->poll= graph_panel_drivers_poll;
+ BLI_addtail(&art->paneltypes, pt);
+
+ pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
+ strcpy(pt->idname, "GRAPH_PT_modifiers");
+ strcpy(pt->label, "Modifiers");
+ pt->draw= graph_panel_modifiers;
+ pt->poll= graph_panel_poll;
+ BLI_addtail(&art->paneltypes, pt);
}
-
static int graph_properties(bContext *C, wmOperator *op)
{
ScrArea *sa= CTX_wm_area(C);
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index a06cdddbec8..7ba636302a5 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -35,6 +35,7 @@ struct bAnimListElem;
struct SpaceIpo;
struct ScrArea;
struct ARegion;
+struct ARegionType;
struct View2DGrid;
/* internal exports only */
@@ -137,7 +138,7 @@ void GRAPHEDIT_OT_ghost_curves_clear(struct wmOperatorType *ot);
/* ***************************************** */
/* graph_buttons.c */
void GRAPHEDIT_OT_properties(struct wmOperatorType *ot);
-void graph_region_buttons(const struct bContext *C, struct ARegion *ar);
+void graph_buttons_register(struct ARegionType *art);
struct bAnimListElem *get_active_fcurve_channel(struct bAnimContext *ac);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 66ebc145621..74002f64187 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -346,34 +346,17 @@ static void graph_buttons_area_init(wmWindowManager *wm, ARegion *ar)
{
ListBase *keymap;
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST_UI, ar->winx, ar->winy);
+ 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, "GraphEdit Generic", SPACE_IPO, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void graph_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);
-
- graph_region_buttons(C, ar);
-
- /* restore view matrix? */
- UI_view2d_view_restore(C);
+ ED_region_panels(C, ar, 1, NULL);
}
-
static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
@@ -586,6 +569,8 @@ void ED_spacetype_ipo(void)
art->draw= graph_buttons_area_draw;
BLI_addhead(&st->regiontypes, art);
+
+ graph_buttons_register(art);
BKE_spacetype_register(st);
}