Skip to content

Commit

Permalink
Fixed GLTextShape editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Mar 29, 2024
1 parent df2abd3 commit d52fea1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mrv2/lib/mrvGL/mrvGLDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// Set it draw selection rectangle with GL_LINE_STRIP
#define USE_ONE_PIXEL_LINES 1

// Set it to avoid Window's FLTK childrens from being drawn
// #define NO_GL_WINDOW_CHILDREN 1

// Set it to draw text shapes with opengl2 instead of
// tlRender's OpenGL 3 freetype routines
#define USE_OPENGL2 1
Expand Down
2 changes: 2 additions & 0 deletions mrv2/lib/mrvGL/mrvGLViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,9 @@ namespace mrv
_drawGL2TextShapes();
Fl_Gl_Window::draw_end(); // Restore GL state
#else
# ifndef NO_GL_WINDOW_CHILDREN
Fl_Gl_Window::draw();
# endif
#endif

#ifdef DEBUG_SPEED
Expand Down
23 changes: 21 additions & 2 deletions mrv2/lib/mrvGL/mrvTimelineViewportEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ namespace mrv
draw::Point pnt(_getRasterf());

shape->pts.push_back(pnt); // needed

annotation->push_back(shape);
// Calculate offset from corner due to cross and the bottom of
// the font.
Expand Down Expand Up @@ -1471,6 +1472,9 @@ namespace mrv
const auto& renderSize = getRenderSize();
float pct = renderSize.h / 1024.F;

const math::Vector2i offset(
kCrossSize + 2, kCrossSize + fl_height() - fl_descent());

#ifdef USE_OPENGL2
auto shape = dynamic_cast<GL2TextShape*>(s.get());
if (!shape)
Expand All @@ -1481,8 +1485,6 @@ namespace mrv
shape->fontSize * shape->viewZoom / devicePixelRatio;
fl_font(shape->font, fontsize);

const math::Vector2i offset(
kCrossSize + 2, kCrossSize + fl_height() - fl_descent());
math::Vector2i pos(
shape->pts[0].x * shape->viewZoom + p.viewPos.x,
shape->pts[0].y * shape->viewZoom + p.viewPos.y);
Expand All @@ -1498,6 +1500,23 @@ namespace mrv
w->textsize(shape->fontSize);
w->value(shape->text.c_str(), shape->text.size());
w->recalc();
#else
auto shape = dynamic_cast<GLTextShape*>(s.get());
if (!shape)
return;

math::Vector2i pos(
shape->pts[0].x + p.viewPos.x, -shape->pts[0].y - p.viewPos.y);

pos.x -= offset.x;
pos.y -= offset.y;

auto w = new MultilineInput(pos.x, pos.y, 20, 30 * pct * p.viewZoom);
w->take_focus();
w->fontFamily = shape->fontFamily;
w->textsize(shape->fontSize);
w->value(shape->text.c_str(), shape->text.size());
w->recalc();
#endif
Fl_Color fltk_color = fl_rgb_color(
shape->color.r * 255.F, shape->color.g * 255.F,
Expand Down

0 comments on commit d52fea1

Please sign in to comment.