Add hidpi support for LabGrid

This commit is contained in:
Pandagrapher
2022-12-27 15:59:30 +01:00
parent c48531448e
commit 0b67f1b7b4
2 changed files with 238 additions and 282 deletions

View File

@@ -172,297 +172,254 @@ void LabGridArea::setListener(ToolPanelListener *l)
void LabGridArea::on_style_updated ()
{
setDirty(true);
queue_draw ();
}
bool LabGridArea::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
bool LabGridArea::on_draw(const ::Cairo::RefPtr<Cairo::Context> &cr)
{
Gtk::Allocation allocation = get_allocation();
allocation.set_x(0);
allocation.set_y(0);
// setDrawRectangle will allocate the backbuffer Surface
if (setDrawRectangle(Cairo::FORMAT_ARGB32, allocation)) {
setDirty(true);
}
if (!isDirty() || !surfaceCreated()) {
// Do not update drawing area if widget is not realized
if (!get_realized()) {
return true;
}
Glib::RefPtr<Gtk::StyleContext> style = get_style_context();
Gtk::Border padding = getPadding(style); // already scaled
Cairo::RefPtr<Cairo::Context> cr = getContext();
Gtk::Border padding = getPadding(style);
// Retrieve drawing area size
Gtk::Allocation allocation = get_allocation();
allocation.set_x(0);
allocation.set_y(0);
int width = allocation.get_width();
int height = allocation.get_height();
if (isDirty()) {
int width = allocation.get_width();
int height = allocation.get_height();
// Setup drawing
cr->set_line_cap(Cairo::LINE_CAP_SQUARE);
cr->set_operator (Cairo::OPERATOR_OVER);
const double s = RTScalable::scalePixelSize(1.);
// Render background
style->render_background(cr,
static_cast<double>(inset + padding.get_left()) - 1.,
static_cast<double>(inset + padding.get_top()) - 1.,
static_cast<double>(width - 2 * inset - padding.get_right() - padding.get_left()) + 2.,
static_cast<double>(height - 2 * inset - padding.get_top() - padding.get_bottom()) + 2.
);
cr->set_line_cap(Cairo::LINE_CAP_SQUARE);
// Drawing the cells
cr->translate(static_cast<double>(inset + padding.get_left()),
static_cast<double>(inset + padding.get_top()));
cr->set_antialias(Cairo::ANTIALIAS_NONE);
width -= 2 * inset + padding.get_right() + padding.get_left();
height -= 2 * inset + padding.get_top() + padding.get_bottom();
// clear background
cr->set_source_rgba (0., 0., 0., 0.);
cr->set_operator (Cairo::OPERATOR_CLEAR);
cr->paint ();
cr->set_operator (Cairo::OPERATOR_OVER);
style->render_background(cr,
(int)(inset * s + padding.get_left() - s + 0.5),
(int)(inset * s + padding.get_top() - s + 0.5),
(int)(width - 2 * inset * s - padding.get_right() - padding.get_left() + 2 * s + 0.5),
(int)(height - 2 * inset * s - padding.get_top() - padding.get_bottom() + 2 * s + 0.5)
);
// flip y:
cr->translate(0., static_cast<double>(height));
cr->scale(1., -1.);
// drawing the cells
cr->translate((int)(inset * s + padding.get_left() + 0.5),
(int)(inset * s + padding.get_top() + 0.5));
cr->set_antialias(Cairo::ANTIALIAS_NONE);
width -= (int)(2 * inset * s + 0.5) + padding.get_right() + padding.get_left();
height -= (int)(2 * inset * s + 0.5) + padding.get_top() + padding.get_bottom();
// flip y:
cr->translate(0, height);
cr->scale(1., -1.);
if (! ciexy_enabled) {//draw cells for Labgrid
int cells = 8;
float step = 12000.f / float(cells/2);
double cellW = double(width) / double(cells);
double cellH = double(height) / double(cells);
double cellYMin = 0.;
double cellYMax = std::floor(cellH);
for (int j = 0; j < cells; j++) {
double cellXMin = 0.;
double cellXMax = std::floor(cellW);
for (int i = 0; i < cells; i++) {
float R, G, B;
float x, y, z;
int ii = i - cells/2;
int jj = j - cells/2;
float a = step * (ii + 0.5f);
float b = step * (jj + 0.5f);
Color::Lab2XYZ(25000.f, a, b, x, y, z);
Color::xyz2srgb(x, y, z, R, G, B);
cr->set_source_rgb(R / 65535.f, G / 65535.f, B / 65535.f);
cr->rectangle(
cellXMin,
cellYMin,
cellXMax - cellXMin - (i == cells-1 ? 0. : double(s)),
cellYMax - cellYMin - (j == cells-1 ? 0. : double(s))
);
cellXMin = cellXMax;
cellXMax = std::floor(cellW * double(i+2) + 0.01);
cr->fill();
}
cellYMin = cellYMax;
cellYMax = std::floor(cellH * double(j+2) + 0.01);
}
} else {//cells for CIE xy
int cells = 600;
float step = 1.f / float(cells);
double cellW = double(width) / double(cells);
double cellH = double(height) / double(cells);
double cellYMin = 0.;
double cellYMax = std::floor(cellH);
//various approximations to simulate Ciexy curves graph
// this graph is not accurate...I replace curve by polygon or parabolic
float xa = 0.2653f / (0.7347f - 0.17f);
float xb = -0.17f * xa;
//linear values
// float ax = (0.1f - 0.6f) / 0.08f;
// float bx = 0.6f;
// float ax0 = -0.1f / (0.17f - 0.08f);
// float bx0 = -0.17f* ax0;
float axs = (0.2653f - 0.65f) / (0.7347f - 0.35f);
float bxs = 0.65f - axs * 0.35f;
// float axss = (0.7f - 0.83f) / (0.3f - 0.1f);
// float bxss = 0.7f - 0.3f * axss;
//float bxsss = 0.65f;
//float axsss = (0.83f - bxsss) / 0.05f;
//float bx4s = 0.83f;
float ay = 0.4f;
float by = 0.4f;
for (int j = 0; j < cells; j++) {
double cellXMin = 0.;
double cellXMax = std::floor(cellW);
for (int i = 0; i < cells; i++) {
float R, G, B;
float XX, YY, ZZ;
float x = 1.1f * step * i - 0.1f;//Graph CIExy with -0.1 to 1 - must be enough
float y = 1.1f * step * j - 0.1;//Graph CIExy with -0.1 to 1 - must be enough
if(y > 0.5f) {
YY = 0.6f;
} else {
YY = ay * y + by;
}
XX = (x * YY) / y;
ZZ = ((1.f - x - y)* YY) / y;
float yr = xa * x + xb;
// float y0 = ax0 * x + bx0;
// float y1 = ax * x + bx;
float y2 = axs * x + bxs;
// float y3 = axss * x + bxss;
// float y4 = axsss * x + bxsss;
// float y5 = bx4s;
float y6 = 22.52f * x * x - 7.652f * x + 0.65f;//parabolic passing in x=0.17 y=0 - x=0.1 y =0.11 - x=0 y= 0.65
float y3 = -1.266666f * x * x -0.170002f * x + 0.859686f;//other parabolic for green passing in x=0.35 y=0.65 - x=0.20 y=0.775 - x=0.1 y=0.83
float y4 = -60.71428f * x * x + 6.821428f * x + 0.65f;//other parabolic x=0 y=0.65 - x=0.03 y=0.8 - x=0.07 y=0.83
//small difference in the connection of the 2 last parabolic
Color::xyz2srgb(XX, YY, ZZ, R, G, B);
//replace color by gray
if(y < yr && x > 0.17f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
/*
if(y < y0 && x <= 0.17f && x >= 0.08f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y < y1 && x < 0.08f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
*/
if(y < y6 && y < 0.65f && x < 0.17f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y > y2 && x > 0.35f) {//0.35
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y > y3 && x <= 0.35f && x > 0.06f) {//0.35
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y > y4 && x <= 0.06f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
// if(y > y5 && x >= 0.07f && x <= 0.1f) {
// R = 0.7f; G = 0.7f; B = 0.7f;
// }
cr->set_source_rgb(R , G , B);
cr->rectangle(
cellXMin,
cellYMin,
cellXMax - cellXMin - (i == cells-1 ? 0. : 0.f * double(s)),
cellYMax - cellYMin - (j == cells-1 ? 0. : 0.f * double(s))
);
cellXMin = cellXMax;
cellXMax = std::floor(cellW * double(i+2) + 0.001);
cr->fill();
}
cellYMin = cellYMax;
cellYMax = std::floor(cellH * double(j+2) + 0.001);
if (! ciexy_enabled) {//draw cells for Labgrid
const int cells = 8;
const float step = 12000.f / static_cast<float>(cells/2);
const double cellW = static_cast<double>(width) / static_cast<double>(cells);
const double cellH = static_cast<double>(height) / static_cast<double>(cells);
double cellYMin = 0.;
double cellYMax = std::floor(cellH);
for (int j = 0; j < cells; j++) {
double cellXMin = 0.;
double cellXMax = std::floor(cellW);
for (int i = 0; i < cells; i++) {
float R, G, B;
float x, y, z;
const int ii = i - cells/2;
const int jj = j - cells/2;
const float a = step * static_cast<float>(ii + 0.5f);
const float b = step * static_cast<float>(jj + 0.5f);
Color::Lab2XYZ(25000.f, a, b, x, y, z);
Color::xyz2srgb(x, y, z, R, G, B);
cr->set_source_rgb(R / 65535.f, G / 65535.f, B / 65535.f);
cr->rectangle(
cellXMin,
cellYMin,
cellXMax - cellXMin - (i == cells-1 ? 0. : 1.),
cellYMax - cellYMin - (j == cells-1 ? 0. : 1.)
);
cellXMin = cellXMax;
cellXMax = std::floor(cellW * static_cast<double>(i+2) + 0.01);
cr->fill();
}
cellYMin = cellYMax;
cellYMax = std::floor(cellH * static_cast<double>(j+2) + 0.01);
}
// drawing the connection line
cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
float loa, hia, lob, hib, grx, gry, whx, why;
loa = .5 * (width + width * low_a);
hia = .5 * (width + width * high_a);
lob = .5 * (height + height * low_b);
hib = .5 * (height + height * high_b);
grx = .5 * (width + width * gre_x);
gry = .5 * (height + height * gre_y);
whx = .5 * (width + width * whi_x);
why = .5 * (height + height * whi_y);
cr->set_line_width(1.5f * double(s));
cr->set_source_rgb(0.6, 0.6, 0.6);
} else {//cells for CIE xy
const int cells = 600;
const float step = 1.f / static_cast<float>(cells);
const double cellW = static_cast<double>(width) / static_cast<double>(cells);
const double cellH = static_cast<double>(height) / static_cast<double>(cells);
double cellYMin = 0.;
double cellYMax = std::floor(cellH);
//various approximations to simulate Ciexy curves graph
// this graph is not accurate...I replace curve by polygon or parabolic
const float xa = 0.2653f / (0.7347f - 0.17f);
const float xb = -0.17f * xa;
//linear values
const float axs = (0.2653f - 0.65f) / (0.7347f - 0.35f);
const float bxs = 0.65f - axs * 0.35f;
const float ay = 0.4f;
const float by = 0.4f;
for (int j = 0; j < cells; j++) {
double cellXMin = 0.;
double cellXMax = std::floor(cellW);
for (int i = 0; i < cells; i++) {
float R, G, B;
float XX, YY, ZZ;
const float x = 1.1f * step * static_cast<float>(i) - 0.1f;//Graph CIExy with -0.1 to 1 - must be enough
const float y = 1.1f * step * static_cast<float>(j) - 0.1;//Graph CIExy with -0.1 to 1 - must be enough
if(y > 0.5f) {
YY = 0.6f;
} else {
YY = ay * y + by;
}
XX = (x * YY) / y;
ZZ = ((1.f - x - y)* YY) / y;
const float yr = xa * x + xb;
const float y2 = axs * x + bxs;
const float y6 = 22.52f * x * x - 7.652f * x + 0.65f;//parabolic passing in x=0.17 y=0 - x=0.1 y =0.11 - x=0 y= 0.65
const float y3 = -1.266666f * x * x -0.170002f * x + 0.859686f;//other parabolic for green passing in x=0.35 y=0.65 - x=0.20 y=0.775 - x=0.1 y=0.83
const float y4 = -60.71428f * x * x + 6.821428f * x + 0.65f;//other parabolic x=0 y=0.65 - x=0.03 y=0.8 - x=0.07 y=0.83
//small difference in the connection of the 2 last parabolic
Color::xyz2srgb(XX, YY, ZZ, R, G, B);
//replace color by gray
if(y < yr && x > 0.17f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y < y6 && y < 0.65f && x < 0.17f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y > y2 && x > 0.35f) {//0.35
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y > y3 && x <= 0.35f && x > 0.06f) {//0.35
R = 0.7f; G = 0.7f; B = 0.7f;
}
if(y > y4 && x <= 0.06f) {
R = 0.7f; G = 0.7f; B = 0.7f;
}
cr->set_source_rgb(R , G , B);
cr->rectangle(
cellXMin,
cellYMin,
cellXMax - cellXMin,
cellYMax - cellYMin);
cellXMin = cellXMax;
cellXMax = std::floor(cellW * static_cast<double>(i+2) + 0.001);
cr->fill();
}
cellYMin = cellYMax;
cellYMax = std::floor(cellH * static_cast<double>(j+2) + 0.001);
}
}
// Drawing the connection line
cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
const double loa = .5 * (static_cast<double>(width) + static_cast<double>(width) * low_a);
const double hia = .5 * (static_cast<double>(width) + static_cast<double>(width) * high_a);
const double lob = .5 * (static_cast<double>(height) + static_cast<double>(height) * low_b);
const double hib = .5 * (static_cast<double>(height) + static_cast<double>(height) * high_b);
const double grx = .5 * (static_cast<double>(width) + static_cast<double>(width) * gre_x);
const double gry = .5 * (static_cast<double>(height) + static_cast<double>(height) * gre_y);
const double whx = .5 * (static_cast<double>(width) + static_cast<double>(width) * whi_x);
const double why = .5 * (static_cast<double>(height) + static_cast<double>(height) * whi_y);
cr->set_line_width(1.5);
cr->set_source_rgb(0.6, 0.6, 0.6);
cr->move_to(loa, lob);
cr->line_to(hia, hib);
if (ciexy_enabled) {
cr->move_to(loa, lob);
cr->line_to(grx, gry);
cr->move_to(grx, gry);
cr->line_to(hia, hib);
if (ciexy_enabled) {
cr->move_to(loa, lob);
cr->line_to(grx, gry);
cr->move_to(grx, gry);
cr->line_to(hia, hib);
}
cr->stroke();
if (ciexy_enabled) {
cr->set_line_width(0.2);
cr->set_source_rgb(0.1, 0.1, 0.1);
//draw horiz and vertical lines
for(int i = 0; i < 22; i++) {
cr->move_to(0.04545 * static_cast<double>(i * width), 0.);
cr->line_to(0.04545 * static_cast<double>(i * width), static_cast<double>(height));
}
for(int i = 0; i < 22; i++) {
cr->move_to(0., 0.04545 * static_cast<double>(i * height));
cr->line_to(static_cast<double>(width), 0.04545 * static_cast<double>(i * height));
}
cr->stroke();
//draw abciss and ordonate
cr->set_line_width(1.);
cr->set_source_rgb(0.4, 0., 0.);
cr->move_to(0.04545 * static_cast<double>(2 * width), 0.);
cr->line_to(0.04545 * static_cast<double>(2 * width), static_cast<double>(height));
cr->move_to(0., 0.04545 * static_cast<double>(2 * height));
cr->line_to(static_cast<double>(width), 0.04545 * static_cast<double>(2 * height));
cr->stroke();
if (ciexy_enabled) {
//to convert from / to Ciexy <=> area
// pos_area = 1.81818 * (x + 0.1) - 1
// x = 0.55 * (pos_area + 1) - 0.1
cr->set_line_width(0.2f * double(s));
cr->set_source_rgb(0.1, 0.1, 0.1);
//draw horiz and vertical lines
for(int i = 0; i < 22; i++) {
cr->move_to(0.04545 * i * width, 0.);
cr->line_to(0.04545 * i * width, height);
}
for(int i = 0; i < 22; i++) {
cr->move_to(0., 0.04545 * i * height );
cr->line_to(width, 0.04545 * i * height);
}
//draw 0 and 1 with circle and lines
cr->set_line_width(1.2);
cr->set_source_rgb(0.4, 0., 0.);
cr->arc(0.06 * static_cast<double>(width),
0.06 * static_cast<double>(height),
0.016 * static_cast<double>(width),
0.,
2. * rtengine::RT_PI);
cr->stroke();
cr->set_line_width(1.5);
cr->set_source_rgb(0.4, 0., 0.);
cr->move_to(0.985 * static_cast<double>(width), 0.08 * static_cast<double>(height));
cr->line_to(0.985 * static_cast<double>(width), 0.055 * static_cast<double>(height));
cr->stroke();
//draw abciss and ordonate
cr->set_line_width(1.f * double(s));
cr->set_source_rgb(0.4, 0., 0.);
cr->move_to(0.04545 * 2 * width, 0.);
cr->line_to(0.04545 * 2 * width, height);
cr->move_to(0., 0.04545 * 2 * height );
cr->line_to(width, 0.04545 * 2 * height);
cr->stroke();
cr->move_to(0.07 * static_cast<double>(width), 0.99 * static_cast<double>(height));
cr->line_to(0.07 * static_cast<double>(width), 0.965 * static_cast<double>(height));
//draw 0 and 1 with circle and lines
cr->set_line_width(1.2f * double(s));
cr->set_source_rgb(0.4, 0., 0.);
cr->arc(0.06 * width, 0.06 * height, 0.016 * width, 0, 2. * rtengine::RT_PI);
cr->stroke();
cr->set_line_width(1.5f * double(s));
cr->set_source_rgb(0.4, 0., 0.);
cr->move_to(0.985 * width, 0.08 * height);
cr->line_to(0.985 * width, 0.055 * height);
cr->stroke();
}
cr->move_to(0.07 * width, 0.99 * height);
cr->line_to(0.07 * width, 0.965 * height);
cr->stroke();
}
// drawing points
if (low_enabled) {
cr->set_source_rgb(0.1, 0.1, 0.1);//black for red in Ciexy
if (litPoint == LOW) {
cr->arc(loa, lob, 5 * s, 0, 2. * rtengine::RT_PI);
} else {
cr->arc(loa, lob, 3 * s, 0, 2. * rtengine::RT_PI);
}
cr->fill();
}
if (ciexy_enabled) {
cr->set_source_rgb(0.5, 0.5, 0.5);//gray for green
if (litPoint == GRE) {
cr->arc(grx, gry, 5 * s, 0, 2. * rtengine::RT_PI);
} else {
cr->arc(grx, gry, 3 * s, 0, 2. * rtengine::RT_PI);
}
cr->fill();
}
if (ciexy_enabled) {//White Point
cr->set_source_rgb(1., 1., 1.);//White
cr->arc(whx, why, 3 * s, 0, 2. * rtengine::RT_PI);
cr->fill();
}
cr->set_source_rgb(0.9, 0.9, 0.9);//white for blue en Ciexy
if (litPoint == HIGH) {
cr->arc(hia, hib, 5 * s, 0, 2. * rtengine::RT_PI);
// Drawing points
if (low_enabled) {
cr->set_source_rgb(0.1, 0.1, 0.1);//black for red in Ciexy
if (litPoint == LOW) {
cr->arc(loa, lob, 5., 0., 2. * rtengine::RT_PI);
} else {
cr->arc(hia, hib, 3 * s, 0, 2. * rtengine::RT_PI);
cr->arc(loa, lob, 3., 0., 2. * rtengine::RT_PI);
}
cr->fill();
}
copySurface(crf);
if (ciexy_enabled) {
cr->set_source_rgb(0.5, 0.5, 0.5);//gray for green
if (litPoint == GRE) {
cr->arc(grx, gry, 5., 0., 2. * rtengine::RT_PI);
} else {
cr->arc(grx, gry, 3., 0., 2. * rtengine::RT_PI);
}
cr->fill();
}
if (ciexy_enabled) {//White Point
cr->set_source_rgb(1., 1., 1.);//White
cr->arc(whx, why, 3., 0., 2. * rtengine::RT_PI);
cr->fill();
}
cr->set_source_rgb(0.9, 0.9, 0.9);//white for blue en Ciexy
if (litPoint == HIGH) {
cr->arc(hia, hib, 5., 0., 2. * rtengine::RT_PI);
} else {
cr->arc(hia, hib, 3., 0., 2. * rtengine::RT_PI);
}
cr->fill();
return false;
}
@@ -529,11 +486,10 @@ bool LabGridArea::on_motion_notify_event(GdkEventMotion *event)
State oldLitPoint = litPoint;
const double s = RTScalable::scalePixelSize(1.);
int width = (int)(get_allocated_width() - 2 * inset * s - padding.get_right() - padding.get_left() + 0.5);
int height = (int)(get_allocated_height() - 2 * inset * s - padding.get_top() - padding.get_bottom() + 0.5);
const float mouse_x = std::min(double(std::max(event->x - inset * s - padding.get_right(), 0.)), double(width));
const float mouse_y = std::min(double(std::max(get_allocated_height() - 1 - event->y - inset * s - padding.get_bottom(), 0.)), double(height));
const int width = get_allocated_width() - 2 * inset - padding.get_right() - padding.get_left();
const int height = get_allocated_height() - 2 * inset - padding.get_top() - padding.get_bottom();
const float mouse_x = std::min(double(std::max(event->x - inset - padding.get_right(), 0.)), double(width));
const float mouse_y = std::min(double(std::max(get_allocated_height() - 1 - event->y - inset - padding.get_bottom(), 0.)), double(height));
const float ma = (2.f * mouse_x - width) / width;
const float mb = (2.f * mouse_y - height) / height;
if (isDragged) {
@@ -557,12 +513,12 @@ bool LabGridArea::on_motion_notify_event(GdkEventMotion *event)
queue_draw();
} else {
litPoint = NONE;
float la = low_a;
float lb = low_b;
float ha = high_a;
float hb = high_b;
float gx = gre_x;
float gy = gre_y;
const float la = low_a;
const float lb = low_b;
const float ha = high_a;
const float hb = high_b;
const float gx = gre_x;
const float gy = gre_y;
const float thrs = 0.05f;
const float distlo = (la - ma) * (la - ma) + (lb - mb) * (lb - mb);
const float disthi = (ha - ma) * (ha - ma) + (hb - mb) * (hb - mb);
@@ -592,11 +548,11 @@ void LabGridArea::get_preferred_width_vfunc(int &minimum_width, int &natural_wid
{
Glib::RefPtr<Gtk::StyleContext> style = get_style_context();
Gtk::Border padding = getPadding(style); // already scaled
const double s = RTScalable::scalePixelSize(1.);
int p = padding.get_left() + padding.get_right();
const int s = RTScalable::scalePixelSize(1);
const int p = padding.get_left() + padding.get_right();
minimum_width = (int)(50 * s + p + 0.5);
natural_width = (int)(150 * s + p + 0.5); // same as GRAPH_SIZE from mycurve.h
minimum_width = 50 * s + p;
natural_width = 150 * s + p; // same as GRAPH_SIZE from mycurve.h
}

View File

@@ -43,7 +43,7 @@
#include "toolpanel.h"
class LabGridArea final : public Gtk::DrawingArea, public BackBuffer {
class LabGridArea final : public Gtk::DrawingArea {
private:
rtengine::ProcEvent evt;
Glib::ustring evtMsg;
@@ -96,7 +96,7 @@ public:
bool ciexyEnabled() const;
void setciexyEnabled(bool yes);
bool on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf) override;
bool on_draw(const ::Cairo::RefPtr<Cairo::Context> &cr) override;
void on_style_updated () override;
bool on_button_press_event(GdkEventButton *event) override;
bool on_button_release_event(GdkEventButton *event) override;