New batch of update for issue 3446

This commit include :
- cleanup rtgui/retinex.cc file (constructor only) and switched to
Gtk::Grid (the new standard) instead of Gtk::Box. This however doesn't
solve the issue of the Transmission curves in the Retinex tool, with
wrong resize of the Frame when folding/unfolding the curves.
- better alignment of the Histogram panel now with 4px of padding on the
left and right side
- Threshold selector now use the Scale's Trough style to draw its box
and sliders
- Curve's background are darker and restricted to the curve diagram
- Diagonal and Flat curves has been converted to Gtk::Grid as well
- A special color is now used for unsensitive Threshold selector and
Sclaes widgets
- Gap around the main Window has been removed on windows to circumvent a
bug in Gtk3, but the window can now only be maximized (usual use case)
or resized vertically by the top border only.
- Buttons at the bottom of the Editor panel has now the same height
This commit is contained in:
Hombre
2016-11-01 20:39:41 +01:00
parent 3ae608d5ca
commit 965cadb52e
37 changed files with 919 additions and 664 deletions

View File

@@ -21,7 +21,7 @@
#include "multilangmgr.h"
#include "mycurve.h"
SHCSelector::SHCSelector() : ColoredBar(RTO_Left2Right), movingPosition(-1), tmpX(0.0), tmpPos(0.0), wslider(0.0), cl(nullptr)
SHCSelector::SHCSelector() : movingPosition(-1), tmpX(0.0), tmpPos(0.0), wslider(0.0), cl(nullptr), coloredBar(RTO_Left2Right)
{
positions[0] = defaults[0] = 0.25;
@@ -31,11 +31,12 @@ SHCSelector::SHCSelector() : ColoredBar(RTO_Left2Right), movingPosition(-1), tmp
rightMargin = RADIUS;
Glib::RefPtr<Gtk::StyleContext> style = get_style_context();
style->add_class(GTK_STYLE_CLASS_DEFAULT);
style->add_class(GTK_STYLE_CLASS_SCALE);
style->add_class(GTK_STYLE_CLASS_SLIDER);
style->add_class("drawingarea");
style->add_class(GTK_STYLE_CLASS_TROUGH);
//style->add_class(GTK_STYLE_CLASS_SCALE);
//style->add_class(GTK_STYLE_CLASS_SLIDER);
// TODO: This is a hack :) ; change this name to a specific one and create a new entry in all gtkrc theme files
// TODO: This is a hack :) ; change this name to a specific one and create a new entry in all CSS theme files
set_name("ThresholdSelector");
set_can_focus(false);
set_tooltip_text(M("SHCSELECTOR_TOOLTIP"));
@@ -43,7 +44,7 @@ SHCSelector::SHCSelector() : ColoredBar(RTO_Left2Right), movingPosition(-1), tmp
Gtk::SizeRequestMode SHCSelector::get_request_mode_vfunc () const
{
return Gtk::SIZE_REQUEST_HEIGHT_FOR_WIDTH;
return Gtk::SIZE_REQUEST_CONSTANT_SIZE;
}
void SHCSelector::get_preferred_height_vfunc (int &minimum_height, int &natural_height) const
@@ -65,7 +66,7 @@ void SHCSelector::get_preferred_height_for_width_vfunc (int width, int &minimum_
natural_height = minimum_height = 14;
}
void SHCSelector::get_preferred_width_for_height_vfunc (int width, int &minimum_width, int &natural_width) const
void SHCSelector::get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const
{
get_preferred_width_vfunc (minimum_width, natural_width);
}
@@ -109,10 +110,27 @@ void SHCSelector::on_realize()
add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
}
bool SHCSelector::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
void SHCSelector::updateBackBuffer()
{
Gdk::RGBA c;
if (!get_realized() || !isDirty() || !get_width() || !get_height()) {
return;
}
// This will create or update the size of the BackBuffer::surface
setDrawRectangle(Cairo::FORMAT_ARGB32, 0, 0, get_width(), get_height(), true);
if (!surface) {
return;
}
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
Glib::RefPtr<Gtk::StyleContext> style = get_style_context();
cr->set_source_rgba (0., 0., 0., 0.);
cr->set_operator (Cairo::OPERATOR_CLEAR);
cr->paint ();
cr->set_operator (Cairo::OPERATOR_OVER);
int w = get_width () - leftMargin - rightMargin;
int h = get_height ();
@@ -120,51 +138,33 @@ bool SHCSelector::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
wslider = std::max(int(h / 5), 10);
double hwslider = double(wslider) / 2.;
Gtk::StateFlags state = !is_sensitive() ? Gtk::STATE_FLAG_INSENSITIVE : Gtk::STATE_FLAG_NORMAL;
Glib::RefPtr<Gtk::StyleContext> style = get_style_context();
//style->render_background(cr, leftMargin, 0, w, h);
//return true;
// clear bg
cr->set_source_rgba (0., 0., 0., 0.);
cr->set_operator (Cairo::OPERATOR_CLEAR);
cr->paint ();
cr->set_operator (Cairo::OPERATOR_OVER);
// set the box's colors
cr->set_line_width (1.0);
cr->set_antialias(Cairo::ANTIALIAS_SUBPIXEL);
cr->set_line_cap(Cairo::LINE_CAP_BUTT);
if (is_sensitive() && canGetColors()) {
if (is_sensitive() && coloredBar.canGetColors()) {
// gradient background
Glib::RefPtr<Gdk::Window> win = get_window();
// this will eventually create/update the off-screen pixmap
setDrawRectangle(win, leftMargin + 1, 1, w - 2, int(float(h) * 5.5f / 7.f + 0.5f));
// this will eventually create/update the off-screen BackBuffer
coloredBar.setDrawRectangle(leftMargin + 1, 1, w - 2, int(float(h) * 5.5f / 7.f + 0.5f));
// that we're displaying here
ColoredBar::expose(cr);
coloredBar.expose(*this, cr);
} else {
style->render_background(cr, leftMargin + 1, 1, w - 2, int(float(h) * 5.5f / 7.f + 0.5f));
}
/* useless
else {
// solid background
// draw the box's background
style->render_background(cr, leftMargin+1, 1, w-2, int(float(h)*5.5f/7.f+0.5f));
}
*/
// draw the box's borders
style->render_frame(cr, leftMargin + 0.5, 0.5, w - 1, int(float(h) * 5.5f / 7.f + 0.5f) + 1);
//cr->set_line_width (1.);
//c = style->get_border_color(state);
//cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
//cr->rectangle (leftMargin + 0.5, 0.5, w - 1, int(float(h) * 5.5f / 7.f + 0.5f) + 1);
//cr->stroke ();
style->render_frame(cr, leftMargin + 1, 1, w - 2, int(float(h) * 5.5f / 7.f + 0.5f));
// draw sliders
cr->set_line_width (1.);
for (int i = 0; i < 3; i++) {
if (i == movingPosition) {
style->set_state(Gtk::STATE_FLAG_ACTIVE);
@@ -179,7 +179,7 @@ bool SHCSelector::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
style->set_state(Gtk::STATE_FLAG_NORMAL);
}
style->render_slider(cr, leftMargin + 0.5 + (w - 1)*positions[i] - hwslider, vb, wslider, h - vb, Gtk::ORIENTATION_HORIZONTAL);
style->render_slider(cr, leftMargin + 0.5 + (w - 1)*positions[i] - hwslider, vb, wslider, h - vb, Gtk::ORIENTATION_VERTICAL);
style->set_state(Gtk::STATE_FLAG_NORMAL);
}
@@ -197,43 +197,37 @@ bool SHCSelector::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
cr->close_path();
if (i==movingPosition) {
// moved (selected)
c = style->get_background_color(Gtk::STATE_FLAG_SELECTED);
Gdk::RGBA c = style->get_background_color(Gtk::STATE_FLAG_SELECTED);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->fill_preserve ();
c = style->get_border_color (Gtk::STATE_FLAG_SELECTED);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->stroke ();
}
*/
/*
else if (i==litCursor) {
// prelight
c = style->get_background_color(Gtk::STATE_FLAG_PRELIGHT);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->fill_preserve ();
c = style->get_border_color (Gtk::STATE_FLAG_PRELIGHT);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->stroke ();
}
*/
/*
else {
// normal
c = style->get_background_color(is_sensitive() ? Gtk::STATE_FLAG_ACTIVE : Gtk::STATE_FLAG_INSENSITIVE);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->fill_preserve ();
c = style->get_border_color (is_sensitive() ? Gtk::STATE_FLAG_ACTIVE : Gtk::STATE_FLAG_INSENSITIVE);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->stroke ();
}
/*
else if (i==litCursor) {
// prelight
Gdk::RGBA c = style->get_background_color(Gtk::STATE_FLAG_PRELIGHT);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->fill_preserve ();
c = style->get_border_color (Gtk::STATE_FLAG_PRELIGHT);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->stroke ();
}
* /
else {
// normal
Gdk::RGBA c = style->get_background_color(is_sensitive() ? Gtk::STATE_FLAG_ACTIVE : Gtk::STATE_FLAG_INSENSITIVE);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->fill_preserve ();
c = style->get_border_color (is_sensitive() ? Gtk::STATE_FLAG_ACTIVE : Gtk::STATE_FLAG_INSENSITIVE);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->stroke ();
}
}
*/
// draw text for the slider that is being moved
cr->set_line_width (0.5);
if (movingPosition >= 0) {
int i = movingPosition;
int offset;
@@ -241,8 +235,7 @@ bool SHCSelector::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
Glib::RefPtr<Pango::Layout> layout = create_pango_layout(Glib::ustring::format(std::setprecision(2), positions[i]));
layout->get_pixel_size(layout_width, layout_height);
offset = positions[i] > 0.5 ? -layout_width - 1 - hwslider : 1 + hwslider;
c = style->get_background_color(state);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->set_source_rgb (0., 0., 0.);
cr->set_line_width(3.);
cr->set_line_join(Cairo::LINE_JOIN_ROUND);
@@ -251,10 +244,25 @@ bool SHCSelector::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
cr->move_to (leftMargin + w * positions[i] + offset, 0.);
layout->add_to_cairo_context (cr);
cr->stroke_preserve();
c = style->get_color(Gtk::STATE_FLAG_PRELIGHT);
cr->set_source_rgb (c.get_red(), c.get_green(), c.get_blue());
cr->set_line_width(0.5);
cr->set_source_rgb (1., 1., 1.);
cr->fill ();
}
}
bool SHCSelector::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)
{
// on_realize & updateBackBuffer have to be called before
if (get_realized() && get_width() && get_height()) {
if (isDirty()) {
updateBackBuffer();
}
if (surface) {
copySurface(cr);
}
}
return true;
}
@@ -330,6 +338,7 @@ bool SHCSelector::on_motion_notify_event (GdkEventMotion* event)
cl->shcChanged ();
}
setDirty(true);
queue_draw ();
}
@@ -339,6 +348,7 @@ bool SHCSelector::on_motion_notify_event (GdkEventMotion* event)
void SHCSelector::styleChanged (const Glib::RefPtr<Gtk::Style>& style)
{
setDirty(true);
queue_draw ();
}
@@ -352,6 +362,7 @@ bool SHCSelector::reset () // : movingPosition(-1), cl(NULL) {
positions[0] = defaults[0];
positions[1] = defaults[1];
positions[2] = defaults[2];
setDirty(true);
queue_draw ();
return true;
}
@@ -363,7 +374,6 @@ void SHCSelector::refresh()
{
setDirty(true);
Glib::RefPtr<Gdk::Window> win = get_window();
if (win) {
win->invalidate(true);
}