Fix GUI bugs in FLTK port, per Xavier Thomas's forum post:

"There was some small but annoying bugs with the FLTK port:
-cursor disappear sometimes
-not all the area of the windows (graphic and text windows) is accessible
by the mouse after a re-size
-input widget for editing constraints value are not correctly placed"
pull/3/head
Jonathan Westhues 2014-05-11 15:43:03 -07:00
parent f5297093c0
commit e587d0ebee
3 changed files with 76 additions and 39 deletions

View File

@ -359,45 +359,6 @@ int64_t GetUnixTime(void)
return (int64_t)ret; return (int64_t)ret;
} }
void ShowTextEditControl(int x, int y, char *s)
{
if(GraphicsEditControlIsVisible()) return;
// Note: TextEditControl->position() does NOT set (x,y) position!
TextEditControl->resize(x, y, TextEditControl->w(), TextEditControl->h());
if(s) TextEditControl->value(s);
TextEditControl->show();
}
void HideTextEditControl(void)
{
TextEditControl->hide();
}
bool TextEditControlIsVisible(void)
{
return TextEditControl->visible();
}
void ShowGraphicsEditControl(int x, int y, char *s)
{
if(GraphicsEditControlIsVisible()) return;
GraphicsEditControl->position(x, y);
GraphicsEditControl->value(s);
GraphicsEditControl->show();
}
void HideGraphicsEditControl(void)
{
GraphicsEditControl->hide();
}
bool GraphicsEditControlIsVisible(void)
{
return GraphicsEditControl->visible();
}
class Graphics_Gl_Window : public Fl_Gl_Window_Group class Graphics_Gl_Window : public Fl_Gl_Window_Group
{ {
public: public:
@ -713,6 +674,73 @@ void Text_Gl_Window::dummy(void)
// sop to Clang++'s -Wweak-vtables warning // sop to Clang++'s -Wweak-vtables warning
} }
void ShowTextEditControl(int x, int y, char *s)
{
if(GraphicsEditControlIsVisible()) return;
// Note: TextEditControl->position() does NOT set (x,y) position!
// It changes the cursor postion in the input widget
// Use the :: operator to avoid confusion
TextEditControl->Fl_Widget::position(x, y);
if(s) TextEditControl->value(s);
TextEditControl->show();
// Grab focus and select all to ease editing
TextEditControl->take_focus();
TextEditControl->Fl_Input::position(TextEditControl->size());
TextEditControl->mark(0);
}
void HideTextEditControl(void)
{
// return focus to the GL window before hiding the widget
// this avoid the disapparition of the mouse pointer if it was over the widget
TextGlWnd->take_focus();
TextEditControl->hide();
}
bool TextEditControlIsVisible(void)
{
return TextEditControl->visible();
}
void ShowGraphicsEditControl(int x, int y, char *s)
{
if(GraphicsEditControlIsVisible()) return;
// Convert to ij (vs. xy) style coordinates,
// and compensate for the input widget height due to inverse coord
x = x + GraphicsGlWnd->w()/2;
y = -y + GraphicsGlWnd->h()/2 - GraphicsEditControl->h();
// Use of the :: 0perator to avoid confusion with the Fl_input positon metod.
GraphicsEditControl->Fl_Widget::position(x, y);
GraphicsEditControl->value(s);
GraphicsEditControl->show();
// Grab focus and select all to ease editing
GraphicsEditControl->take_focus();
GraphicsEditControl->Fl_Input::position(GraphicsEditControl->size());
GraphicsEditControl->mark(0);
}
void HideGraphicsEditControl(void)
{
// return focus to the GL window before hiding the widget
// this avoid the disapparition of the mouse pointer if it was over the widget
GraphicsGlWnd->take_focus();
GraphicsEditControl->hide();
}
bool GraphicsEditControlIsVisible(void)
{
return GraphicsEditControl->visible();
}
void InvalidateText(void) void InvalidateText(void)
{ {
TextGlWnd->redraw(); TextGlWnd->redraw();

View File

@ -82,6 +82,9 @@ public:
*/ */
virtual int handle_gl(int event); virtual int handle_gl(int event);
// override resize
virtual void resize(int x, int y,int w, int h);
protected: protected:
void draw(void); void draw(void);

View File

@ -169,6 +169,12 @@ int Fl_Gl_Window_Group::handle_gl(int event) {
return 0; return 0;
} }
void Fl_Gl_Window_Group::resize(int x, int y,int w, int h)
{
glstandin->resize(x,y,w,h);
Fl_Window::resize(x,y,w,h);
}
void Fl_Gl_Window_Group::flush(void) { void Fl_Gl_Window_Group::flush(void) {
// Fl_Window::make_current() does this, but not // Fl_Window::make_current() does this, but not
// Fl_Gl_Window::make_current(), and we can't override make_current() // Fl_Gl_Window::make_current(), and we can't override make_current()