diff options
author | Joshua Leung <aligorith@gmail.com> | 2018-06-21 07:57:59 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2018-06-21 07:58:14 +0300 |
commit | 876c73c9af223a807f97b463c32e8b6e190983e8 (patch) | |
tree | 49b7789f68de65084d575cc41c0feac97ec791e7 /source/blender/editors/space_graph | |
parent | 3777918e5c90ccb4469fe9f6282e0b4d7e53b859 (diff) |
Cleanup: Move logic for initialising a new Drivers editor into its own function
This shouldn't really be part of the windowmanager code. Pulling it out
now, so that we can reuse in RNA when switching display modes,
(and perhaps other places later)
Diffstat (limited to 'source/blender/editors/space_graph')
-rw-r--r-- | source/blender/editors/space_graph/graph_utils.c | 45 |
1 files changed, 45 insertions, 0 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). |