void Slider::createSlider(int size) { SDL_Surface *s = screen.getSurface(); SDL_Surface *image = SDL_CreateRGBSurface(SDL_SWSURFACE, size, size, s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask); SDL_Surface *tile = loadImage(L"blue.bmp"); SDL_Rect src = { 0, 0, tile->w, tile->h }; SDL_Rect dst = { 0, 0, tile->w, tile->h }; for (int j = 0; j < size; j += tile->h) for (int i = 0; i < size; i += tile->w) { dst.x = i; dst.y = j; SDL_BlitSurface(tile, &src, image, &dst); } SDL_FreeSurface(tile); SDL_LockSurface(image); drawBevel(image, 0, 0, size, size, false, 1); drawBevel(image, 1, 1, size - 2, size - 2, true, 1); SDL_UnlockSurface(image); activeSlider = adjustBrightness(image, 1.5, false); slider = SDL_DisplayFormat(image); SDL_FreeSurface(image); }
void NonShinyLookAndFeel::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor) { if (textEditor.isEnabled()) { if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly()) { const int border = 2; g.setColour (textEditor.findColour (TextEditor::focusedOutlineColourId)); g.drawRect (0, 0, width, height, border); g.setOpacity (1.0f); const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId).withMultipliedAlpha (0.75f)); drawBevel (g, 0, 0, width, height + 2, border + 2, shadowColour, shadowColour); } else { g.setColour (textEditor.findColour (TextEditor::outlineColourId)); g.drawRect (0, 0, width, height); g.setOpacity (1.0f); const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId)); drawBevel (g, 0, 0, width, height + 2, 3, shadowColour, shadowColour); } } }
Button::Button(int x, int y, int w, int h, Font *font, int r, int g, int b, const std::wstring &bg, const std::wstring &text, Command *cmd): left(x), top(y), width(w), height(h), mouseInside(false), command(cmd) { SDL_Surface *s = screen.getSurface(); image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask); SDL_Surface *tile = loadImage(bg); SDL_Rect src = { 0, 0, tile->w, tile->h }; SDL_Rect dst = { 0, 0, tile->w, tile->h }; for (int j = 0; j < height; j += tile->h) for (int i = 0; i < width; i += tile->w) { dst.x = i; dst.y = j; SDL_BlitSurface(tile, &src, image, &dst); } SDL_FreeSurface(tile); SDL_LockSurface(image); drawBevel(image, 0, 0, width, height, false, 1); drawBevel(image, 1, 1, width - 2, height - 2, true, 1); SDL_UnlockSurface(image); int tW, tH; font->getSize(text, tW, tH); font->draw(image, (width - tW) / 2, (height - tH) / 2, r, g, b, true, text); highlighted = adjustBrightness(image, 1.5, false); }
void Slider::createBackground() { background = screen.createSubimage(left, top, width, height); int y = height / 2; SDL_LockSurface(background); drawBevel(background, 0, y - 2, width, 4, false, 1); SDL_UnlockSurface(background); }
Checkbox::Checkbox(int x, int y, int w, int h, Font *font, int r, int g, int b, const std::wstring &bg, bool &chk): checked(chk) { left = x; top = y; width = w; height = h; checked = chk; SDL_Surface *s = screen.getSurface(); image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask); SDL_Surface *tile = loadImage(bg); SDL_Rect src = { 0, 0, tile->w, tile->h }; SDL_Rect dst = { 0, 0, tile->w, tile->h }; for (int j = 0; j < height; j += tile->h) for (int i = 0; i < width; i += tile->w) { dst.x = i; dst.y = j; SDL_BlitSurface(tile, &src, image, &dst); } SDL_FreeSurface(tile); SDL_LockSurface(image); drawBevel(image, 0, 0, width, height, false, 1); drawBevel(image, 1, 1, width - 2, height - 2, true, 1); SDL_UnlockSurface(image); highlighted = adjustBrightness(image, 1.5, false); checkedImage = SDL_DisplayFormat(image); int tW, tH; font->getSize(L"X", tW, tH); tH += 2; tW += 2; font->draw(checkedImage, (width - tW) / 2, (height - tH) / 2, r, g, b, true, L"X"); checkedHighlighted = adjustBrightness(checkedImage, 1.5, false); mouseInside = false; }
Button::Button(int x, int y, int w, int h, Font *font, int r, int g, int b, const std::wstring &bg, const std::wstring &text, bool bevel, Command *cmd) { left = x; top = y; width = w; height = h; SDL_Surface *s = screen.getSurface(); image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, s->format->BitsPerPixel, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask); SDL_Surface *tile = loadImage(bg, true); SDL_Rect src = { 0, 0, tile->w, tile->h }; SDL_Rect dst = { 0, 0, tile->w, tile->h }; for (int j = 0; j < height; j += tile->h) for (int i = 0; i < width; i += tile->w) { dst.x = i; dst.y = j; SDL_BlitSurface(tile, &src, image, &dst); } SDL_FreeSurface(tile); if (bevel) { SDL_LockSurface(image); drawBevel(image, 0, 0, width, height, false, 1); drawBevel(image, 1, 1, width - 2, height - 2, true, 1); SDL_UnlockSurface(image); } int tW, tH; font->getSize(text, tW, tH); font->draw(image, (width - tW) / 2, (height - tH) / 2, r, g, b, true, text); highlighted = adjustBrightness(image, 1.5, false); SDL_SetColorKey(image, SDL_SRCCOLORKEY, getCornerPixel(image)); SDL_SetColorKey(highlighted, SDL_SRCCOLORKEY, getCornerPixel(highlighted)); mouseInside = false; command = cmd; }
osg::Geode* createExample(unsigned int size) { osg::Geode* geode = new osg::Geode(); osgCairo::Image* image = new osgCairo::Image(); if(image->allocateSurface(size, size, CAIRO_FORMAT_ARGB32)) { osg::Texture2D* texture = new osg::Texture2D(); osg::Geometry* geom = osg::createTexturedQuadGeometry( osg::Vec3(0.0f, 0.0f, 0.0f), osg::Vec3(image->s(), 0.0f, 0.0f), osg::Vec3(0.0f, image->t(), 0.0f), 0.0f, 0.0f, 1.0f, 1.0f ); cairo_t* c = image->createContext(false); if(!cairo_status(c)) { drawBevel(c, image->s(), image->t()); cairo_destroy(c); } texture->setImage(image); texture->setDataVariance(osg::Object::DYNAMIC); osg::StateSet* state = geom->getOrCreateStateSet(); state->setTextureAttributeAndModes( 0, texture, osg::StateAttribute::ON ); state->setMode(GL_BLEND, osg::StateAttribute::ON); state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); state->setAttributeAndModes( new osg::BlendFunc(osg::BlendFunc::ONE, osg::BlendFunc::ONE_MINUS_SRC_ALPHA) ); image->dirty(); osgDB::writeObjectFile(*image, "image.osgt"); osgDB::writeImageFile(*image, "image.png"); geode->addDrawable(geom); } return geode; }
void IMGUI::panel(const Rect& ext, Color color, bool colorBorder) { g_pGLPainter->setTexture(0); Color topColor = 0xFFEEEEEE; Color botColor = 0xFF848284; if (colorBorder) { ColorF c(color); topColor = c*1.4f; botColor = c*0.7f; } Rect ext1 = ext.inflated(-1.0f, -1.0f, 0.0f, 0.0f); g_pGLPainter->drawRect(ext1.l, ext1.t, ext1.r, ext1.b, color); ext1.inflate(1.0f, 1.0f, 0.0f, 0.0f); drawBevel(ext1, topColor, botColor, true); }
void renderList(sLinkedList* list, sSdlWrapper* wrap) { Uint32 bg = makeColor(255, 50, 25, 175); Uint32 fg = makeColor(255, 75, 50, 200); if(listEmpty(list)) return; sListIterator* it = 0; listHead(list, &it); point* toDraw = 0; int x = 0; int y = 0; while(!listIteratorEnd(it)) { toDraw = (point*)listGet(it); pointGetPos(toDraw, &x, &y); drawBevel(wrap, x*25, y*25, 25, 25, bg, fg); listIteratorNext(it); } free(it); }
void MSEntryFieldCombo::drawTextButton(MSBoolean armed_) { if(frozen()==MSFalse&&mapped()==MSTrue) { drawBevel(buttonRect(),(armed_==MSTrue)?MSSunken:MSRaised,2); XFillRectangle(display(),window(), (armed_==MSTrue)?selectShadowGC():backgroundShadowGC(), buttonRect().x()+2,buttonRect().y()+2, buttonRect().width()-4,buttonRect().height()-4); int offset = 2 + 1; int x = buttonRect().x() + offset; int y = buttonRect().y() + 2; XDrawString(display(), window(), fieldValue()->textGC(), fieldValue()->textFontStruct(), x, y + fieldValue()->textAscent(), comboButtonLabel().string(), comboButtonLabel().length()); } }
bool IMGUI::checkBox(const Rect& ext, const char* text, bool& bPressed) { bool bModified = false; if (isMouseAction(ext, Mouse_Down, Mouse_Left)) { bPressed = !bPressed; bModified = true; } Rect thumbExt(ext.l, ext.t, ext.l + ext.h(), ext.b); thumbExt.inflate(-1.0f); Rect textExt(thumbExt.r + 5, ext.t, ext.r, ext.b); drawBevel(thumbExt, 0xFFEEEEEE, 0xFF848284); if (bPressed) { panel(thumbExt.inflated(-2), 0xFFDDDDDD, true); } float textY = textExt.t + (textExt.b - textExt.t - FONT_HEIGHT)*0.5f + FONT_HEIGHT; g_pGLPainter->drawText(textExt.l, textY, text, 0xFFDDDDDD); return bModified; }
void MSEntryFieldCombo::drawComboButton(MSBoolean armed_) { if (frozen()==MSFalse&&mapped()==MSTrue) { drawBevel(buttonRect(),(armed_==MSTrue)?MSSunken:MSRaised,2); XFillRectangle(display(),window(), (armed_==MSTrue)?selectShadowGC():backgroundShadowGC(), buttonRect().x()+2,buttonRect().y()+2, buttonRect().width()-4,buttonRect().height()-4); int mw=buttonRect().width()>>1; // x midpoint of button int mh=buttonRect().height()>>1; // y midpoint of button int xoff=buttonRect().x(); int yoff=buttonRect().y(); int ah = _fieldValue->height()/2; int aw = _fieldValue->textHeight(); _comboArrow->configure(xoff+mw-aw/2, yoff+mh-ah/2, aw, ah); _comboArrow->select(armed_); _comboArrow->draw(); }