#887: Fixes FLTK file chooser not releasing preview image.
...when hidden
This commit is contained in:
parent
be1c96b98a
commit
5c90938aa3
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
// Copyright 1998-2024 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -145,7 +145,6 @@ public:
|
||||
const char * filter();
|
||||
int filter_value();
|
||||
void filter_value(int f);
|
||||
void hide();
|
||||
void iconsize(uchar s);
|
||||
uchar iconsize();
|
||||
void label(const char *l);
|
||||
@ -161,6 +160,7 @@ public:
|
||||
void rescan();
|
||||
void rescan_keep_filename();
|
||||
void show();
|
||||
void hide();
|
||||
int shown();
|
||||
void textcolor(Fl_Color c);
|
||||
Fl_Color textcolor();
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
// Copyright 1998-2024 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -29,8 +29,7 @@
|
||||
void Fl_File_Chooser::cb_window_i(Fl_Double_Window*, void*) {
|
||||
fileName->value("");
|
||||
fileList->deselect();
|
||||
Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
|
||||
window->hide();
|
||||
hide();
|
||||
}
|
||||
void Fl_File_Chooser::cb_window(Fl_Double_Window* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->user_data()))->cb_window_i(o,v);
|
||||
@ -105,7 +104,7 @@ void Fl_File_Chooser::cb_fileName(Fl_File_Input* o, void* v) {
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::cb_okButton_i(Fl_Return_Button*, void*) {
|
||||
window->hide();
|
||||
hide();
|
||||
|
||||
// Do any callback that is registered...
|
||||
if (callback_)
|
||||
@ -118,8 +117,7 @@ void Fl_File_Chooser::cb_okButton(Fl_Return_Button* o, void* v) {
|
||||
void Fl_File_Chooser::cb_cancelButton_i(Fl_Button*, void*) {
|
||||
fileName->value("");
|
||||
fileList->deselect();
|
||||
Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
|
||||
window->hide();
|
||||
hide();
|
||||
}
|
||||
void Fl_File_Chooser::cb_cancelButton(Fl_Button* o, void* v) {
|
||||
((Fl_File_Chooser*)(o->parent()->parent()->parent()->user_data()))->cb_cancelButton_i(o,v);
|
||||
@ -222,19 +220,19 @@ Fl_File_Chooser::Fl_File_Chooser(const char *pathname, const char *pattern, int
|
||||
} // Fl_Tile* o
|
||||
{ Fl_Group* o = new Fl_Group(10, 275, 470, 95);
|
||||
{ Fl_Group* o = new Fl_Group(10, 275, 470, 20);
|
||||
{ previewButton = new Fl_Check_Button(10, 275, 73, 20, "Preview");
|
||||
{ previewButton = new Fl_Check_Button(10, 275, 105, 20, "Preview");
|
||||
previewButton->shortcut(0x80070);
|
||||
previewButton->down_box(FL_DOWN_BOX);
|
||||
previewButton->value(1);
|
||||
previewButton->callback((Fl_Callback*)cb_previewButton);
|
||||
previewButton->label(preview_label);
|
||||
} // Fl_Check_Button* previewButton
|
||||
{ showHiddenButton = new Fl_Check_Button(115, 275, 165, 20, "Show hidden files");
|
||||
{ showHiddenButton = new Fl_Check_Button(115, 275, 140, 20, "Show hidden files");
|
||||
showHiddenButton->down_box(FL_DOWN_BOX);
|
||||
showHiddenButton->callback((Fl_Callback*)cb_showHiddenButton);
|
||||
showHiddenButton->label(hidden_label);
|
||||
} // Fl_Check_Button* showHiddenButton
|
||||
{ Fl_Box* o = new Fl_Box(115, 275, 365, 20);
|
||||
{ Fl_Box* o = new Fl_Box(255, 275, 225, 20);
|
||||
Fl_Group::current()->resizable(o);
|
||||
} // Fl_Box* o
|
||||
o->end();
|
||||
@ -364,10 +362,6 @@ void Fl_File_Chooser::filter_value(int f) {
|
||||
showChoiceCB();
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::hide() {
|
||||
window->hide();
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::iconsize(uchar s) {
|
||||
fileList->iconsize(s);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ code_name {.cxx}
|
||||
comment {//
|
||||
// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2021 by Bill Spitzak and others.
|
||||
// Copyright 1998-2024 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software. Distribution and use rights are outlined in
|
||||
// the file "COPYING" which should have been included with this file. If this
|
||||
@ -76,7 +76,7 @@ Determines the type of file chooser presented to the user.
|
||||
}
|
||||
decl {void update_preview();} {private local
|
||||
}
|
||||
Function {Fl_File_Chooser(const char *pathname, const char *pattern, int type_val, const char *title)} {open selected
|
||||
Function {Fl_File_Chooser(const char *pathname, const char *pattern, int type_val, const char *title)} {open
|
||||
} {
|
||||
code {if (!prefs_) {
|
||||
prefs_ = new Fl_Preferences(Fl_Preferences::CORE_USER, "fltk.org", "filechooser");
|
||||
@ -86,10 +86,9 @@ Determines the type of file chooser presented to the user.
|
||||
label {Choose File}
|
||||
callback {fileName->value("");
|
||||
fileList->deselect();
|
||||
Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
|
||||
window->hide();} open
|
||||
private xywh {0 0 490 380} type Double hide resizable
|
||||
code0 {if (title) window->label(title);} modal
|
||||
hide();} open selected
|
||||
private xywh {467 276 490 380} type Double resizable
|
||||
code0 {if (title) window->label(title);} modal visible
|
||||
} {
|
||||
Fl_Group {} {open
|
||||
private xywh {10 10 470 25}
|
||||
@ -140,17 +139,17 @@ window->hide();} open
|
||||
Fl_Check_Button previewButton {
|
||||
label Preview
|
||||
callback {preview(previewButton->value());}
|
||||
xywh {10 275 73 20} down_box DOWN_BOX shortcut 0x80070 value 1
|
||||
xywh {10 275 105 20} down_box DOWN_BOX shortcut 0x80070 value 1
|
||||
code0 {previewButton->label(preview_label);}
|
||||
}
|
||||
Fl_Check_Button showHiddenButton {
|
||||
label {Show hidden files}
|
||||
callback {showHidden(showHiddenButton->value());}
|
||||
xywh {115 275 165 20} down_box DOWN_BOX
|
||||
xywh {115 275 140 20} down_box DOWN_BOX
|
||||
code0 {showHiddenButton->label(hidden_label);}
|
||||
}
|
||||
Fl_Box {} {
|
||||
private xywh {115 275 365 20} resizable
|
||||
private xywh {255 275 225 20} resizable
|
||||
}
|
||||
}
|
||||
Fl_File_Input fileName {
|
||||
@ -168,7 +167,7 @@ window->hide();} open
|
||||
} {
|
||||
Fl_Return_Button okButton {
|
||||
label OK
|
||||
callback {window->hide();
|
||||
callback {hide();
|
||||
|
||||
// Do any callback that is registered...
|
||||
if (callback_)
|
||||
@ -181,8 +180,7 @@ if (callback_)
|
||||
label Cancel
|
||||
callback {fileName->value("");
|
||||
fileList->deselect();
|
||||
Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
|
||||
window->hide();}
|
||||
hide();}
|
||||
private xywh {408 345 72 25}
|
||||
code0 {o->label(fl_cancel);}
|
||||
}
|
||||
@ -298,10 +296,6 @@ data_ = d;} {}
|
||||
code {showChoice->value(f);
|
||||
showChoiceCB();} {}
|
||||
}
|
||||
Function {hide()} {return_type void
|
||||
} {
|
||||
code {window->hide();} {}
|
||||
}
|
||||
Function {iconsize(uchar s)} {return_type void
|
||||
} {
|
||||
code {fileList->iconsize(s);} {}
|
||||
@ -345,6 +339,8 @@ okButton->parent()->init_sizes();} {}
|
||||
}
|
||||
decl {void show();} {public local
|
||||
}
|
||||
decl {void hide();} {public local
|
||||
}
|
||||
Function {shown()} {return_type int
|
||||
} {
|
||||
code {return window->shown();} {}
|
||||
|
@ -1551,6 +1551,14 @@ void Fl_File_Chooser::show()
|
||||
if (!Fl::system_driver()->dot_file_hidden()) showHiddenButton->hide();
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::hide() {
|
||||
Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
|
||||
Fl_Shared_Image *oldimage = (Fl_Shared_Image*)previewBox->image();
|
||||
if (oldimage) oldimage->release();
|
||||
previewBox->image(NULL);
|
||||
window->hide();
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::showHidden(int value)
|
||||
{
|
||||
if (value) {
|
||||
|
Loading…
Reference in New Issue
Block a user