[Bf-blender-cvs] [16d8583c848] temp-vse-channels-edge-panning: Make channels UI scaleable, so it is always visible.
Richard Antalik
noreply at git.blender.org
Thu Mar 24 02:13:20 CET 2022
Commit: 16d8583c84801b9940787e578930fef7fb777f81
Author: Richard Antalik
Date: Wed Mar 23 22:13:03 2022 +0100
Branches: temp-vse-channels-edge-panning
https://developer.blender.org/rB16d8583c84801b9940787e578930fef7fb777f81
Make channels UI scaleable, so it is always visible.
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/resources.c
M source/blender/editors/space_sequencer/sequencer_channels_draw.c
M source/blender/editors/space_sequencer/sequencer_intern.h
M source/blender/makesrna/intern/rna_userdef.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 060c9dc33d6..37dfbe6754f 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2940,10 +2940,10 @@ typedef enum eFontStyle_Align {
UI_STYLE_TEXT_RIGHT = 2,
} eFontStyle_Align;
-struct uiFontStyleDraw_Params {
+typedef struct uiFontStyleDraw_Params {
eFontStyle_Align align;
uint word_wrap : 1;
-};
+} uiFontStyleDraw_Params;
/* Styled text draw */
void UI_fontstyle_set(const struct uiFontStyle *fs);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index b2ba8fa4a74..cfdcd08df4a 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -154,7 +154,7 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
switch (colorid) {
case TH_BACK:
- if (ELEM(theme_regionid, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW) || (spacetype == SPACE_SEQ && theme_regionid == RGN_TYPE_CHANNELS) ) {
+ if (ELEM(theme_regionid, RGN_TYPE_WINDOW, RGN_TYPE_PREVIEW)) {
cp = ts->back;
}
else if (theme_regionid == RGN_TYPE_CHANNELS) {
diff --git a/source/blender/editors/space_sequencer/sequencer_channels_draw.c b/source/blender/editors/space_sequencer/sequencer_channels_draw.c
index 070b1398b2b..8806630c12c 100644
--- a/source/blender/editors/space_sequencer/sequencer_channels_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_channels_draw.c
@@ -38,58 +38,63 @@
/* Own include. */
#include "sequencer_intern.h"
-#define ICON_WIDTH (U.widget_unit * 0.8)
-
-/* Similar to `UI_view2d_sync()` but converts values to pixelspace. */
-static void sync_channel_header_area(SeqChannelDrawContext *context)
-{
- LISTBASE_FOREACH (ARegion *, region, &context->area->regionbase) {
- View2D *v2d_other = ®ion->v2d;
-
- /* don't operate on self */
- if (context->v2d != v2d_other && region->regiontype == RGN_TYPE_WINDOW) {
- context->v2d->cur.ymin = v2d_other->cur.ymin * context->channel_height;
- context->v2d->cur.ymax = v2d_other->cur.ymax * context->channel_height;
- /* region possibly changed, so refresh */
- ED_region_tag_redraw_no_rebuild(region);
- }
- }
-}
-
-static float channel_height_pixelspace_get(ScrArea *area)
+static ARegion *timeline_region_get(ScrArea *area)
{
LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
- return UI_view2d_view_to_region_y(®ion->v2d, 1.0f) -
- UI_view2d_view_to_region_y(®ion->v2d, 0.0f);
+ return region;
}
}
BLI_assert_unreachable();
- return 1.0f;
+ return NULL;
}
-static float frame_width_pixelspace_get(ScrArea *area)
+static float draw_offset_get(View2D *timeline_region_v2d)
{
- LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
- if (region->regiontype == RGN_TYPE_WINDOW) {
- return UI_view2d_view_to_region_x(®ion->v2d, 1.0f) -
- UI_view2d_view_to_region_x(®ion->v2d, 0.0f);
- }
- }
+ return timeline_region_v2d->cur.ymin;
+}
- BLI_assert_unreachable();
- return 1.0f;
+static float channel_height_pixelspace_get(View2D *timeline_region_v2d)
+{
+ return UI_view2d_view_to_region_y(timeline_region_v2d, 1.0f) -
+ UI_view2d_view_to_region_y(timeline_region_v2d, 0.0f);
+}
+
+static float frame_width_pixelspace_get(View2D *timeline_region_v2d)
+{
+
+ return UI_view2d_view_to_region_x(timeline_region_v2d, 1.0f) -
+ UI_view2d_view_to_region_x(timeline_region_v2d, 0.0f);
+}
+
+static float icon_width_get(SeqChannelDrawContext *context)
+{
+ return (U.widget_unit * 0.8 * context->scale);
}
static float widget_y_offset(SeqChannelDrawContext *context)
{
- return context->channel_height / 2 - ICON_WIDTH / 2;
+ return (((context->channel_height / context->scale) - icon_width_get(context))) / 2;
}
static float channel_index_y_min(SeqChannelDrawContext *context, const int index)
{
- return index * context->channel_height;
+ float y = (index - context->draw_offset) * context->channel_height;
+ y /= context->scale;
+ return y;
+}
+
+static void debug_rect(SeqChannelDrawContext *context, int channel_index)
+{
+ GPU_blend(GPU_BLEND_ALPHA);
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4ub(255, 255, 255, 48);
+ float y = channel_index_y_min(context, channel_index);
+ imm_draw_box_wire_2d(pos, 1, y, context->v2d->cur.xmax, y + context->channel_height);
+ immUnbindProgram();
+ GPU_blend(GPU_BLEND_NONE);
}
static void displayed_channel_range_get(SeqChannelDrawContext *context, int channel_range[2])
@@ -110,8 +115,9 @@ static float draw_channel_widget_hide(SeqChannelDrawContext *context,
int channel_index,
float offset)
{
- const float y = channel_index_y_min(context, channel_index) + widget_y_offset(context);
- const float width = ICON_WIDTH;
+ float y = channel_index_y_min(context, channel_index) + widget_y_offset(context);
+
+ const float width = icon_width_get(context);
SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index);
const int icon = SEQ_channel_is_muted(channel) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT;
const char *tooltip = SEQ_channel_is_muted(channel) ? "Unmute channel" : "Mute channel";
@@ -127,8 +133,8 @@ static float draw_channel_widget_hide(SeqChannelDrawContext *context,
icon,
context->v2d->cur.xmax - offset,
y,
- ICON_WIDTH,
- ICON_WIDTH,
+ icon_width_get(context),
+ icon_width_get(context),
&ptr,
hide_prop,
0,
@@ -147,8 +153,8 @@ static float draw_channel_widget_lock(SeqChannelDrawContext *context,
float offset)
{
- const float y = channel_index_y_min(context, channel_index) + widget_y_offset(context);
- const float width = ICON_WIDTH;
+ float y = channel_index_y_min(context, channel_index) + widget_y_offset(context);
+ const float width = icon_width_get(context);
SeqTimelineChannel *channel = SEQ_channel_get_by_index(context->channels, channel_index);
const int icon = SEQ_channel_is_locked(channel) ? ICON_LOCKED : ICON_UNLOCKED;
@@ -165,8 +171,8 @@ static float draw_channel_widget_lock(SeqChannelDrawContext *context,
icon,
context->v2d->cur.xmax - offset,
y,
- ICON_WIDTH,
- ICON_WIDTH,
+ icon_width_get(context),
+ icon_width_get(context),
&ptr,
hide_prop,
0,
@@ -186,7 +192,7 @@ static bool channel_is_being_renamed(SpaceSeq *sseq, int channel_index)
static float text_size_get(SeqChannelDrawContext *context)
{
- return 20 * U.dpi_fac; // XXX
+ return 20 * U.dpi_fac * context->scale; // XXX
}
/* Todo: decide what gets priority - label or buttons */
@@ -196,15 +202,16 @@ static void label_rect_init(SeqChannelDrawContext *context,
rctf *r_rect)
{
float text_size = text_size_get(context);
- float margin = (context->channel_height - text_size) / 2.0f;
+ float margin = (context->channel_height / context->scale - text_size) / 2.0f;
float y = channel_index_y_min(context, channel_index) + margin;
- float margin_x = ICON_WIDTH * 0.65;
- float width = max_ff(0.0f, context->v2d->cur.xmax - used_width);
+ float margin_x = icon_width_get(context) * 0.65;
+ float width = max_ff(0.0f,
+ context->v2d->cur.xmax / context->scale - used_width / context->scale);
/* Text input has own margin. Prevent text jumping around and use as much space as possible. */
if (channel_is_being_renamed(CTX_wm_space_seq(context->C), channel_index)) {
- float input_box_margin = ICON_WIDTH * 0.5f;
+ float input_box_margin = icon_width_get(context) * 0.5f;
margin_x -= input_box_margin;
width += input_box_margin;
}
@@ -235,14 +242,14 @@ static void draw_channel_labels(SeqChannelDrawContext *context,
rect.xmin,
rect.ymin,
rect.xmax - rect.xmin,
- rect.ymax - rect.ymin,
+ (rect.ymax - rect.ymin),
&ptr,
RNA_property_identifier(prop),
-1,
0,
0,
- -1,
- -1,
+ 0,
+ 0,
NULL);
UI_block_emboss_set(block, UI_EMBOSS_NONE);
@@ -253,29 +260,40 @@ static void draw_channel_labels(SeqChannelDrawContext *context,
WM_event_add_notifier(context->C, NC_SCENE | ND_SEQUENCER, context->scene);
}
else {
- uchar col[4] = {255, 255, 255, 255};
- char *label = SEQ_channel_name_get(context->channels, channel_index);
- UI_view2d_text_cache_add_rectf(context->v2d, &rect, label, strlen(label), col);
+ const char *label = SEQ_channel_name_get(context->channels, channel_index);
+ uiDefBut(block,
+ UI_BTYPE_LABEL,
+ 0,
+ label,
+ rect.xmin,
+ rect.ymin,
+ rect.xmax - rect.xmin,
+ (rect.ymax - rect.ymin),
+ NULL,
+ 0,
+ 0,
+ 0,
+ 0,
+ "");
}
}
/* Todo: different text/buttons alignment */
static void draw_channel_header(SeqChannelDrawContext *context, uiBlock *block, int channel_index)
{
- /* Not enough space to draw. Draw only background.*/
- if (ICON_WIDTH > context->channel_height) {
- return;
- }
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list