X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Frendercontrol.cc;h=6386b035c86dc481d018ae93303ae396fa65c58e;hb=3dfe9f4ebeb7abd8446c52db0232b9f610a78846;hp=bf48d58abc4216d9232a736a5cb472c93cb7f15d;hpb=136c9c078d33e5784881267be03d8ff1adf41bc5;p=chaz%2Fopenbox diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc index bf48d58a..6386b035 100644 --- a/otk/rendercontrol.cc +++ b/otk/rendercontrol.cc @@ -32,7 +32,7 @@ extern "C" { namespace otk { -RenderControl *RenderControl::getRenderControl(int screen) +RenderControl *RenderControl::createRenderControl(int screen) { // get the visual on the screen and return the correct type of RenderControl int vclass = display->screenInfo(screen)->visual()->c_class; @@ -232,6 +232,9 @@ void RenderControl::drawGradientBackground( case RenderTexture::Vertical: verticalGradient(sf, texture); break; + case RenderTexture::Horizontal: + horizontalGradient(sf, texture); + break; case RenderTexture::Diagonal: diagonalGradient(sf, texture); break; @@ -321,6 +324,36 @@ void RenderControl::verticalGradient(Surface &sf, } } +void RenderControl::horizontalGradient(Surface &sf, + const RenderTexture &texture) const +{ + pixel32 *data = sf.pixelData(); + pixel32 current; + float dr, dg, db; + unsigned int r,g,b; + int w = sf.size().width(), h = sf.size().height(); + + dr = (float)(texture.secondary_color().red() - texture.color().red()); + dr/= (float)w; + + dg = (float)(texture.secondary_color().green() - texture.color().green()); + dg/= (float)w; + + db = (float)(texture.secondary_color().blue() - texture.color().blue()); + db/= (float)w; + + for (int x = 0; x < w; ++x, ++data) { + r = texture.color().red() + (int)(dr * x); + g = texture.color().green() + (int)(dg * x); + b = texture.color().blue() + (int)(db * x); + current = (r << default_red_shift) + + (g << default_green_shift) + + (b << default_blue_shift); + for (int y = 0; y < h; ++y) + *(data + y*w) = current; + } +} + void RenderControl::diagonalGradient(Surface &sf, const RenderTexture &texture) const {