Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_edit_text.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_edit_text.c.
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2019 Blender Foundation. */ | * Copyright 2019 Blender Foundation. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup draw_engine | * \ingroup draw_engine | ||||
| */ | */ | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "BKE_vfont.h" | #include "BKE_vfont.h" | ||||
| #include "DNA_curve_types.h" | #include "DNA_curve_types.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata) | void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| View3D *v3d = draw_ctx->v3d; | View3D *v3d = draw_ctx->v3d; | ||||
| DRWShadingGroup *grp; | DRWShadingGroup *grp; | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | static void v2_quad_corners_to_mat4(const float corners[4][2], float r_mat[4][4]) | ||||
| copy_v2_v2(r_mat[3], corners[0]); | copy_v2_v2(r_mat[3], corners[0]); | ||||
| add_v2_v2(r_mat[3], r_mat[0]); | add_v2_v2(r_mat[3], r_mat[0]); | ||||
| add_v2_v2(r_mat[3], r_mat[1]); | add_v2_v2(r_mat[3], r_mat[1]); | ||||
| } | } | ||||
| static void edit_text_cache_populate_select(OVERLAY_Data *vedata, Object *ob) | static void edit_text_cache_populate_select(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| const Curve *cu = ob->data; | const Curve *cu = static_cast<Curve *>(ob->data); | ||||
| EditFont *ef = cu->editfont; | EditFont *ef = cu->editfont; | ||||
| float final_mat[4][4], box[4][2]; | float final_mat[4][4], box[4][2]; | ||||
| struct GPUBatch *geom = DRW_cache_quad_get(); | struct GPUBatch *geom = DRW_cache_quad_get(); | ||||
| for (int i = 0; i < ef->selboxes_len; i++) { | for (int i = 0; i < ef->selboxes_len; i++) { | ||||
| EditFontSelBox *sb = &ef->selboxes[i]; | EditFontSelBox *sb = &ef->selboxes[i]; | ||||
| float selboxw; | float selboxw; | ||||
| Show All 28 Lines | for (int i = 0; i < ef->selboxes_len; i++) { | ||||
| DRW_shgroup_call_obmat(pd->edit_text_selection_grp, geom, final_mat); | DRW_shgroup_call_obmat(pd->edit_text_selection_grp, geom, final_mat); | ||||
| } | } | ||||
| } | } | ||||
| static void edit_text_cache_populate_cursor(OVERLAY_Data *vedata, Object *ob) | static void edit_text_cache_populate_cursor(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| const Curve *cu = ob->data; | const Curve *cu = static_cast<Curve *>(ob->data); | ||||
| EditFont *edit_font = cu->editfont; | EditFont *edit_font = cu->editfont; | ||||
| float(*cursor)[2] = edit_font->textcurs; | float(*cursor)[2] = edit_font->textcurs; | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| v2_quad_corners_to_mat4(cursor, mat); | v2_quad_corners_to_mat4(cursor, mat); | ||||
| mul_m4_m4m4(mat, ob->obmat, mat); | mul_m4_m4m4(mat, ob->obmat, mat); | ||||
| struct GPUBatch *geom = DRW_cache_quad_get(); | struct GPUBatch *geom = DRW_cache_quad_get(); | ||||
| DRW_shgroup_call_obmat(pd->edit_text_cursor_grp, geom, mat); | DRW_shgroup_call_obmat(pd->edit_text_cursor_grp, geom, mat); | ||||
| } | } | ||||
| static void edit_text_cache_populate_boxes(OVERLAY_Data *vedata, Object *ob) | static void edit_text_cache_populate_boxes(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); | OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); | ||||
| const Curve *cu = ob->data; | const Curve *cu = static_cast<Curve *>(ob->data); | ||||
| for (int i = 0; i < cu->totbox; i++) { | for (int i = 0; i < cu->totbox; i++) { | ||||
| TextBox *tb = &cu->tb[i]; | TextBox *tb = &cu->tb[i]; | ||||
| const bool is_active = (i == (cu->actbox - 1)); | const bool is_active = (i == (cu->actbox - 1)); | ||||
| float *color = is_active ? G_draw.block.color_active : G_draw.block.color_wire; | float *color = is_active ? G_draw.block.color_active : G_draw.block.color_wire; | ||||
| if ((tb->w != 0.0f) || (tb->h != 0.0f)) { | if ((tb->w != 0.0f) || (tb->h != 0.0f)) { | ||||
| float vecs[4][3]; | float vecs[4][3]; | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||