Formatted all .cc and .h code in rtengine, rtexif and rtgui using astyle

This commit is contained in:
DrSlony
2015-08-11 11:55:03 +02:00
parent effb46c3e1
commit 0e0cfb9b25
452 changed files with 133354 additions and 99460 deletions

View File

@@ -19,159 +19,187 @@
#include "coloredbar.h"
ColoredBar::ColoredBar (eRTOrientation orient) {
orientation = orient;
dirty = true;
this->x = this->y = this->w = this->h = 0;
ColoredBar::ColoredBar (eRTOrientation orient)
{
orientation = orient;
dirty = true;
this->x = this->y = this->w = this->h = 0;
}
/*
* Redraw the bar to a Cairo::ImageSurface
*/
void ColoredBar::expose(Cairo::RefPtr<Cairo::ImageSurface> destSurface) {
// look out if the Surface has to be redrawn
if (!surfaceCreated() || !destSurface)
return;
draw();
copySurface(destSurface);
void ColoredBar::expose(Cairo::RefPtr<Cairo::ImageSurface> destSurface)
{
// look out if the Surface has to be redrawn
if (!surfaceCreated() || !destSurface) {
return;
}
draw();
copySurface(destSurface);
}
/*
* Redraw the bar to a Gdk::Window
*/
void ColoredBar::expose(Glib::RefPtr<Gdk::Window> destWindow) {
// look out if the Surface has to be redrawn
if (!surfaceCreated() || !destWindow)
return;
draw();
copySurface(destWindow);
void ColoredBar::expose(Glib::RefPtr<Gdk::Window> destWindow)
{
// look out if the Surface has to be redrawn
if (!surfaceCreated() || !destWindow) {
return;
}
draw();
copySurface(destWindow);
}
/*
* Redraw the bar to a Gdk::Window
*/
void ColoredBar::expose(BackBuffer *backBuffer) {
// look out if the Surface has to be redrawn
if (!surfaceCreated() || !backBuffer)
return;
draw();
copySurface(backBuffer);
void ColoredBar::expose(BackBuffer *backBuffer)
{
// look out if the Surface has to be redrawn
if (!surfaceCreated() || !backBuffer) {
return;
}
draw();
copySurface(backBuffer);
}
void ColoredBar::draw() {
if (isDirty()) {
Cairo::RefPtr<Cairo::Context> cr = getContext();
// the bar has to be drawn to the Surface first
if (!bgGradient.empty()) {
// a gradient has been set, we use it
cr->set_line_width(0.);
void ColoredBar::draw()
{
if (isDirty()) {
Cairo::RefPtr<Cairo::Context> cr = getContext();
// gradient background
Cairo::RefPtr< Cairo::LinearGradient > bggradient;
switch (orientation) {
case (RTO_Left2Right):
bggradient = Cairo::LinearGradient::create (0., 0., double(w), 0.);
break;
case (RTO_Right2Left):
bggradient = Cairo::LinearGradient::create (double(w), 0., 0., 0.);
break;
case (RTO_Bottom2Top):
bggradient = Cairo::LinearGradient::create (0., double(h), 0., 0.);
break;
case (RTO_Top2Bottom):
default:
bggradient = Cairo::LinearGradient::create (0., 0., 0., double(h));
break;
}
// the bar has to be drawn to the Surface first
if (!bgGradient.empty()) {
// a gradient has been set, we use it
cr->set_line_width(0.);
for (std::vector<GradientMilestone>::iterator i=bgGradient.begin(); i!=bgGradient.end(); i++) {
bggradient->add_color_stop_rgb (i->position, i->r, i->g, i->b);
}
cr->set_source (bggradient);
cr->rectangle(0, 0, w, h);
cr->fill();
}
else {
// ask the ColorProvider to provide colors :) for each pixels
if (colorProvider) {
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);
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
}
}
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);
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
}
}
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);
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
}
}
break;
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);
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();
}
}
break;
}
}
}
// has it been updated or not, we assume that the Surface has been correctly set (we don't handle allocation error)
setDirty(false);
}
// gradient background
Cairo::RefPtr< Cairo::LinearGradient > bggradient;
switch (orientation) {
case (RTO_Left2Right):
bggradient = Cairo::LinearGradient::create (0., 0., double(w), 0.);
break;
case (RTO_Right2Left):
bggradient = Cairo::LinearGradient::create (double(w), 0., 0., 0.);
break;
case (RTO_Bottom2Top):
bggradient = Cairo::LinearGradient::create (0., double(h), 0., 0.);
break;
case (RTO_Top2Bottom):
default:
bggradient = Cairo::LinearGradient::create (0., 0., 0., double(h));
break;
}
for (std::vector<GradientMilestone>::iterator i = bgGradient.begin(); i != bgGradient.end(); i++) {
bggradient->add_color_stop_rgb (i->position, i->r, i->g, i->b);
}
cr->set_source (bggradient);
cr->rectangle(0, 0, w, h);
cr->fill();
} else {
// ask the ColorProvider to provide colors :) for each pixels
if (colorProvider) {
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);
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
}
}
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);
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
}
}
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);
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
}
}
break;
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);
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();
}
}
break;
}
}
}
// has it been updated or not, we assume that the Surface has been correctly set (we don't handle allocation error)
setDirty(false);
}
}
void ColoredBar::setBgGradient (const std::vector<GradientMilestone> &milestones) {
bgGradient = milestones;
setDirty(true);
void ColoredBar::setBgGradient (const std::vector<GradientMilestone> &milestones)
{
bgGradient = milestones;
setDirty(true);
}
void ColoredBar::clearBgGradient () {
bgGradient.clear();
setDirty(true);
void ColoredBar::clearBgGradient ()
{
bgGradient.clear();
setDirty(true);
}
bool ColoredBar::canGetColors() {
return colorProvider!=NULL || bgGradient.size()>0;
bool ColoredBar::canGetColors()
{
return colorProvider != NULL || bgGradient.size() > 0;
}