Gtk3 by Hombre, issue 2807
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "coloredbar.h"
|
||||
#include "../rtengine/utils.h"
|
||||
|
||||
ColoredBar::ColoredBar (eRTOrientation orient)
|
||||
{
|
||||
@@ -37,7 +38,8 @@ void ColoredBar::expose(Cairo::RefPtr<Cairo::ImageSurface> destSurface)
|
||||
}
|
||||
|
||||
draw();
|
||||
copySurface(destSurface);
|
||||
Gdk::Rectangle rect(x, y, w, h);
|
||||
copySurface(destSurface, &rect);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -51,7 +53,20 @@ void ColoredBar::expose(Glib::RefPtr<Gdk::Window> destWindow)
|
||||
}
|
||||
|
||||
draw();
|
||||
copySurface(destWindow);
|
||||
Gdk::Rectangle rect(x, y, w, h);
|
||||
copySurface(destWindow, &rect);
|
||||
}
|
||||
|
||||
void ColoredBar::expose(const Cairo::RefPtr< Cairo::Context> &cr)
|
||||
{
|
||||
// look out if the Surface has to be redrawn
|
||||
if (!surfaceCreated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
draw();
|
||||
Gdk::Rectangle rect(x, y, w, h);
|
||||
copySurface(cr, &rect);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -65,7 +80,8 @@ void ColoredBar::expose(BackBuffer *backBuffer)
|
||||
}
|
||||
|
||||
draw();
|
||||
copySurface(backBuffer);
|
||||
Gdk::Rectangle rect(x, y, w, h);
|
||||
copySurface(backBuffer, &rect);
|
||||
}
|
||||
|
||||
void ColoredBar::draw()
|
||||
@@ -110,53 +126,54 @@ void ColoredBar::draw()
|
||||
} else {
|
||||
// ask the ColorProvider to provide colors :) for each pixels
|
||||
if (colorProvider) {
|
||||
unsigned char *dst;
|
||||
unsigned char *surfaceData = surface->get_data();
|
||||
int surfW = getWidth();
|
||||
|
||||
cr->set_antialias(Cairo::ANTIALIAS_NONE);
|
||||
cr->set_line_width(1.);
|
||||
|
||||
switch (orientation) {
|
||||
case (RTO_Left2Right):
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
double x_ = double( x);
|
||||
double y_ = double((h - 1) - y);
|
||||
double x01 = x_ / double(w - 1);
|
||||
double y01 = double(y) / double(h - 1);
|
||||
for (int py = 0; py < h; ++py) {
|
||||
for (int px = 0; px < w; ++px) {
|
||||
double x_ = double( px);
|
||||
//double y_ = double((h-1)-py); unused
|
||||
double x01 = x_ / double(w - 1);
|
||||
double y01 = double(py) / double(h - 1);
|
||||
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
|
||||
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
|
||||
cr->rectangle(x_, y_, 1., 1.);
|
||||
cr->fill();
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case (RTO_Right2Left):
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
double x_ = double((w - 1) - x);
|
||||
double y_ = double((h - 1) - y);
|
||||
double x01 = double(x) / double(w - 1);
|
||||
double y01 = double(y) / double(h - 1);
|
||||
for (int py = 0; py < h; ++py) {
|
||||
for (int px = 0; px < w; ++px) {
|
||||
//double x_ = double((w-1)-px); unused
|
||||
//double y_ = double((h-1)-py); unused
|
||||
double x01 = double(px) / double(w - 1);
|
||||
double y01 = double(py) / double(h - 1);
|
||||
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
|
||||
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
|
||||
cr->rectangle(x_, y_, 1., 1.);
|
||||
cr->fill();
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case (RTO_Bottom2Top):
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
double x_ = double((w - 1) - x);
|
||||
double y_ = double((h - 1) - y);
|
||||
double x01 = double(x) / double(w - 1);
|
||||
double y01 = double(y) / double(h - 1);
|
||||
for (int py = 0; py < h; ++py) {
|
||||
for (int px = 0; px < w; ++px) {
|
||||
//double x_ = double((w-1)-px); unused
|
||||
//double y_ = double((h-1)-py); unused
|
||||
double x01 = double(px) / double(w - 1);
|
||||
double y01 = double(py) / double(h - 1);
|
||||
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
|
||||
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
|
||||
cr->rectangle(x_, y_, 1., 1.);
|
||||
cr->fill();
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,21 +181,93 @@ void ColoredBar::draw()
|
||||
|
||||
case (RTO_Top2Bottom):
|
||||
default:
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
double x_ = double( x);
|
||||
double y_ = double( y);
|
||||
for (int py = 0; py < h; ++py) {
|
||||
for (int px = 0; px < w; ++px) {
|
||||
double x_ = double( px);
|
||||
double y_ = double( py);
|
||||
double x01 = x_ / double(w - 1);
|
||||
double y01 = y_ / double(h - 1);
|
||||
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
|
||||
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
|
||||
cr->rectangle(x_, y_, 1., 1.);
|
||||
cr->fill();
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
unsigned char *dst;
|
||||
unsigned char *surfaceData = surface->get_data();
|
||||
int surfW = getWidth();
|
||||
|
||||
cr->set_antialias(Cairo::ANTIALIAS_NONE);
|
||||
cr->set_line_width(1.);
|
||||
switch (orientation) {
|
||||
case (RTO_Left2Right):
|
||||
for (int py=0; py<h; ++py, ++py) {
|
||||
dst = surfaceData + ((y+py)*surfW+x)*4;
|
||||
for (int px=0; px<w; ++px, ++px) {
|
||||
double x_ = double( px);
|
||||
//double y_ = double((h-1)-py); unused
|
||||
double x01 = x_ /double(w-1);
|
||||
double y01 = double(py)/double(h-1);
|
||||
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (RTO_Right2Left):
|
||||
for (int py=0; py<h; ++py, ++py) {
|
||||
dst = surfaceData + ((y+py)*surfW+x)*4;
|
||||
for (int px=0; px<w; ++px, ++px) {
|
||||
//double x_ = double((w-1)-px); unused
|
||||
//double y_ = double((h-1)-py); unused
|
||||
double x01 = double(px)/double(w-1);
|
||||
double y01 = double(py)/double(h-1);
|
||||
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (RTO_Bottom2Top):
|
||||
for (int py=0; py<h; ++py, ++py) {
|
||||
dst = surfaceData + ((y+py)*surfW+x)*4;
|
||||
for (int px=0; px<w; ++px, ++px) {
|
||||
//double x_ = double((w-1)-px); unused
|
||||
//double y_ = double((h-1)-py); unused
|
||||
double x01 = double(px)/double(w-1);
|
||||
double y01 = double(py)/double(h-1);
|
||||
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (RTO_Top2Bottom):
|
||||
default:
|
||||
for (int py=0; py<h; ++py, ++py) {
|
||||
dst = surfaceData + ((y+py)*surfW+x)*4;
|
||||
for (int px=0; px<w; ++px, ++px) {
|
||||
double x_ = double( px);
|
||||
double y_ = double( py);
|
||||
double x01 = x_/double(w-1);
|
||||
double y01 = y_/double(h-1);
|
||||
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
|
||||
|
||||
rtengine::poke01_d(surfaceData, ccRed, ccGreen, ccBlue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user