diff options
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r-- | source/blender/editors/space_graph/graph_utils.c | 45 | ||||
-rw-r--r-- | source/blender/editors/space_graph/space_graph.c | 28 |
2 files changed, 70 insertions, 3 deletions
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index f55a5511e2d..e543111e662 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -44,17 +44,62 @@ #include "BKE_context.h" #include "BKE_fcurve.h" +#include "BKE_screen.h" #include "WM_api.h" #include "ED_anim_api.h" +#include "ED_screen.h" +#include "UI_interface.h" #include "graph_intern.h" // own include /* ************************************************************** */ +/* Set Up Drivers Editor */ + +/* Set up UI configuration for Drivers Editor */ +/* NOTE: Currently called from windowmanager (new drivers editor window) and RNA (mode switching) */ +void ED_drivers_editor_init(bContext *C, ScrArea *sa) +{ + SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; + + /* Set mode */ + sipo->mode = SIPO_MODE_DRIVERS; + + /* Show Properties Region (or else the settings can't be edited) */ + ARegion *ar_props = BKE_area_find_region_type(sa, RGN_TYPE_UI); + if (ar_props) { + UI_panel_category_active_set(ar_props, "Drivers"); + + ar_props->flag &= ~RGN_FLAG_HIDDEN; + /* XXX: Adjust width of this too? */ + + ED_region_visibility_change_update(C, ar_props); + } + else { + printf("%s: Couldn't find properties region for Drivers Editor - %p\n", __func__, sa); + } + + /* Adjust framing in graph region */ + /* TODO: Have a way of not resetting this every time? + * (e.g. So that switching back and forth between editors doesn't keep jumping?) + */ + ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + if (ar_main) { + /* XXX: Ideally we recenter based on the range instead... */ + ar_main->v2d.tot.xmin = -2.0f; + ar_main->v2d.tot.ymin = -2.0f; + ar_main->v2d.tot.xmax = 2.0f; + ar_main->v2d.tot.ymax = 2.0f; + + ar_main->v2d.cur = ar_main->v2d.tot; + } +} + +/* ************************************************************** */ /* Active F-Curve */ /* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change). diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 59d7d7500ae..7c3105843c5 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -60,6 +60,8 @@ #include "WM_message.h" #include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" #include "UI_resources.h" #include "UI_view2d.h" @@ -181,14 +183,14 @@ static void graph_free(SpaceLink *sl) /* spacetype; init callback */ -static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) +static void graph_init(struct wmWindowManager *wm, ScrArea *sa) { SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; /* init dopesheet data if non-existent (i.e. for old files) */ if (sipo->ads == NULL) { sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... + sipo->ads->source = (ID *)WM_window_get_active_scene(wm->winactive); } /* force immediate init of any invalid F-Curve colors */ @@ -799,6 +801,24 @@ static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID } } +static int graph_space_subtype_get(ScrArea *sa) +{ + SpaceIpo *sgraph = sa->spacedata.first; + return sgraph->mode; +} + +static void graph_space_subtype_set(ScrArea *sa, int value) +{ + SpaceIpo *sgraph = sa->spacedata.first; + sgraph->mode = value; +} + +static void graph_space_subtype_item_extend( + bContext *UNUSED(C), EnumPropertyItem **item, int *totitem) +{ + RNA_enum_items_add(item, totitem, rna_enum_space_graph_mode_items); +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_ipo(void) { @@ -817,6 +837,9 @@ void ED_spacetype_ipo(void) st->listener = graph_listener; st->refresh = graph_refresh; st->id_remap = graph_id_remap; + st->space_subtype_item_extend = graph_space_subtype_item_extend; + st->space_subtype_get = graph_space_subtype_get; + st->space_subtype_set = graph_space_subtype_set; /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); @@ -867,4 +890,3 @@ void ED_spacetype_ipo(void) BKE_spacetype_register(st); } - |