Skip to content
Snippets Groups Projects
Commit c0731dbc authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

first try at implementing better resize of message browser

parent 36945c13
No related branches found
No related tags found
No related merge requests found
......@@ -2653,10 +2653,9 @@ static void message_browser_cb(Fl_Widget *w, void *data)
g->copySelectedMessagesToClipboard();
}
// This dummy box class permits to define a box widget that will not
// eat the FL_ENTER/FL_LEAVE events (the new Box widget in fltk > 1.1
// does that, so that gl->handle() was not called when the mouse
// moved)
// This dummy box class permits to define a box widget that will not eat the
// FL_ENTER/FL_LEAVE events (the box widget in fltk > 1.1 does that, so that
// gl->handle() was not called when the mouse moved)
class dummyBox : public Fl_Box {
private:
int handle(int){ return 0; } // always!
......@@ -2664,6 +2663,27 @@ class dummyBox : public Fl_Box {
dummyBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x, y, w, h, l) {}
};
// The main graphic window has a special resize behaviour forcing the message
// tile to always keep its height
class mainWindowSpecialResize : public mainWindow {
public:
mainWindowSpecialResize(int w, int h, bool nonModal, const char *l=0)
: mainWindow(w, h, nonModal, l) {}
virtual void resize(int X,int Y,int W,int H)
{
bool special = (shown() && this == FlGui::instance()->graph[0]->getWindow());
int old_mh = 0;
if(special)
old_mh = FlGui::instance()->graph[0]->getMessageHeight();
Fl_Window::resize(X, Y, W, H);
const int minimum_non_message_height = 100;
if(special && old_mh < h() - minimum_non_message_height){
int mh = FlGui::instance()->graph[0]->getMessageHeight();
FlGui::instance()->graph[0]->resizeMessages(old_mh - mh);
}
}
};
graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu)
: _autoScrollMessages(true)
{
......@@ -2713,7 +2733,7 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu)
// the graphic window should be a "normal" window (neither modal nor
// non-modal)
if(main){
_win = new mainWindow(width, height, false);
_win = new mainWindowSpecialResize(width, height, false);
_win->callback(file_quit_cb);
}
else{
......@@ -2820,9 +2840,9 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu)
_butt[i]->align(FL_ALIGN_CENTER | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
}
x += 2;
x += 4;
_label = new Fl_Progress(x, mh + glheight + mheight + 2, width - x, sht);
_label->box(FL_THIN_DOWN_BOX);
_label->box(FL_FLAT_BOX);
_label->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE | FL_ALIGN_CLIP);
_label->color(FL_BACKGROUND_COLOR, FL_DARK2); // FL_DARK_GREEN
......@@ -2878,7 +2898,7 @@ graphicWindow::graphicWindow(bool main, int numTiles, bool detachedMenu)
if(main){
_browser = new Fl_Browser(twidth, mh + glheight, glwidth, mheight);
_browser->box(FL_THIN_DOWN_BOX);
_browser->box(GMSH_SIMPLE_TOP_BOX);
_browser->textfont(FL_COURIER);
_browser->textsize(FL_NORMAL_SIZE - 1);
_browser->type(FL_MULTI_BROWSER);
......@@ -3189,6 +3209,7 @@ int graphicWindow::getGlWidth()
void graphicWindow::setGlWidth(int w)
{
_win->size(w, _win->h());
_win->redraw();
// workaround resizing bug on Mac
_win->size_range(_minWidth, _minHeight);
}
......@@ -3197,7 +3218,8 @@ void graphicWindow::setGlHeight(int h)
{
int hh = h + _bottom->h();
if(_bar) hh += _bar->h();
_win->size(_win->w(), h);
_win->size(_win->w(), hh);
_win->redraw();
// workaround resizing bug on Mac
_win->size_range(_minWidth, _minHeight);
}
......@@ -3243,6 +3265,12 @@ void graphicWindow::showHideMessages()
}
int graphicWindow::getMessageHeight()
{
if(!_browser) return 0;
return _browser->h();
}
int graphicWindow::getSavedMessageHeight()
{
if(!_browser) return 0;
if(!_browser->h()) return _savedMessageHeight;
......
......@@ -82,6 +82,7 @@ class graphicWindow{
void saveMessages(const char *filename);
void copySelectedMessagesToClipboard();
int getMessageHeight();
int getSavedMessageHeight();
void fillRecentHistoryMenu();
};
......
......@@ -12,8 +12,13 @@
// Derive the main window from Fl_Window (it shows up faster that way)
class mainWindow : public Fl_Window {
private:
int handle(int event)
public:
mainWindow(int w, int h, bool nonModal, const char *l=0)
: Fl_Window(w, h, l)
{
if(nonModal) set_non_modal();
}
virtual int handle(int event)
{
switch (event) {
case FL_SHORTCUT:
......@@ -33,13 +38,11 @@ class mainWindow : public Fl_Window {
}
return Fl_Window::handle(event);
}
public:
mainWindow(int w, int h, bool nonModal, const char *l=0)
: Fl_Window(w, h, l)
virtual void resize(int X,int Y,int W,int H)
{
if(nonModal) set_non_modal();
Fl_Window::resize(X, Y, W, H);
}
void show()
virtual void show()
{
if(non_modal() && !shown()) Fl_Window::show(); // fix ordering
Fl_Window::show();
......
......@@ -12,8 +12,13 @@
// Derive special windows from Fl_Double_Window to correctly process
// the OS-specific shorcuts (Esc & Cmd-w on Mac, Alt+F4 on Windows)
class paletteWindow : public Fl_Double_Window {
private:
int handle(int event)
public:
paletteWindow(int w, int h, bool nonModal, const char *l=0)
: Fl_Double_Window(w, h, l)
{
if(nonModal) set_non_modal();
}
virtual int handle(int event)
{
switch (event) {
case FL_SHORTCUT:
......@@ -32,13 +37,7 @@ class paletteWindow : public Fl_Double_Window {
}
return Fl_Double_Window::handle(event);
}
public:
paletteWindow(int w, int h, bool nonModal, const char *l=0)
: Fl_Double_Window(w, h, l)
{
if(nonModal) set_non_modal();
}
void show()
virtual void show()
{
if(non_modal() && !shown()) Fl_Double_Window::show(); // fix ordering
Fl_Double_Window::show();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment