Fix #113682: Improved Text Caret Position #113707

Merged
Harley Acheson merged 3 commits from Harley/blender:Fix113682 into blender-v4.0-release 2023-10-14 20:58:59 +02:00
3 changed files with 65 additions and 60 deletions
Showing only changes of commit cd047483e0 - Show all commits

View File

@ -2650,6 +2650,35 @@ static void node_draw_extra_info_row(const bNode &node,
}
}
static void node_draw_extra_info_panel_back(const bNode &node, const rctf &extra_info_rect)
{
const rctf &node_rect = node.runtime->totr;
rctf panel_back_rect = extra_info_rect;
/* Extend the panel behind hidden nodes to accomodate the large rounded corners. */
if (node.flag & NODE_HIDDEN) {
panel_back_rect.ymin = BLI_rctf_cent_y(&node_rect);
}
ColorTheme4f color;
if (node.flag & NODE_MUTED) {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color);
}
else {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.75f, color);
}
color.a -= 0.35f;
ColorTheme4f color_outline;
UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color_outline);
const float outline_width = U.pixelsize;
BLI_rctf_pad(&panel_back_rect, outline_width, outline_width);
UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
UI_draw_roundbox_4fv_ex(
&panel_back_rect, color, nullptr, 0.0f, color_outline, outline_width, BASIS_RAD);
}
static void node_draw_extra_info_panel(const Scene *scene,
TreeDrawContext &tree_draw_ctx,
const SpaceNode &snode,
@ -2670,11 +2699,8 @@ static void node_draw_extra_info_panel(const Scene *scene,
}
const rctf &rct = node.runtime->totr;
float color[4];
rctf extra_info_rect;
const float width = (node.width - 6.0f) * UI_SCALE_FAC;
if (node.is_frame()) {
extra_info_rect.xmin = rct.xmin;
extra_info_rect.xmax = rct.xmin + 95.0f * UI_SCALE_FAC;
@ -2682,62 +2708,40 @@ static void node_draw_extra_info_panel(const Scene *scene,
extra_info_rect.ymax = rct.ymin + 2.0f * UI_SCALE_FAC;
}
else {
float preview_height = 0;
rctf preview_rect;
const float padding = 3.0f * UI_SCALE_FAC;
extra_info_rect.xmin = rct.xmin + 3.0f * UI_SCALE_FAC;
extra_info_rect.xmax = extra_info_rect.xmin + width;
extra_info_rect.xmin = rct.xmin + padding;
extra_info_rect.xmax = rct.xmax - padding;
extra_info_rect.ymin = rct.ymax;
extra_info_rect.ymax = rct.ymax + extra_info_rows.size() * (20.0f * UI_SCALE_FAC);
float preview_height = 0.0f;
rctf preview_rect;
if (preview) {
const float width = BLI_rctf_size_x(&extra_info_rect);
if (preview->x > preview->y) {
const float preview_padding = 3.0f * UI_SCALE_FAC;
preview_height = (width - 2.0 * preview_padding) * float(preview->y) / float(preview->x) +
2.0 * preview_padding;
preview_rect.ymin = extra_info_rect.ymin + preview_padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - preview_padding;
preview_rect.xmin = extra_info_rect.xmin + preview_padding;
preview_rect.xmax = extra_info_rect.xmax - preview_padding;
preview_height = (width - 2.0f * padding) * float(preview->y) / float(preview->x) +
2.0f * padding;
preview_rect.ymin = extra_info_rect.ymin + padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - padding;
preview_rect.xmin = extra_info_rect.xmin + padding;
preview_rect.xmax = extra_info_rect.xmax - padding;
extra_info_rect.ymax += preview_height;
}
else {
const float preview_padding = 3.0f * UI_SCALE_FAC;
preview_height = width;
const float preview_width = (width - 2.0 * preview_padding) * float(preview->x) /
const float preview_width = (width - 2.0f * padding) * float(preview->x) /
float(preview->y) +
2.0 * preview_padding;
preview_rect.ymin = extra_info_rect.ymin + preview_padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - preview_padding;
preview_rect.xmin = extra_info_rect.xmin + preview_padding + (width - preview_width) / 2;
preview_rect.xmax = extra_info_rect.xmax - preview_padding - (width - preview_width) / 2;
2.0f * padding;
preview_rect.ymin = extra_info_rect.ymin + padding;
preview_rect.ymax = extra_info_rect.ymin + preview_height - padding;
preview_rect.xmin = extra_info_rect.xmin + padding + (width - preview_width) / 2;
preview_rect.xmax = extra_info_rect.xmax - padding - (width - preview_width) / 2;
extra_info_rect.ymax += preview_height;
}
}
if (node.flag & NODE_MUTED) {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.2f, color);
}
else {
UI_GetThemeColorBlend4f(TH_BACK, TH_NODE, 0.75f, color);
}
color[3] -= 0.35f;
UI_draw_roundbox_corner_set(
UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT &
((rct.xmax) > extra_info_rect.xmax ? ~UI_CNR_BOTTOM_RIGHT : UI_CNR_ALL));
UI_draw_roundbox_4fv(&extra_info_rect, true, BASIS_RAD, color);
/* Draw outline. */
const float outline_width = 1.0f;
extra_info_rect.xmin -= outline_width;
extra_info_rect.xmax += outline_width;
extra_info_rect.ymin -= outline_width;
extra_info_rect.ymax += outline_width;
UI_GetThemeColorBlendShade4fv(TH_BACK, TH_NODE, 0.4f, -20, color);
UI_draw_roundbox_corner_set(
UI_CNR_ALL & ~UI_CNR_BOTTOM_LEFT &
((rct.xmax) > extra_info_rect.xmax ? ~UI_CNR_BOTTOM_RIGHT : UI_CNR_ALL));
UI_draw_roundbox_4fv(&extra_info_rect, false, BASIS_RAD, color);
node_draw_extra_info_panel_back(node, extra_info_rect);
if (preview) {
node_draw_preview(scene, preview, &preview_rect);

View File

@ -162,8 +162,7 @@ static void createTransMeshVertCData(bContext * /*C*/, TransInfo *t)
if (mirror_data.vert_map) {
tc->data_mirror_len = mirror_data.mirror_elem_len;
tc->data_mirror = static_cast<TransDataMirror *>(
MEM_mallocN(mirror_data.mirror_elem_len * sizeof(*tc->data_mirror), __func__));
tc->data_mirror = MEM_cnew_array<TransDataMirror>(mirror_data.mirror_elem_len, __func__);
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, a) {
if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) {

View File

@ -161,25 +161,27 @@ static void add_instances_from_component(
bke::MutableAttributeAccessor dst_attributes = dst_component.attributes_for_write();
for (const auto item : attributes_to_propagate.items()) {
const AttributeIDRef &id = item.key;
const bke::GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_POINT);
const eCustomDataType data_type = item.value.data_type;
const bke::GAttributeReader src = src_attributes.lookup(id, ATTR_DOMAIN_POINT, data_type);
if (!src) {
/* Domain interpolation can fail if the source domain is empty. */
continue;
}
const eCustomDataType type = bke::cpp_type_to_custom_data_type(src.varray.type());
if (src.varray.size() == dst_component.instances_num() && src.sharing_info &&
src.varray.is_span()) {
const bke::AttributeInitShared init(src.varray.get_internal_span().data(),
*src.sharing_info);
dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, type, init);
}
else {
GSpanAttributeWriter dst = dst_attributes.lookup_or_add_for_write_only_span(
id, ATTR_DOMAIN_INSTANCE, type);
array_utils::gather(src.varray, selection, dst.span.slice(start_len, select_len));
dst.finish();
if (!dst_attributes.contains(id)) {
if (src.varray.size() == dst_component.instances_num() && src.sharing_info &&
src.varray.is_span()) {
const bke::AttributeInitShared init(src.varray.get_internal_span().data(),
*src.sharing_info);
dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, data_type, init);
continue;
}
dst_attributes.add(id, ATTR_DOMAIN_INSTANCE, data_type, bke::AttributeInitConstruct());
}
GSpanAttributeWriter dst = dst_attributes.lookup_for_write_span(id);
array_utils::gather(src.varray, selection, dst.span.slice(start_len, select_len));
dst.finish();
}
}