32 View view_edit_text = {
"view_edit_text"};
37 gpu::Batch *quad =
nullptr;
39 gpu::Batch *quad_wire =
nullptr;
47 box_line_buf_.clear();
53 quad = res.shapes.quad_solid.get();
54 quad_wire = res.shapes.quad_wire.get();
66 auto &sub = ps_.sub(
"text_selection");
67 sub.state_set(default_state,
state.clipping_plane_count);
68 sub.shader_set(res.shaders->uniform_color.get());
71 sub.push_constant(
"ucolor",
color);
77 auto &sub = ps_.sub(
"highlight_text_selection");
80 state.clipping_plane_count);
81 sub.shader_set(res.shaders->uniform_color.get());
84 sub.push_constant(
"ucolor",
color);
85 selection_highlight_ps_ = ⊂
90 auto &sub = ps_.sub(
"text_cursor");
91 sub.state_set(default_state,
state.clipping_plane_count);
92 sub.shader_set(res.shaders->uniform_color.get());
93 sub.state_set(default_state,
state.clipping_plane_count);
96 sub.push_constant(
"ucolor",
color);
105 const State & )
final
112 add_select(manager, cu, ob_ref.object->object_to_world());
113 add_cursor(manager, cu, ob_ref.object->object_to_world());
114 add_boxes(res, cu, ob_ref.object->object_to_world());
125 auto &sub_pass = ps_.sub(
"text_boxes");
128 state.clipping_plane_count);
129 sub_pass.shader_set(res.shaders->extra_wire.get());
130 box_line_buf_.end_sync(sub_pass);
144 manager.submit(ps_, view_edit_text);
150 static void v2_quad_corners_to_mat4(
const float4x2 &corners,
float4x4 &r_mat)
152 const float2 &origin = corners[0];
157 float4(half_size_y, 0.0f, 0.0f),
158 float4(0.0f, 0.0f, 1.0f, 0.0f),
159 float4(origin + half_size_x + half_size_y, 0.0f, 1.0f));
184 box[1] =
float2(sb->
x + selboxw, sb->
y);
190 box[1] = mat[0] * selboxw +
float2(&sb->
x);
191 box[3] = mat[1] * sb->
h +
float2(&sb->
x);
194 v2_quad_corners_to_mat4(box, mat);
195 ResourceHandleRange res_handle = manager.
resource_handle(ob_to_world * mat);
196 selection_ps_->
draw(
quad, res_handle);
197 selection_highlight_ps_->
draw(
quad, res_handle);
201 void add_cursor(Manager &manager,
const Curve &cu,
const float4x4 &ob_to_world)
206 v2_quad_corners_to_mat4(cursor, mat);
207 ResourceHandleRange res_handle = manager.resource_handle(ob_to_world * mat);
213 cursor_ps_->
draw(quad_wire, res_handle);
216 void add_boxes(
const Resources &res,
const Curve &cu,
const float4x4 &ob_to_world)
218 const EditFont *edit_font = cu.
editfont;
219 for (
const int i : IndexRange(cu.
totbox)) {
221 const bool is_active = (
i == (cu.
actbox - 1));
222 const float4 &color = is_active ? res.theme.colors.active_object : res.theme.colors.wire;
224 if ((tb.
w != 0.0f) || (tb.
h != 0.0f)) {
231 for (
const int j : IndexRange(4)) {
234 for (
const int j : IndexRange(4)) {
235 box_line_buf_.
append(vecs[j], vecs[(j + 1) % 4], color);
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
T & DRW_object_get_data_for_drawing(const Object &object)
void GPU_framebuffer_bind(blender::gpu::FrameBuffer *fb)
@ TH_WIDGET_TEXT_HIGHLIGHT
@ TH_WIDGET_TEXT_SELECTION
void UI_GetThemeColor4fv(int colorid, float col[4])
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
ResourceHandleRange resource_handle(const ObjectRef &ref, float inflate_bounds=0.0f)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIndexRange res_index={}, uint custom_id=0)
detail::PassBase< command::DrawCommandBuf > Sub
Text(SelectionType selection_type)
void begin_sync(Resources &res, const State &state) final
void draw(Framebuffer &framebuffer, Manager &manager, View &view) final
void edit_object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &res, const State &) final
void end_sync(Resources &res, const State &state) final
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
@ DRW_STATE_DEPTH_GREATER_EQUAL
@ DRW_STATE_DEPTH_LESS_EQUAL
blender::gpu::Batch * quad
select::SelectionType SelectionType
detail::Pass< command::DrawCommandBuf > PassSimple
MatT from_rotation(const RotationT &rotation)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 2, 2 > float2x2
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< float, 2 > float2
MatBase< float, 4, 2 > float4x2
MatBase< float, 4, 3 > float4x3
VecBase< float, 3 > float3
struct EditFont * editfont
EditFontSelBox * selboxes
blender::float2 textcurs[4]
float4x4 winmat_polygon_offset(const float4x4 &winmat, float offset)
void append(const float3 &start, const float3 &end, const float4 &color, select::ID select_id=select::SelectMap::select_invalid_id())