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:
authorJacques Lucke <mail@jlucke.com>2019-05-07 16:09:14 +0300
committerJacques Lucke <mail@jlucke.com>2019-05-07 16:09:14 +0300
commitf2b7582b27fa1235a013b2d92af72428c0fc1623 (patch)
tree6585abf521e82cc1933aa498fc6688970be9f5a8 /source/blender/editors/animation
parente4669199bf9c819d82072f7dd93ff7156e9e72aa (diff)
UI: Animation editor scrubbing area
The main reason for this change is to allow setting the active frame with the left mouse button, while still being able to select e.g. keyframes with the same mouse button. The solution is to introduce a new scrubbing region with a specialized keymap. There are a couple of related todos, that will be handled in separate commits. Those are listed in D4654. This solves T63193. Differential Revision: https://developer.blender.org/D4654 Reviewers: brecht, billreynish
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r--source/blender/editors/animation/CMakeLists.txt1
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c10
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c5
-rw-r--r--source/blender/editors/animation/anim_scrubbing.c197
4 files changed, 203 insertions, 10 deletions
diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt
index 978bd772b6f..098c871823e 100644
--- a/source/blender/editors/animation/CMakeLists.txt
+++ b/source/blender/editors/animation/CMakeLists.txt
@@ -44,6 +44,7 @@ set(SRC
anim_markers.c
anim_motion_paths.c
anim_ops.c
+ anim_scrubbing.c
drivers.c
fmodifier_ui.c
keyframes_draw.c
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 6d1ee08d5e9..00025112835 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -485,16 +485,10 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
{
if (name) {
- BLI_strncpy(name, IFACE_("Dope Sheet Summary"), ANIM_CHAN_NAME_SIZE);
+ BLI_strncpy(name, IFACE_("Summary"), ANIM_CHAN_NAME_SIZE);
}
}
-// FIXME: this is really a temp icon I think
-static int acf_summary_icon(bAnimListElem *UNUSED(ale))
-{
- return ICON_BORDERMOVE;
-}
-
/* check if some setting exists for this channel */
static bool acf_summary_setting_valid(bAnimContext *UNUSED(ac),
bAnimListElem *UNUSED(ale),
@@ -557,7 +551,7 @@ static bAnimChannelType ACF_SUMMARY = {
acf_summary_name, /* name */
NULL, /* name prop */
- acf_summary_icon, /* icon */
+ NULL, /* icon */
acf_summary_setting_valid, /* has setting */
acf_summary_setting_flag, /* flag for setting */
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index adc6ec3f6be..9e09fc485a6 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -55,6 +55,7 @@
#include "DEG_depsgraph_build.h"
#include "UI_view2d.h"
+#include "UI_interface.h"
#include "ED_anim_api.h"
#include "ED_armature.h"
@@ -2542,7 +2543,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
float ymax;
if (ac->datatype == ANIMCONT_NLA) {
- ymax = NLACHANNEL_FIRST_TOP(snla);
+ ymax = NLACHANNEL_FIRST_TOP(ac);
}
else {
ymax = ACHANNEL_FIRST_TOP(ac);
@@ -2735,7 +2736,7 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2])
UI_view2d_listview_view_to_cell(NLACHANNEL_NAMEWIDTH,
NLACHANNEL_STEP(snla),
0,
- NLACHANNEL_FIRST_TOP(snla),
+ NLACHANNEL_FIRST_TOP(ac),
x,
y,
NULL,
diff --git a/source/blender/editors/animation/anim_scrubbing.c b/source/blender/editors/animation/anim_scrubbing.c
new file mode 100644
index 00000000000..a22d1b494fc
--- /dev/null
+++ b/source/blender/editors/animation/anim_scrubbing.c
@@ -0,0 +1,197 @@
+/*
+ * 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) 2019 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edanimation
+ */
+
+#include "BKE_context.h"
+
+#include "GPU_immediate.h"
+#include "GPU_matrix.h"
+#include "GPU_state.h"
+
+#include "ED_scrubbing.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "UI_interface.h"
+#include "UI_interface_icons.h"
+#include "UI_view2d.h"
+#include "UI_resources.h"
+
+#include "DNA_scene_types.h"
+
+#include "BLI_rect.h"
+#include "BLI_math.h"
+#include "BLI_string.h"
+#include "BLI_timecode.h"
+
+#include "RNA_access.h"
+
+static void get_scrubbing_region_rect(const ARegion *ar, rcti *rect)
+{
+ rect->xmin = 0;
+ rect->xmax = ar->winx;
+ rect->ymax = ar->winy;
+ rect->ymin = rect->ymax - UI_SCRUBBING_MARGIN_Y;
+}
+
+static int get_centered_text_y(const rcti *rect)
+{
+ return BLI_rcti_cent_y(rect) - UI_DPI_FAC * 4;
+}
+
+static void draw_background(const rcti *rect)
+{
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+ immUniformThemeColor(TH_SCRUBBING_BACKGROUND);
+
+ GPU_blend(true);
+ GPU_blend_set_func_separate(
+ GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+
+ immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+
+ GPU_blend(false);
+
+ immUnbindProgram();
+}
+
+static void get_current_time_str(
+ const Scene *scene, bool display_seconds, int frame, uint max_len, char *r_str)
+{
+ if (display_seconds) {
+ BLI_timecode_string_from_time(r_str, max_len, 0, FRA2TIME(frame), FPS, U.timecode_style);
+ }
+ else {
+ BLI_snprintf(r_str, max_len, "%d", frame);
+ }
+}
+
+static void draw_current_frame(const Scene *scene,
+ bool display_seconds,
+ const View2D *v2d,
+ const rcti *scrubbing_region_rect,
+ int current_frame)
+{
+ const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+ const unsigned char color[] = {255, 255, 255, 255};
+ int frame_x = UI_view2d_view_to_region_x(v2d, current_frame);
+
+ char frame_str[64];
+ get_current_time_str(scene, display_seconds, current_frame, sizeof(frame_str), frame_str);
+ float text_width = UI_fontstyle_string_width(fstyle, frame_str);
+ float box_width = text_width + 10 * UI_DPI_FAC;
+ float box_padding = 3 * UI_DPI_FAC;
+
+ float bg_color[4];
+ UI_GetThemeColor4fv(TH_CFRAME, bg_color);
+ bg_color[3] = 8.0f;
+
+ UI_draw_roundbox_corner_set(UI_CNR_ALL);
+ UI_draw_roundbox_aa(true,
+ frame_x - box_width / 2,
+ scrubbing_region_rect->ymin + box_padding,
+ frame_x + box_width / 2,
+ scrubbing_region_rect->ymax - box_padding,
+ 5 * UI_DPI_FAC,
+ bg_color);
+
+ UI_fontstyle_draw_simple(fstyle,
+ frame_x - text_width / 2,
+ get_centered_text_y(scrubbing_region_rect),
+ frame_str,
+ color);
+}
+
+void ED_scrubbing_draw(const ARegion *ar,
+ const Scene *scene,
+ bool display_seconds,
+ bool discrete_frames)
+{
+ const View2D *v2d = &ar->v2d;
+
+ GPU_matrix_push_projection();
+ wmOrtho2_region_pixelspace(ar);
+
+ rcti scrubbing_region_rect;
+ get_scrubbing_region_rect(ar, &scrubbing_region_rect);
+
+ draw_background(&scrubbing_region_rect);
+
+ rcti numbers_rect = scrubbing_region_rect;
+ numbers_rect.ymin = get_centered_text_y(&scrubbing_region_rect) - 4 * UI_DPI_FAC;
+ if (discrete_frames) {
+ UI_view2d_draw_scale_x__discrete_frames_or_seconds(
+ ar, v2d, &numbers_rect, scene, display_seconds, TH_TEXT);
+ }
+ else {
+ UI_view2d_draw_scale_x__frames_or_seconds(
+ ar, v2d, &numbers_rect, scene, display_seconds, TH_TEXT);
+ }
+
+ draw_current_frame(scene, display_seconds, v2d, &scrubbing_region_rect, scene->r.cfra);
+
+ GPU_matrix_pop_projection();
+}
+
+void ED_channel_search_draw(const bContext *C, ARegion *ar, bDopeSheet *dopesheet)
+{
+ GPU_matrix_push_projection();
+ wmOrtho2_region_pixelspace(ar);
+
+ rcti rect;
+ rect.xmin = 0;
+ rect.xmax = ceilf(ar->sizex * UI_DPI_FAC);
+ rect.ymin = ar->sizey * UI_DPI_FAC - UI_SCRUBBING_MARGIN_Y;
+ rect.ymax = ceilf(ar->sizey * UI_DPI_FAC);
+
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformThemeColor(TH_BACK);
+ immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
+ immUnbindProgram();
+
+ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS);
+
+ PointerRNA ptr;
+ RNA_pointer_create(&CTX_wm_screen(C)->id, &RNA_DopeSheet, dopesheet, &ptr);
+ PropertyRNA *prop = RNA_struct_find_property(&ptr, "filter_text");
+
+ int padding = 2 * UI_DPI_FAC;
+ uiDefAutoButR(block,
+ &ptr,
+ prop,
+ -1,
+ "",
+ ICON_NONE,
+ rect.xmin + padding,
+ rect.ymin + padding,
+ BLI_rcti_size_x(&rect) - 2 * padding,
+ BLI_rcti_size_y(&rect) - 2 * padding);
+
+ UI_block_end(C, block);
+ UI_block_draw(C, block);
+
+ GPU_matrix_pop_projection();
+}