Fixing rendering loop in the FileBrowser, based on a suggestion from
Adam
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#define CROPRESIZEBORDER 4
|
#define CROPRESIZEBORDER 4
|
||||||
|
|
||||||
extern Glib::Threads::Thread* mainThread;
|
//extern Glib::Threads::Thread* mainThread;
|
||||||
|
|
||||||
bool FileBrowserEntry::iconsLoaded(false);
|
bool FileBrowserEntry::iconsLoaded(false);
|
||||||
Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::editedIcon;
|
Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::editedIcon;
|
||||||
|
@@ -85,9 +85,9 @@ static void myGdkLockLeave()
|
|||||||
{
|
{
|
||||||
// Automatic gdk_flush for non main tread
|
// Automatic gdk_flush for non main tread
|
||||||
#if AUTO_GDK_FLUSH
|
#if AUTO_GDK_FLUSH
|
||||||
if (Glib::Thread::self() != mainThread) {
|
//if (Glib::Thread::self() != mainThread) {
|
||||||
gdk_flush();
|
// gdk_flush();
|
||||||
}
|
//}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
myGdkRecMutex.unlock();
|
myGdkRecMutex.unlock();
|
||||||
|
@@ -626,6 +626,15 @@ void ThumbBrowserBase::enableInspector()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThumbBrowserBase::Internal::on_style_updated()
|
||||||
|
{
|
||||||
|
style = get_style_context ();
|
||||||
|
textn = style->get_color(Gtk::STATE_FLAG_NORMAL);
|
||||||
|
texts = style->get_color(Gtk::STATE_FLAG_SELECTED);
|
||||||
|
bgn = style->get_background_color(Gtk::STATE_FLAG_NORMAL);
|
||||||
|
bgs = style->get_background_color(Gtk::STATE_FLAG_SELECTED);
|
||||||
|
}
|
||||||
|
|
||||||
void ThumbBrowserBase::Internal::on_realize()
|
void ThumbBrowserBase::Internal::on_realize()
|
||||||
{
|
{
|
||||||
// Gtk signals automatically acquire the GUI (i.e. this method is enclosed by gdk_thread_enter and gdk_thread_leave)
|
// Gtk signals automatically acquire the GUI (i.e. this method is enclosed by gdk_thread_enter and gdk_thread_leave)
|
||||||
@@ -634,6 +643,13 @@ void ThumbBrowserBase::Internal::on_realize()
|
|||||||
get_pango_context()->set_cairo_font_options (cfo);
|
get_pango_context()->set_cairo_font_options (cfo);
|
||||||
|
|
||||||
Gtk::DrawingArea::on_realize();
|
Gtk::DrawingArea::on_realize();
|
||||||
|
|
||||||
|
style = get_style_context ();
|
||||||
|
textn = style->get_color(Gtk::STATE_FLAG_NORMAL);
|
||||||
|
texts = style->get_color(Gtk::STATE_FLAG_SELECTED);
|
||||||
|
bgn = style->get_background_color(Gtk::STATE_FLAG_NORMAL);
|
||||||
|
bgs = style->get_background_color(Gtk::STATE_FLAG_SELECTED);
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Window> window = get_window();
|
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||||
set_can_focus(true);
|
set_can_focus(true);
|
||||||
add_events(Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK);
|
add_events(Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK);
|
||||||
@@ -884,7 +900,7 @@ bool ThumbBrowserBase::Internal::on_draw(const ::Cairo::RefPtr< Cairo::Context>
|
|||||||
int h = get_height();
|
int h = get_height();
|
||||||
|
|
||||||
// draw thumbnails
|
// draw thumbnails
|
||||||
Glib::RefPtr<Gtk::StyleContext> style = get_style_context ();
|
|
||||||
cr->set_antialias(Cairo::ANTIALIAS_NONE);
|
cr->set_antialias(Cairo::ANTIALIAS_NONE);
|
||||||
cr->set_line_join(Cairo::LINE_JOIN_MITER);
|
cr->set_line_join(Cairo::LINE_JOIN_MITER);
|
||||||
style->render_background(cr, 0., 0., w, h);
|
style->render_background(cr, 0., 0., w, h);
|
||||||
|
@@ -38,10 +38,19 @@ class ThumbBrowserBase : public Gtk::VBox
|
|||||||
int ofsX, ofsY;
|
int ofsX, ofsY;
|
||||||
ThumbBrowserBase* parent;
|
ThumbBrowserBase* parent;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
|
|
||||||
|
// caching some very often used values
|
||||||
|
Glib::RefPtr<Gtk::StyleContext> style;
|
||||||
|
Gdk::RGBA textn;
|
||||||
|
Gdk::RGBA texts;
|
||||||
|
Gdk::RGBA bgn;
|
||||||
|
Gdk::RGBA bgs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Internal ();
|
Internal ();
|
||||||
void setParent (ThumbBrowserBase* p);
|
void setParent (ThumbBrowserBase* p);
|
||||||
void on_realize();
|
void on_realize();
|
||||||
|
void on_style_updated();
|
||||||
bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr);
|
bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr);
|
||||||
bool on_button_press_event (GdkEventButton* event);
|
bool on_button_press_event (GdkEventButton* event);
|
||||||
bool on_button_release_event (GdkEventButton* event);
|
bool on_button_release_event (GdkEventButton* event);
|
||||||
@@ -51,6 +60,22 @@ class ThumbBrowserBase : public Gtk::VBox
|
|||||||
bool on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
|
bool on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
|
||||||
void setPosition (int x, int y);
|
void setPosition (int x, int y);
|
||||||
|
|
||||||
|
Glib::RefPtr<Gtk::StyleContext> getStyle() {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
Gdk::RGBA getNormalTextColor() {
|
||||||
|
return textn;
|
||||||
|
}
|
||||||
|
Gdk::RGBA getSelectedTextColor() {
|
||||||
|
return texts;
|
||||||
|
}
|
||||||
|
Gdk::RGBA getNormalBgColor() {
|
||||||
|
return bgn;
|
||||||
|
}
|
||||||
|
Gdk::RGBA getSelectedBgColor() {
|
||||||
|
return bgs;
|
||||||
|
}
|
||||||
|
|
||||||
void setDirty ()
|
void setDirty ()
|
||||||
{
|
{
|
||||||
dirty = true;
|
dirty = true;
|
||||||
@@ -194,6 +219,23 @@ public:
|
|||||||
{
|
{
|
||||||
return &internal;
|
return &internal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Glib::RefPtr<Gtk::StyleContext> getStyle() {
|
||||||
|
return internal.getStyle();
|
||||||
|
}
|
||||||
|
Gdk::RGBA getNormalTextColor() {
|
||||||
|
return internal.getNormalTextColor();
|
||||||
|
}
|
||||||
|
Gdk::RGBA getSelectedTextColor() {
|
||||||
|
return internal.getSelectedTextColor();
|
||||||
|
}
|
||||||
|
Gdk::RGBA getNormalBgColor() {
|
||||||
|
return internal.getNormalBgColor();
|
||||||
|
}
|
||||||
|
Gdk::RGBA getSelectedBgColor() {
|
||||||
|
return internal.getSelectedBgColor();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -86,15 +86,11 @@ void ThumbBrowserEntryBase::updateBackBuffer ()
|
|||||||
|
|
||||||
Cairo::RefPtr<Cairo::Context> cc = Cairo::Context::create(surface);
|
Cairo::RefPtr<Cairo::Context> cc = Cairo::Context::create(surface);
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::StyleContext> style = w->get_style_context();
|
Glib::RefPtr<Gtk::StyleContext> style = parent->getStyle();
|
||||||
Gdk::RGBA txtn;
|
Gdk::RGBA textn = parent->getNormalTextColor();
|
||||||
style->lookup_color("text", txtn);
|
Gdk::RGBA texts = parent->getSelectedTextColor();
|
||||||
Gdk::RGBA textn = style->get_color(Gtk::STATE_FLAG_NORMAL);
|
Gdk::RGBA bgn = parent->getNormalBgColor();
|
||||||
Gdk::RGBA texts = style->get_color(Gtk::STATE_FLAG_SELECTED);
|
Gdk::RGBA bgs = parent->getSelectedBgColor();
|
||||||
Gdk::RGBA bgn = style->get_background_color(Gtk::STATE_FLAG_NORMAL);
|
|
||||||
//Gdk::RGBA bgs = style->get_background_color(Gtk::STATE_FLAG_SELECTED);
|
|
||||||
Gdk::RGBA bgs;
|
|
||||||
bgs.set_rgba(0.3372549, 0.3372549, 0.3372549);
|
|
||||||
|
|
||||||
// clear area, draw frames and background
|
// clear area, draw frames and background
|
||||||
style->render_background(cc, 0., 0., exp_width, exp_height);
|
style->render_background(cc, 0., 0., exp_width, exp_height);
|
||||||
@@ -498,12 +494,7 @@ void ThumbBrowserEntryBase::draw ()
|
|||||||
|
|
||||||
Glib::RefPtr<Gdk::Window> win = w->get_window();
|
Glib::RefPtr<Gdk::Window> win = w->get_window();
|
||||||
Cairo::RefPtr<Cairo::Context> cc = win->create_cairo_context();
|
Cairo::RefPtr<Cairo::Context> cc = win->create_cairo_context();
|
||||||
Glib::RefPtr<Gtk::StyleContext> sc = w->get_style_context();
|
|
||||||
|
|
||||||
// Gdk::RGBA textn = sc->get_color(Gtk::STATE_FLAG_NORMAL);
|
|
||||||
// Gdk::RGBA texts = sc->get_color(Gtk::STATE_FLAG_SELECTED);
|
|
||||||
Gdk::RGBA bgn = sc->get_background_color(Gtk::STATE_FLAG_NORMAL);
|
|
||||||
Gdk::RGBA bgs = sc->get_background_color(Gtk::STATE_FLAG_SELECTED);
|
|
||||||
int w_ = startx + ofsX;
|
int w_ = startx + ofsX;
|
||||||
int h_ = starty + ofsY;
|
int h_ = starty + ofsY;
|
||||||
cc->set_source(backBuffer->getSurface(), w_, h_);
|
cc->set_source(backBuffer->getSurface(), w_, h_);
|
||||||
@@ -516,7 +507,7 @@ void ThumbBrowserEntryBase::draw ()
|
|||||||
|
|
||||||
// redraw button set above the thumbnail
|
// redraw button set above the thumbnail
|
||||||
if (buttonSet) {
|
if (buttonSet) {
|
||||||
buttonSet->setColors (selected ? bgs : bgn, selected ? bgn : bgs);
|
buttonSet->setColors (selected ? parent->getSelectedBgColor() : parent->getNormalBgColor(), selected ? parent->getNormalBgColor() : parent->getSelectedBgColor());
|
||||||
buttonSet->redraw (cc);
|
buttonSet->redraw (cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user