SolveSpace Logo SOLVESPACE -- parametric 2d/3d CAD
Examples
Tutorials
Features
Download
Reference
Technology
Library
Forum
Contact
USER FORUM

(you are viewing a thread; or go back to list of threads)

Some fixes for the fltk port (by Xavier Thomas)
Hi,

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

Here is a small patch to fix those problems.


diff --git a/src/fltk/fltkmain.cpp b/src/fltk/fltkmain.cpp
index 37bf02c..ad0e81a 100644
--- a/src/fltk/fltkmain.cpp
+++ b/src/fltk/fltkmain.cpp
@@ -359,45 +359,6 @@ int64_t GetUnixTime(void)
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
{
public:
@@ -713,6 +674,73 @@ void Text_Gl_Window::dummy(void)
// 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)
{
TextGlWnd->redraw();
diff --git a/src/fltk/xFl_Gl_Window_Group.H b/src/fltk/xFl_Gl_Window_Group.H
index 05d2abd..01c7182 100644
--- a/src/fltk/xFl_Gl_Window_Group.H
+++ b/src/fltk/xFl_Gl_Window_Group.H
@@ -82,6 +82,9 @@ public:
*/
virtual int handle_gl(int event);

+ // override resize
+ virtual void resize(int x, int y,int w, int h);
+
protected:

void draw(void);
diff --git a/src/fltk/xFl_Gl_Window_Group.cxx b/src/fltk/xFl_Gl_Window_Group.cxx
index 8b62a68..0483af5 100644
--- a/src/fltk/xFl_Gl_Window_Group.cxx
+++ b/src/fltk/xFl_Gl_Window_Group.cxx
@@ -169,6 +169,12 @@ int Fl_Gl_Window_Group::handle_gl(int event) {
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) {
// Fl_Window::make_current() does this, but not
// Fl_Gl_Window::make_current(), and we can't override make_current()
Sat May 10 2014, 19:56:38
(no subject) (by Jonathan Westhues)
Thanks, pushed to gitorious. If you find anything else, then please feel free to submit merge requests there.
Sun May 11 2014, 18:49:57
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):
© 2008-2022 SolveSpace contributors. Most recent update June 2 2022.