UI: Edge Highlighting While Resizing Editors
Highlighting of the active edges of editors while resizing. Pull Request: https://projects.blender.org/blender/blender/pulls/120998
This commit is contained in:
committed by
Harley Acheson
parent
726fd7365d
commit
b2eb8cc0df
@@ -273,6 +273,39 @@ void ED_screen_draw_edges(wmWindow *win)
|
||||
}
|
||||
}
|
||||
|
||||
void screen_draw_move_highlight(bScreen *screen, eScreenAxis dir_axis)
|
||||
{
|
||||
rctf rect = {SHRT_MAX, SHRT_MIN, SHRT_MAX, SHRT_MIN};
|
||||
|
||||
LISTBASE_FOREACH (const ScrEdge *, edge, &screen->edgebase) {
|
||||
if (edge->v1->editflag && edge->v2->editflag) {
|
||||
if (dir_axis == SCREEN_AXIS_H) {
|
||||
rect.xmin = std::min({rect.xmin, float(edge->v1->vec.x), float(edge->v2->vec.x)});
|
||||
rect.xmax = std::max({rect.xmax, float(edge->v1->vec.x), float(edge->v2->vec.x)});
|
||||
rect.ymin = rect.ymax = float(edge->v1->vec.y);
|
||||
}
|
||||
else {
|
||||
rect.ymin = std::min({rect.ymin, float(edge->v1->vec.y), float(edge->v2->vec.y)});
|
||||
rect.ymax = std::max({rect.ymax, float(edge->v1->vec.y), float(edge->v2->vec.y)});
|
||||
rect.xmin = rect.xmax = float(edge->v1->vec.x);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (dir_axis == SCREEN_AXIS_H) {
|
||||
BLI_rctf_pad(&rect, 0.0f, 2.5f * U.pixelsize);
|
||||
}
|
||||
else {
|
||||
BLI_rctf_pad(&rect, 2.5f * U.pixelsize, 0.0f);
|
||||
}
|
||||
|
||||
float inner[4] = {1.0f, 1.0f, 1.0f, 0.7f};
|
||||
float outline[4] = {0.0f, 0.0f, 0.0f, 0.8f};
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_4fv_ex(
|
||||
&rect, inner, nullptr, 1.0f, outline, 2.0f * U.pixelsize, 2.5f * U.pixelsize);
|
||||
}
|
||||
|
||||
static void screen_draw_area_drag_tip(int x, int y, const ScrArea *source, const std::string &hint)
|
||||
{
|
||||
const char *area_name = IFACE_(ED_area_name(source).c_str());
|
||||
|
||||
@@ -93,6 +93,8 @@ void screen_draw_dock_preview(
|
||||
ScrArea *source, ScrArea *target, AreaDockTarget dock_target, float factor, int x, int y);
|
||||
void screen_draw_split_preview(ScrArea *area, eScreenAxis dir_axis, float factor);
|
||||
|
||||
void screen_draw_move_highlight(bScreen *screen, eScreenAxis dir_axis);
|
||||
|
||||
/* `screen_edit.cc` */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1655,6 +1655,8 @@ struct sAreaMoveData {
|
||||
int bigger, smaller, origval, step;
|
||||
eScreenAxis dir_axis;
|
||||
AreaMoveSnapType snap_type;
|
||||
bScreen *screen;
|
||||
void *draw_callback; /* Call #screen_draw_move_highlight */
|
||||
};
|
||||
|
||||
/* helper call to move area-edge, sets limits
|
||||
@@ -1757,6 +1759,13 @@ static void area_move_set_limits(wmWindow *win,
|
||||
}
|
||||
}
|
||||
|
||||
static void area_move_draw_cb(const wmWindow * /*win*/, void *userdata)
|
||||
{
|
||||
const wmOperator *op = static_cast<const wmOperator *>(userdata);
|
||||
const sAreaMoveData *md = static_cast<sAreaMoveData *>(op->customdata);
|
||||
screen_draw_move_highlight(md->screen, md->dir_axis);
|
||||
}
|
||||
|
||||
/* validate selection inside screen, set variables OK */
|
||||
/* return false: init failed */
|
||||
static bool area_move_init(bContext *C, wmOperator *op)
|
||||
@@ -1799,6 +1808,9 @@ static bool area_move_init(bContext *C, wmOperator *op)
|
||||
|
||||
md->snap_type = use_bigger_smaller_snap ? SNAP_BIGGER_SMALLER_ONLY : SNAP_AREAGRID;
|
||||
|
||||
md->screen = screen;
|
||||
md->draw_callback = WM_draw_cb_activate(CTX_wm_window(C), area_move_draw_cb, op);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1988,6 +2000,11 @@ static void area_move_apply(bContext *C, wmOperator *op)
|
||||
|
||||
static void area_move_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
sAreaMoveData *md = static_cast<sAreaMoveData *>(op->customdata);
|
||||
if (md->draw_callback) {
|
||||
WM_draw_cb_exit(CTX_wm_window(C), md->draw_callback);
|
||||
}
|
||||
|
||||
MEM_SAFE_FREE(op->customdata);
|
||||
|
||||
/* this makes sure aligned edges will result in aligned grabbing */
|
||||
|
||||
Reference in New Issue
Block a user