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)
203 EditFont *edit_font = cu.editfont;
206 v2_quad_corners_to_mat4(cursor, mat);
207 ResourceHandleRange res_handle = manager.resource_handle(ob_to_world * mat);
209 cursor_ps_->draw(quad, res_handle);
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;
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)) {
226 cu.xof + tb.x, cu.yof + tb.y + edit_font->font_size_eval, 0.001);
235 box_line_buf_.append(vecs[j], vecs[(j + 1) % 4], color);
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