Nodes: Remove resize widgets from collapsed nodes
Collapsed nodes had a specific widget to change their width. Now that collapsed nodes are square rather than pill-shaped, the edges can be used to resize them, just like in the uncollapsed state. Therefore the scape widget can be removed. Pull Request: https://projects.blender.org/blender/blender/pulls/147576
This commit is contained in:
committed by
Hans Goudey
parent
d609bd3668
commit
8a78c14d03
@@ -201,7 +201,9 @@ NodeResizeDirection node_get_resize_direction(const SpaceNode &snode,
|
||||
const int x,
|
||||
const int y)
|
||||
{
|
||||
const float size = NODE_RESIZE_MARGIN * math::max(snode.runtime->aspect, 1.0f);
|
||||
const bool node_is_collapsed = node->flag & NODE_COLLAPSED;
|
||||
const float size = NODE_RESIZE_MARGIN * math::max(snode.runtime->aspect, 1.0f) *
|
||||
(node_is_collapsed ? 3.0f : 1.0f);
|
||||
|
||||
if (node->is_frame()) {
|
||||
NodeFrame *data = (NodeFrame *)node->storage;
|
||||
@@ -231,17 +233,6 @@ NodeResizeDirection node_get_resize_direction(const SpaceNode &snode,
|
||||
return dir;
|
||||
}
|
||||
|
||||
if (node->flag & NODE_COLLAPSED) {
|
||||
/* right part of node */
|
||||
rctf bounds = node->runtime->draw_bounds;
|
||||
bounds.xmin = node->runtime->draw_bounds.xmax - 1.0f * U.widget_unit;
|
||||
if (BLI_rctf_isect_pt(&bounds, x, y)) {
|
||||
return NODE_RESIZE_RIGHT;
|
||||
}
|
||||
|
||||
return NODE_RESIZE_NONE;
|
||||
}
|
||||
|
||||
const rctf &bounds = node->runtime->draw_bounds;
|
||||
NodeResizeDirection dir = NODE_RESIZE_NONE;
|
||||
|
||||
@@ -250,6 +241,15 @@ NodeResizeDirection node_get_resize_direction(const SpaceNode &snode,
|
||||
}
|
||||
if (x >= bounds.xmin && x < bounds.xmin + size && y >= bounds.ymin && y < bounds.ymax) {
|
||||
dir |= NODE_RESIZE_LEFT;
|
||||
|
||||
if (node_is_collapsed) {
|
||||
/* Prevent conflict with the collapse/expand icon. */
|
||||
if ((abs(y - BLI_rctf_cent_y(&bounds)) < 0.4f * U.widget_unit) &&
|
||||
(x > (bounds.xmin + 0.4f * U.widget_unit)))
|
||||
{
|
||||
dir = NODE_RESIZE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
@@ -3427,14 +3427,14 @@ static void node_draw_collapsed(const bContext &C,
|
||||
|
||||
/* Collapse/expand icon. */
|
||||
{
|
||||
const int but_size = U.widget_unit * 1.0f;
|
||||
const int but_size = 0.8f * U.widget_unit;
|
||||
UI_block_emboss_set(&block, ui::EmbossType::None);
|
||||
|
||||
uiBut *but = uiDefIconBut(&block,
|
||||
ButType::ButToggle,
|
||||
0,
|
||||
ICON_RIGHTARROW,
|
||||
rct.xmin + (NODE_MARGIN_X / 3),
|
||||
rct.xmin + (NODE_MARGIN_X / 3) + 0.1f * U.widget_unit,
|
||||
centy - but_size / 2,
|
||||
but_size,
|
||||
but_size,
|
||||
@@ -3502,39 +3502,6 @@ static void node_draw_collapsed(const bContext &C,
|
||||
UI_but_flag_enable(but, UI_BUT_INACTIVE);
|
||||
}
|
||||
|
||||
/* Scale widget thing. */
|
||||
uint pos = GPU_vertformat_attr_add(
|
||||
immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
immUniformThemeColorShadeAlpha(TH_TEXT, -40, -180);
|
||||
float dx = 0.5f * U.widget_unit;
|
||||
const float dx2 = 0.15f * U.widget_unit * snode.runtime->aspect;
|
||||
const float dy = 0.2f * U.widget_unit;
|
||||
|
||||
immBegin(GPU_PRIM_LINES, 4);
|
||||
immVertex2f(pos, rct.xmax - dx, centy - dy);
|
||||
immVertex2f(pos, rct.xmax - dx, centy + dy);
|
||||
|
||||
immVertex2f(pos, rct.xmax - dx - dx2, centy - dy);
|
||||
immVertex2f(pos, rct.xmax - dx - dx2, centy + dy);
|
||||
immEnd();
|
||||
|
||||
immUniformThemeColorShadeAlpha(TH_TEXT, 0, -180);
|
||||
dx -= snode.runtime->aspect;
|
||||
|
||||
immBegin(GPU_PRIM_LINES, 4);
|
||||
immVertex2f(pos, rct.xmax - dx, centy - dy);
|
||||
immVertex2f(pos, rct.xmax - dx, centy + dy);
|
||||
|
||||
immVertex2f(pos, rct.xmax - dx - dx2, centy - dy);
|
||||
immVertex2f(pos, rct.xmax - dx - dx2, centy + dy);
|
||||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
|
||||
node_draw_sockets(C, block, snode, ntree, node);
|
||||
|
||||
UI_block_end_ex(&C,
|
||||
|
||||
@@ -1286,6 +1286,15 @@ bNodeSocket *node_find_indicated_socket(SpaceNode &snode,
|
||||
}
|
||||
}
|
||||
if (distance < max_distance) {
|
||||
if (node_collapsed) {
|
||||
if ((cursor.x - location.x > NODE_SOCKSIZE) ||
|
||||
((location.x < cursor.x) && (cursor.x - location.x <= padded_socket_size) &&
|
||||
(abs(location.y - cursor.y) > NODE_SOCKSIZE)))
|
||||
{
|
||||
/* Needed to be able to resize collapsed nodes. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
update_best_socket(sock, distance);
|
||||
}
|
||||
}
|
||||
@@ -1299,7 +1308,10 @@ bNodeSocket *node_find_indicated_socket(SpaceNode &snode,
|
||||
const float distance = math::distance(location, cursor);
|
||||
if (distance < max_distance) {
|
||||
if (node_collapsed) {
|
||||
if (location.x - cursor.x > padded_socket_size) {
|
||||
if ((location.x - cursor.x > NODE_SOCKSIZE) ||
|
||||
((location.x > cursor.x) && (location.x - cursor.x <= padded_socket_size) &&
|
||||
(abs(location.y - cursor.y) > NODE_SOCKSIZE)))
|
||||
{
|
||||
/* Needed to be able to resize collapsed nodes. */
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user