WIP: UI: Image Editor Interactive Zoom Control #117050
|
@ -263,6 +263,11 @@ class CLIP_HT_header(Header):
|
|||
else:
|
||||
self._draw_masking(context)
|
||||
|
||||
# Image zoom controls.
|
||||
sub = layout.row(align=True)
|
||||
sub.prop(sc, "zoom_percentage", text="")
|
||||
sub.menu("CLIP_MT_view_zoom", icon='DOWNARROW_HLT', text="")
|
||||
|
||||
# Gizmo toggle & popover.
|
||||
row = layout.row(align=True)
|
||||
row.prop(sc, "show_gizmo", icon='GIZMO', text="")
|
||||
|
@ -1301,23 +1306,29 @@ class CLIP_PT_tools_grease_pencil_draw(AnnotationDrawingToolsPanel, Panel):
|
|||
|
||||
|
||||
class CLIP_MT_view_zoom(Menu):
|
||||
bl_label = "Fractional Zoom"
|
||||
bl_label = "Zoom"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
from math import isclose
|
||||
|
||||
current_zoom = _context.space_data.zoom_percentage
|
||||
ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
|
||||
|
||||
for i, (a, b) in enumerate(ratios):
|
||||
if i in {3, 4}: # Draw separators around Zoom 1:1.
|
||||
layout.separator()
|
||||
|
||||
percent = a / b * 100
|
||||
layout.operator(
|
||||
"clip.view_zoom_ratio",
|
||||
text=iface_("Zoom %d:%d") % (a, b),
|
||||
translate=False,
|
||||
text=iface_("%g%% (%d:%d)") % (percent, a, b),
|
||||
translate=False, icon=('NONE','LAYER_ACTIVE')[isclose(percent, current_zoom, abs_tol = 0.5)]
|
||||
).ratio = a / b
|
||||
|
||||
layout.separator()
|
||||
layout.operator("clip.view_zoom_in")
|
||||
layout.operator("clip.view_zoom_out")
|
||||
layout.operator("clip.view_all", text="Zoom to Fit").fit_view = True
|
||||
layout.operator("view2d.zoom_border", text="Zoom Region...")
|
||||
|
||||
|
||||
class CLIP_MT_view(Menu):
|
||||
bl_label = "View"
|
||||
|
@ -1333,26 +1344,22 @@ class CLIP_MT_view(Menu):
|
|||
layout.prop(sc, "show_region_hud")
|
||||
layout.separator()
|
||||
|
||||
layout.operator("clip.view_selected")
|
||||
layout.operator("clip.view_all")
|
||||
layout.operator("clip.view_all", text="View Fit").fit_view = True
|
||||
layout.operator("clip.view_center_cursor")
|
||||
layout.prop(sc, "show_metadata")
|
||||
layout.separator()
|
||||
|
||||
layout.menu("CLIP_MT_view_zoom")
|
||||
layout.separator()
|
||||
|
||||
layout.operator("clip.view_zoom_in")
|
||||
layout.operator("clip.view_zoom_out")
|
||||
layout.separator()
|
||||
layout.operator("clip.view_all")
|
||||
layout.operator("clip.view_selected")
|
||||
layout.operator("clip.view_center_cursor")
|
||||
|
||||
layout.prop(sc, "show_metadata")
|
||||
layout.separator()
|
||||
else:
|
||||
layout.operator_context = 'INVOKE_REGION_PREVIEW'
|
||||
layout.operator("clip.graph_view_all")
|
||||
if sc.view == 'GRAPH':
|
||||
layout.operator("clip.graph_center_current_frame")
|
||||
|
||||
layout.operator("view2d.zoom_border", text="Zoom")
|
||||
layout.operator_context = 'INVOKE_DEFAULT'
|
||||
|
||||
layout.separator()
|
||||
|
|
|
@ -88,11 +88,6 @@ class IMAGE_MT_view(Menu):
|
|||
|
||||
layout.separator()
|
||||
|
||||
layout.operator("image.view_zoom_in")
|
||||
layout.operator("image.view_zoom_out")
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.menu("IMAGE_MT_view_zoom")
|
||||
|
||||
layout.separator()
|
||||
|
@ -121,23 +116,29 @@ class IMAGE_MT_view(Menu):
|
|||
|
||||
|
||||
class IMAGE_MT_view_zoom(Menu):
|
||||
bl_label = "Fractional Zoom"
|
||||
bl_label = "Zoom"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
from math import isclose
|
||||
|
||||
current_zoom = _context.space_data.zoom_percentage
|
||||
ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
|
||||
|
||||
for i, (a, b) in enumerate(ratios):
|
||||
if i in {3, 4}: # Draw separators around Zoom 1:1.
|
||||
layout.separator()
|
||||
|
||||
percent = a / b * 100
|
||||
layout.operator(
|
||||
"image.view_zoom_ratio",
|
||||
text=iface_("Zoom %d:%d") % (a, b),
|
||||
translate=False,
|
||||
text=iface_("%g%% (%d:%d)") % (percent, a, b),
|
||||
translate=False, icon=('NONE','LAYER_ACTIVE')[isclose(percent, current_zoom, abs_tol = 0.5)]
|
||||
).ratio = a / b
|
||||
|
||||
layout.separator()
|
||||
layout.operator("image.view_zoom_in")
|
||||
layout.operator("image.view_zoom_out")
|
||||
layout.operator("image.view_all", text="Zoom to Fit").fit_view = True
|
||||
layout.operator("image.view_zoom_border", text="Zoom Region...")
|
||||
|
||||
|
||||
class IMAGE_MT_select(Menu):
|
||||
bl_label = "Select"
|
||||
|
@ -846,6 +847,11 @@ class IMAGE_HT_header(Header):
|
|||
|
||||
layout.separator_spacer()
|
||||
|
||||
# Image zoom controls.
|
||||
sub = layout.row(align=True)
|
||||
sub.prop(sima, "zoom_percentage", text="")
|
||||
sub.menu("IMAGE_MT_view_zoom", icon='DOWNARROW_HLT', text="")
|
||||
|
||||
# Gizmo toggle & popover.
|
||||
row = layout.row(align=True)
|
||||
row.prop(sima, "show_gizmo", icon='GIZMO', text="")
|
||||
|
|
|
@ -188,6 +188,12 @@ class SEQUENCER_HT_header(Header):
|
|||
layout.separator_spacer()
|
||||
|
||||
if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
|
||||
|
||||
# Image zoom controls.
|
||||
sub = layout.row(align=True)
|
||||
sub.prop(st, "zoom_percentage", text="")
|
||||
sub.menu("SEQUENCER_MT_preview_zoom", icon='DOWNARROW_HLT', text="")
|
||||
|
||||
layout.prop(st, "display_mode", text="", icon_only=True)
|
||||
layout.prop(st, "preview_channels", text="", icon_only=True)
|
||||
|
||||
|
@ -366,24 +372,29 @@ class SEQUENCER_MT_range(Menu):
|
|||
|
||||
|
||||
class SEQUENCER_MT_preview_zoom(Menu):
|
||||
bl_label = "Fractional Zoom"
|
||||
bl_label = "Zoom"
|
||||
|
||||
def draw(self, _context):
|
||||
layout = self.layout
|
||||
layout.operator_context = 'INVOKE_REGION_PREVIEW'
|
||||
from math import isclose
|
||||
|
||||
current_zoom = _context.space_data.zoom_percentage
|
||||
ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
|
||||
|
||||
for i, (a, b) in enumerate(ratios):
|
||||
if i in {3, 4}: # Draw separators around Zoom 1:1.
|
||||
layout.separator()
|
||||
|
||||
percent = a / b * 100
|
||||
layout.operator(
|
||||
"sequencer.view_zoom_ratio",
|
||||
text=iface_("Zoom %d:%d") % (a, b),
|
||||
translate=False,
|
||||
text=iface_("%g%% (%d:%d)") % (percent, a, b),
|
||||
translate=False, icon=('NONE','LAYER_ACTIVE')[isclose(percent, current_zoom, abs_tol = 0.5)]
|
||||
).ratio = a / b
|
||||
layout.operator_context = 'INVOKE_DEFAULT'
|
||||
|
||||
layout.separator()
|
||||
layout.operator("view2d.zoom_in")
|
||||
layout.operator("view2d.zoom_out")
|
||||
layout.operator("sequencer.view_all_preview", text="Zoom to Fit")
|
||||
layout.operator("view2d.zoom_border", text="Zoom Region...")
|
||||
|
||||
|
||||
class SEQUENCER_MT_proxy(Menu):
|
||||
|
@ -453,7 +464,7 @@ class SEQUENCER_MT_view(Menu):
|
|||
layout.operator_context = 'INVOKE_REGION_PREVIEW'
|
||||
layout.operator("sequencer.view_all_preview", text="Fit Preview in Window")
|
||||
if is_sequencer_view:
|
||||
layout.menu("SEQUENCER_MT_preview_zoom", text="Fractional Preview Zoom")
|
||||
layout.menu("SEQUENCER_MT_preview_zoom", text="Preview Zoom")
|
||||
else:
|
||||
layout.operator("view2d.zoom_border", text="Zoom to Border")
|
||||
layout.menu("SEQUENCER_MT_preview_zoom")
|
||||
|
|
|
@ -58,8 +58,9 @@ uiBut *uiDefAutoButR(uiBlock *block,
|
|||
int height)
|
||||
{
|
||||
uiBut *but = nullptr;
|
||||
const PropertyType type = RNA_property_type(prop);
|
||||
|
||||
switch (RNA_property_type(prop)) {
|
||||
switch (type) {
|
||||
case PROP_BOOLEAN: {
|
||||
if (RNA_property_array_check(prop) && index == -1) {
|
||||
return nullptr;
|
||||
|
@ -127,9 +128,34 @@ uiBut *uiDefAutoButR(uiBlock *block,
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
else if (RNA_property_subtype(prop) == PROP_PERCENTAGE ||
|
||||
RNA_property_subtype(prop) == PROP_FACTOR)
|
||||
{
|
||||
else if (RNA_property_subtype(prop) == PROP_PERCENTAGE) {
|
||||
bool show_slider = false;
|
||||
if (type == PROP_INT) {
|
||||
int softmin, softmax, step;
|
||||
RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step);
|
||||
show_slider = softmax <= 100;
|
||||
}
|
||||
else if (type == PROP_FLOAT) {
|
||||
float softmin, softmax, step, precision;
|
||||
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
|
||||
show_slider = softmax <= 100.0f;
|
||||
}
|
||||
but = uiDefButR_prop(block,
|
||||
show_slider ? UI_BTYPE_NUM_SLIDER : UI_BTYPE_NUM,
|
||||
0,
|
||||
name,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
ptr,
|
||||
prop,
|
||||
index,
|
||||
0,
|
||||
0,
|
||||
nullptr);
|
||||
}
|
||||
else if (RNA_property_subtype(prop) == PROP_FACTOR) {
|
||||
but = uiDefButR_prop(block,
|
||||
UI_BTYPE_NUM_SLIDER,
|
||||
0,
|
||||
|
|
|
@ -843,6 +843,7 @@ static void view_zoomstep_apply_ex(bContext *C,
|
|||
|
||||
/* request updates to be done... */
|
||||
ED_region_tag_redraw_no_rebuild(vzd->region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ static void sclip_zoom_set_factor_exec(bContext *C, const wmEvent *event, float
|
|||
sclip_zoom_set_factor(C, factor, mpos, mpos ? (U.uiflag & USER_ZOOM_TO_MOUSEPOS) : false);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
@ -577,6 +578,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
|
|||
if (cancel) {
|
||||
sc->zoom = vpd->zoom;
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
}
|
||||
|
||||
if (vpd->timer) {
|
||||
|
@ -594,6 +596,7 @@ static int view_zoom_exec(bContext *C, wmOperator *op)
|
|||
sclip_zoom_set_factor(C, RNA_float_get(op->ptr, "factor"), nullptr, false);
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -663,6 +666,7 @@ static void view_zoom_apply(
|
|||
RNA_float_set(op->ptr, "factor", factor);
|
||||
sclip_zoom_set(C, vpd->zoom * factor, vpd->location, zoom_to_pos);
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
}
|
||||
|
||||
static int view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
@ -744,6 +748,7 @@ static int view_zoom_in_exec(bContext *C, wmOperator *op)
|
|||
sclip_zoom_set_factor(C, powf(2.0f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -801,6 +806,7 @@ static int view_zoom_out_exec(bContext *C, wmOperator *op)
|
|||
sclip_zoom_set_factor(C, powf(0.5f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -866,6 +872,7 @@ static int view_zoom_ratio_exec(bContext *C, wmOperator *op)
|
|||
sc->yof = int(sc->yof);
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -949,6 +956,7 @@ static int view_all_exec(bContext *C, wmOperator *op)
|
|||
sc->xof = sc->yof = 0.0f;
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1020,6 +1028,7 @@ static int view_selected_exec(bContext *C, wmOperator * /*op*/)
|
|||
|
||||
ED_clip_view_selection(C, region, true);
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -507,6 +507,7 @@ struct ViewZoomData {
|
|||
/* */
|
||||
SpaceImage *sima;
|
||||
ARegion *region;
|
||||
ScrArea *area;
|
||||
};
|
||||
|
||||
static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
@ -541,6 +542,7 @@ static void image_view_zoom_init(bContext *C, wmOperator *op, const wmEvent *eve
|
|||
|
||||
vpd->sima = sima;
|
||||
vpd->region = region;
|
||||
vpd->area = CTX_wm_area(C);
|
||||
|
||||
WM_event_add_modal_handler(C, op);
|
||||
}
|
||||
|
@ -553,6 +555,7 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel)
|
|||
if (cancel) {
|
||||
sima->zoom = vpd->zoom;
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
}
|
||||
|
||||
if (vpd->timer) {
|
||||
|
@ -573,6 +576,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op)
|
|||
sima_zoom_set_factor(sima, region, RNA_float_get(op->ptr, "factor"), nullptr, false);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -608,6 +612,7 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
|
|||
location,
|
||||
(use_cursor_init && (U.uiflag & USER_ZOOM_TO_MOUSEPOS)));
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -661,6 +666,7 @@ static void image_zoom_apply(ViewZoomData *vpd,
|
|||
RNA_float_set(op->ptr, "factor", factor);
|
||||
sima_zoom_set(vpd->sima, vpd->region, vpd->zoom * factor, vpd->location, zoom_to_pos);
|
||||
ED_region_tag_redraw(vpd->region);
|
||||
ED_area_tag_redraw_regiontype(vpd->area, RGN_TYPE_HEADER);
|
||||
}
|
||||
|
||||
static int image_view_zoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
@ -786,6 +792,7 @@ static int image_view_ndof_invoke(bContext *C, wmOperator * /*op*/, const wmEven
|
|||
sima->yof += pan_vec[1];
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -829,6 +836,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op)
|
|||
image_view_all(sima, region, op);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -975,6 +983,7 @@ static int image_view_selected_exec(bContext *C, wmOperator * /*op*/)
|
|||
sima_zoom_set_from_bounds(sima, region, &bounds);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1014,6 +1023,7 @@ static int image_view_zoom_in_exec(bContext *C, wmOperator *op)
|
|||
sima, region, powf(2.0f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1073,6 +1083,7 @@ static int image_view_zoom_out_exec(bContext *C, wmOperator *op)
|
|||
sima, region, powf(0.5f, 1.0f / 3.0f), location, U.uiflag & USER_ZOOM_TO_MOUSEPOS);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1138,6 +1149,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op)
|
|||
sima->yof = int(sima->yof);
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
@ -1204,6 +1216,7 @@ static int image_view_zoom_border_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
|
@ -221,16 +221,12 @@ static int sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
|
|||
{
|
||||
RenderData *rd = &CTX_data_scene(C)->r;
|
||||
View2D *v2d = UI_view2d_fromcontext(C);
|
||||
SpaceSeq *sseq = CTX_wm_space_seq(C);
|
||||
|
||||
float ratio = RNA_float_get(op->ptr, "ratio");
|
||||
|
||||
int winx, winy;
|
||||
BKE_render_resolution(rd, false, &winx, &winy);
|
||||
|
||||
float facx = BLI_rcti_size_x(&v2d->mask) / float(winx);
|
||||
float facy = BLI_rcti_size_y(&v2d->mask) / float(winy);
|
||||
|
||||
BLI_rctf_resize(&v2d->cur, ceilf(winx * facx / ratio + 0.5f), ceilf(winy * facy / ratio + 0.5f));
|
||||
BLI_rctf_resize(&v2d->cur,
|
||||
float(BLI_rcti_size_x(&v2d->mask)) / ratio,
|
||||
float(BLI_rcti_size_y(&v2d->mask)) / ratio);
|
||||
|
||||
ED_region_tag_redraw(CTX_wm_region(C));
|
||||
|
||||
|
|
|
@ -1804,6 +1804,18 @@ static void rna_SpaceImageEditor_zoom_get(PointerRNA *ptr, float *values)
|
|||
}
|
||||
}
|
||||
|
||||
static float rna_SpaceImageEditor_zoom_percentage_get(PointerRNA *ptr)
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)ptr->data;
|
||||
return sima->zoom * 100.0f;
|
||||
}
|
||||
|
||||
static void rna_SpaceImageEditor_zoom_percentage_set(PointerRNA *ptr, const float value)
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)ptr->data;
|
||||
sima->zoom = value / 100.0f;
|
||||
}
|
||||
|
||||
static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *values)
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)ptr->data;
|
||||
|
@ -2500,6 +2512,43 @@ static std::optional<std::string> rna_SpaceSequencerTimelineOverlay_path(
|
|||
return "timeline_overlay";
|
||||
}
|
||||
|
||||
static float rna_SpaceSequenceEditor_zoom_percentage_get(PointerRNA *ptr)
|
||||
{
|
||||
SpaceSeq *sseq = static_cast<SpaceSeq *>(ptr->data);
|
||||
ScrArea *area = rna_area_from_space(ptr);
|
||||
if (area == nullptr) {
|
||||
return 100.0f;
|
||||
}
|
||||
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
|
||||
if (region == nullptr) {
|
||||
return 100.0f;
|
||||
}
|
||||
|
||||
View2D *v2d = ®ion->v2d;
|
||||
const float zoom = 1.0f / (BLI_rctf_size_x(&v2d->cur) / float(BLI_rcti_size_x(&v2d->mask))) *
|
||||
100.0f;
|
||||
return zoom;
|
||||
}
|
||||
|
||||
static void rna_SpaceSequenceEditor_zoom_percentage_set(PointerRNA *ptr, const float value)
|
||||
{
|
||||
SpaceSeq *sseq = static_cast<SpaceSeq *>(ptr->data);
|
||||
ScrArea *area = rna_area_from_space(ptr);
|
||||
if (area == nullptr) {
|
||||
return;
|
||||
}
|
||||
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_PREVIEW);
|
||||
if (region == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
View2D *v2d = ®ion->v2d;
|
||||
BLI_rctf_resize(&v2d->cur,
|
||||
float(BLI_rcti_size_x(&v2d->mask)) / (value / 100.0f),
|
||||
float(BLI_rcti_size_y(&v2d->mask)) / (value / 100.0f));
|
||||
ED_region_tag_redraw(region);
|
||||
}
|
||||
|
||||
/* Space Node Editor */
|
||||
static PointerRNA rna_SpaceNode_overlay_get(PointerRNA *ptr)
|
||||
{
|
||||
|
@ -2760,6 +2809,18 @@ static void rna_SpaceClipEditor_view_type_update(Main * /*bmain*/,
|
|||
ED_area_tag_refresh(area);
|
||||
}
|
||||
|
||||
static float rna_SpaceClipEditor_zoom_percentage_get(PointerRNA *ptr)
|
||||
{
|
||||
SpaceClip *sc = (SpaceClip *)ptr->data;
|
||||
return sc->zoom * 100.0f;
|
||||
}
|
||||
|
||||
static void rna_SpaceClipEditor_zoom_percentage_set(PointerRNA *ptr, const float value)
|
||||
{
|
||||
SpaceClip *sc = (SpaceClip *)ptr->data;
|
||||
sc->zoom = value / 100.0f;
|
||||
}
|
||||
|
||||
/* File browser. */
|
||||
|
||||
static std::optional<std::string> rna_FileSelectParams_path(const PointerRNA * /*ptr*/)
|
||||
|
@ -5606,6 +5667,16 @@ static void rna_def_space_image(BlenderRNA *brna)
|
|||
RNA_def_property_float_funcs(prop, "rna_SpaceImageEditor_zoom_get", nullptr, nullptr);
|
||||
RNA_def_property_ui_text(prop, "Zoom", "Zoom factor");
|
||||
|
||||
prop = RNA_def_property(srna, "zoom_percentage", PROP_FLOAT, PROP_PERCENTAGE);
|
||||
RNA_def_property_float_funcs(prop,
|
||||
"rna_SpaceImageEditor_zoom_percentage_get",
|
||||
"rna_SpaceImageEditor_zoom_percentage_set",
|
||||
nullptr);
|
||||
RNA_def_property_float_default(prop, 100.0);
|
||||
RNA_def_property_range(prop, .4, 80000);
|
||||
RNA_def_property_ui_range(prop, 25, 400, 100, 0);
|
||||
RNA_def_property_ui_text(prop, "Zoom", "Zoom percentage");
|
||||
|
||||
/* image draw */
|
||||
prop = RNA_def_property(srna, "show_repeat", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SI_DRAW_TILE);
|
||||
|
@ -6098,6 +6169,17 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
|
|||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_ui_text(prop, "2D Cursor Location", "2D cursor location for this view");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, nullptr);
|
||||
|
||||
/* zoom percentage. */
|
||||
prop = RNA_def_property(srna, "zoom_percentage", PROP_FLOAT, PROP_PERCENTAGE);
|
||||
RNA_def_property_float_funcs(prop,
|
||||
"rna_SpaceSequenceEditor_zoom_percentage_get",
|
||||
"rna_SpaceSequenceEditor_zoom_percentage_set",
|
||||
nullptr);
|
||||
RNA_def_property_float_default(prop, 100.0);
|
||||
RNA_def_property_range(prop, .4, 80000);
|
||||
RNA_def_property_ui_range(prop, 25, 400, 100, 0);
|
||||
RNA_def_property_ui_text(prop, "Zoom", "Zoom percentage");
|
||||
}
|
||||
|
||||
static void rna_def_space_text(BlenderRNA *brna)
|
||||
|
@ -8009,6 +8091,18 @@ static void rna_def_space_clip(BlenderRNA *brna)
|
|||
RNA_def_property_boolean_negative_sdna(prop, nullptr, "gizmo_flag", SCLIP_GIZMO_HIDE_NAVIGATE);
|
||||
RNA_def_property_ui_text(prop, "Navigate Gizmo", "Viewport navigation gizmo");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, nullptr);
|
||||
|
||||
/* Zoom. */
|
||||
|
||||
prop = RNA_def_property(srna, "zoom_percentage", PROP_FLOAT, PROP_PERCENTAGE);
|
||||
RNA_def_property_float_funcs(prop,
|
||||
"rna_SpaceClipEditor_zoom_percentage_get",
|
||||
"rna_SpaceClipEditor_zoom_percentage_set",
|
||||
nullptr);
|
||||
RNA_def_property_float_default(prop, 100.0);
|
||||
RNA_def_property_range(prop, .4f, 80000);
|
||||
RNA_def_property_ui_range(prop, 25, 400, 100, 0);
|
||||
RNA_def_property_ui_text(prop, "Zoom", "Zoom percentage");
|
||||
}
|
||||
|
||||
static void rna_def_spreadsheet_column_id(BlenderRNA *brna)
|
||||
|
|
|
@ -155,6 +155,8 @@ static bool gesture_box_apply(bContext *C, wmOperator *op)
|
|||
retval = op->type->exec(C, op);
|
||||
OPERATOR_RETVAL_CHECK(retval);
|
||||
|
||||
ED_area_tag_redraw_regiontype(CTX_wm_area(C), RGN_TYPE_HEADER);
|
||||
|
||||
return (retval & OPERATOR_FINISHED) ? true : false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue