diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-05-08 05:38:30 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-05-08 15:53:52 +0300 |
commit | 81c302bbff48b391b7f62ef7db233e9c7bd2adb2 (patch) | |
tree | 373b7644c0ea4a4936090d5730b34927a26ab106 /source/blender | |
parent | 9dbe7bbe9a943ffd18fa670c4f68b4f90a6fc773 (diff) |
Action Editor: Initial support for a Properties Region
This commit adds some of the initial support for a properties region in the
Action Editor. There are currently no panels to display, as there is still
a lot of work required to port over the required internal architecture to
support the panels seen in the Graph Editor.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_action/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_buttons.c | 132 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_intern.h | 10 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_ops.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_action/space_action.c | 99 |
6 files changed, 293 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index f7d208a6a1b..efd167d49d5 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -137,6 +137,30 @@ static void do_version_constraints_stretch_to_limits(ListBase *lb) } } +static void do_version_action_editor_properties_region(ListBase *regionbase) +{ + ARegion *ar; + + for (ar = regionbase->first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_UI) { + /* already exists */ + return; + } + else if (ar->regiontype == RGN_TYPE_WINDOW) { + /* add new region here */ + ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action"); + + BLI_insertlinkbefore(regionbase, ar, arnew); + + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; + arnew->flag = RGN_FLAG_HIDDEN; + + return; + } + } +} + void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { if (!MAIN_VERSION_ATLEAST(main, 270, 0)) { @@ -1109,5 +1133,22 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) SEQ_END } + /* Adding "Properties" region to DopeSheet */ + for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + /* handle pushed-back space data first */ + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_ACTION) { + SpaceAction *saction = (SpaceAction *)sl; + do_version_action_editor_properties_region(&saction->regionbase); + } + } + + /* active spacedata info must be handled too... */ + if (sa->spacetype == SPACE_ACTION) { + do_version_action_editor_properties_region(&sa->regionbase); + } + } + } } } diff --git a/source/blender/editors/space_action/CMakeLists.txt b/source/blender/editors/space_action/CMakeLists.txt index 839071d1330..24c3ee9cd3d 100644 --- a/source/blender/editors/space_action/CMakeLists.txt +++ b/source/blender/editors/space_action/CMakeLists.txt @@ -36,6 +36,7 @@ set(INC_SYS ) set(SRC + action_buttons.c action_data.c action_draw.c action_edit.c diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c new file mode 100644 index 00000000000..a3112f1ad15 --- /dev/null +++ b/source/blender/editors/space_action/action_buttons.c @@ -0,0 +1,132 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2016 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation, Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/space_action/action_buttons.c + * \ingroup spaction + */ + + +#include <string.h> +#include <stdio.h> +#include <math.h> +#include <float.h> + +#include "DNA_anim_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "BLT_translation.h" + +#include "BKE_context.h" +#include "BKE_curve.h" +#include "BKE_depsgraph.h" +#include "BKE_fcurve.h" +#include "BKE_main.h" +#include "BKE_global.h" +#include "BKE_screen.h" +#include "BKE_unit.h" + + +#include "WM_api.h" +#include "WM_types.h" + +#include "RNA_access.h" + +#include "ED_anim_api.h" +#include "ED_keyframing.h" +#include "ED_screen.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "action_intern.h" // own include + +/* ******************* action editor space & buttons ************** */ + +/* ******************* general ******************************** */ + +void action_buttons_register(ARegionType *art) +{ +#if 0 + PanelType *pt; + + // TODO: AnimData / Actions List + + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties"); + strcpy(pt->idname, "ACTION_PT_properties"); + strcpy(pt->label, N_("Active F-Curve")); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + pt->draw = action_anim_panel_properties; + pt->poll = action_anim_panel_poll; + BLI_addtail(&art->paneltypes, pt); + + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties"); + strcpy(pt->idname, "ACTION_PT_key_properties"); + strcpy(pt->label, N_("Active Keyframe")); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + pt->draw = action_anim_panel_key_properties; + pt->poll = action_anim_panel_poll; + BLI_addtail(&art->paneltypes, pt); + + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel modifiers"); + strcpy(pt->idname, "ACTION_PT_modifiers"); + strcpy(pt->label, N_("Modifiers")); + strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + pt->draw = action_anim_panel_modifiers; + pt->poll = action_anim_panel_poll; + BLI_addtail(&art->paneltypes, pt); +#endif +} + +static int action_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) +{ + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = action_has_buttons_region(sa); + + if (ar) + ED_region_toggle_hidden(C, ar); + + return OPERATOR_FINISHED; +} + +void ACTION_OT_properties(wmOperatorType *ot) +{ + ot->name = "Properties"; + ot->idname = "ACTION_OT_properties"; + ot->description = "Toggle display properties panel"; + + ot->exec = action_properties_toggle_exec; + ot->poll = ED_operator_action_active; + + /* flags */ + ot->flag = 0; +} diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 17f1f404225..50e10e7e154 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -34,11 +34,21 @@ struct bContext; struct bAnimContext; struct SpaceAction; +struct ScrArea; struct ARegion; +struct ARegionType; struct wmOperatorType; /* internal exports only */ +/* **************************************** */ +/* space_action.c / action_buttons.c */ + +struct ARegion *action_has_buttons_region(struct ScrArea *sa); + +void action_buttons_register(struct ARegionType *art); +void ACTION_OT_properties(struct wmOperatorType *ot); + /* ***************************************** */ /* action_draw.c */ void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 59b147c6f6c..f69f9944f8a 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -51,6 +51,9 @@ void action_operatortypes(void) { + /* view */ + WM_operatortype_append(ACTION_OT_properties); + /* keyframes */ /* selection */ WM_operatortype_append(ACTION_OT_clickselect); @@ -257,6 +260,13 @@ void action_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; + /* keymap for all regions */ + keymap = WM_keymap_find(keyconf, "Dopesheet Generic", SPACE_ACTION, 0); + + /* region management... */ + WM_keymap_add_item(keymap, "ACTION_OT_properties", NKEY, KM_PRESS, 0, 0); + + /* channels */ /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 53c5a008af8..60240109432 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -59,6 +59,32 @@ #include "action_intern.h" /* own include */ +/* ******************** manage regions ********************* */ + +ARegion *action_has_buttons_region(ScrArea *sa) +{ + ARegion *ar, *arnew; + + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); + if (ar) return ar; + + /* add subdiv level; after main */ + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + + /* is error! */ + if (ar == NULL) return NULL; + + arnew = MEM_callocN(sizeof(ARegion), "buttons for action"); + + BLI_insertlinkafter(&sa->regionbase, ar, arnew); + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; + + arnew->flag = RGN_FLAG_HIDDEN; + + return arnew; +} + /* ******************** default callbacks for action space ***************** */ static SpaceLink *action_new(const bContext *C) @@ -93,6 +119,14 @@ static SpaceLink *action_new(const bContext *C) ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + /* ui buttons */ + ar = MEM_callocN(sizeof(ARegion), "buttons region for action"); + + BLI_addtail(&saction->regionbase, ar); + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; + ar->flag = RGN_FLAG_HIDDEN; + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for action"); @@ -159,6 +193,8 @@ static void action_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); } static void action_main_region_draw(const bContext *C, ARegion *ar) @@ -231,6 +267,9 @@ static void action_channel_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + + keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); } static void action_channel_region_draw(const bContext *C, ARegion *ar) @@ -498,6 +537,54 @@ static void action_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s } +/* add handlers, stuff you only do once or on area/region changes */ +static void action_buttons_area_init(wmWindowManager *wm, ARegion *ar) +{ + wmKeyMap *keymap; + + ED_region_panels_init(wm, ar); + + keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); +} + +static void action_buttons_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, NULL, -1, true); +} + +static void action_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch (wmn->category) { + case NC_ANIMATION: + ED_region_tag_redraw(ar); + break; + case NC_SCENE: + switch (wmn->data) { + case ND_OB_ACTIVE: + case ND_FRAME: + case ND_MARKERS: + ED_region_tag_redraw(ar); + break; + } + break; + case NC_OBJECT: + switch (wmn->data) { + case ND_BONE_ACTIVE: + case ND_BONE_SELECT: + case ND_KEYS: + ED_region_tag_redraw(ar); + break; + } + break; + default: + if (wmn->data == ND_KEYS) + ED_region_tag_redraw(ar); + break; + } +} + static void action_refresh(const bContext *C, ScrArea *sa) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; @@ -579,6 +666,18 @@ void ED_spacetype_action(void) BLI_addhead(&st->regiontypes, art); + /* regions: UI buttons */ + art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); + art->regionid = RGN_TYPE_UI; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI; + art->listener = action_region_listener; + art->init = action_buttons_area_init; + art->draw = action_buttons_area_draw; + + BLI_addhead(&st->regiontypes, art); + + action_buttons_register(art); BKE_spacetype_register(st); } |