30 View view_edit_text = {
"view_edit_text"};
35 gpu::Batch *quad =
nullptr;
37 gpu::Batch *quad_wire =
nullptr;
45 box_line_buf_.clear();
51 quad = res.shapes.quad_solid.get();
52 quad_wire = res.shapes.quad_wire.get();
64 auto &sub = ps_.sub(
"text_selection");
65 sub.state_set(default_state,
state.clipping_plane_count);
66 sub.shader_set(res.shaders->uniform_color.get());
69 sub.push_constant(
"ucolor",
color);
75 auto &sub = ps_.sub(
"highlight_text_selection");
78 state.clipping_plane_count);
79 sub.shader_set(res.shaders->uniform_color.get());
82 sub.push_constant(
"ucolor",
color);
83 selection_highlight_ps_ = ⊂
88 auto &sub = ps_.sub(
"text_cursor");
89 sub.state_set(default_state,
state.clipping_plane_count);
90 sub.shader_set(res.shaders->uniform_color.get());
91 sub.state_set(default_state,
state.clipping_plane_count);
94 sub.push_constant(
"ucolor",
color);
103 const State & )
final
110 add_select(manager, cu, ob_ref.object->object_to_world());
111 add_cursor(manager, cu, ob_ref.object->object_to_world());
112 add_boxes(res, cu, ob_ref.object->object_to_world());
123 auto &sub_pass = ps_.sub(
"text_boxes");
126 state.clipping_plane_count);
127 sub_pass.shader_set(res.shaders->extra_wire.get());
128 box_line_buf_.end_sync(sub_pass);
142 manager.submit(ps_, view_edit_text);
148 static void v2_quad_corners_to_mat4(
const float4x2 &corners,
float4x4 &r_mat)
150 const float2 &origin = corners[0];
155 float4(half_size_y, 0.0f, 0.0f),
156 float4(0.0f, 0.0f, 1.0f, 0.0f),
157 float4(origin + half_size_x + half_size_y, 0.0f, 1.0f));
180 if (sb->
rot == 0.0f) {
182 box[1] =
float2(sb->
x + selboxw, sb->
y);
188 box[1] = mat[0] * selboxw +
float2(&sb->
x);
189 box[3] = mat[1] * sb->
h +
float2(&sb->
x);
192 v2_quad_corners_to_mat4(box, mat);
194 selection_ps_->
draw(
quad, res_handle);
195 selection_highlight_ps_->
draw(
quad, res_handle);
199 void add_cursor(Manager &manager,
const Curve &cu,
const float4x4 &ob_to_world)
204 v2_quad_corners_to_mat4(cursor, mat);
205 ResourceHandle res_handle = manager.resource_handle(ob_to_world * mat);
211 cursor_ps_->
draw(quad_wire, res_handle);
214 void add_boxes(
const Resources &res,
const Curve &cu,
const float4x4 &ob_to_world)
216 const EditFont *edit_font = cu.
editfont;
217 for (
const int i : IndexRange(cu.
totbox)) {
219 const bool is_active = (
i == (cu.
actbox - 1));
220 const float4 &color = is_active ? res.theme.colors.active_object : res.theme.colors.wire;
222 if ((tb.
w != 0.0f) || (tb.
h != 0.0f)) {
229 for (
const int j : IndexRange(4)) {
232 for (
const int j : IndexRange(4)) {
233 box_line_buf_.
append(vecs[j], vecs[(j + 1) % 4], color);
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
void GPU_framebuffer_bind(GPUFrameBuffer *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, ResourceHandleRange handle={0}, 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
Mesh & DRW_object_get_data_for_drawing(const Object &object)
#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
float4x4 winmat_polygon_offset(float4x4 winmat, float offset)
void append(const float3 &start, const float3 &end, const float4 &color, select::ID select_id=select::SelectMap::select_invalid_id())