//____ updateWindowRects() _____________________________________________________ // // Updates the rectangles of the SDL Window that WonderGUI has modified. // void updateWindowRects( const RootPanel_p& pRoot, SDL_Window * pWindow ) { int nRects = pRoot->nbUpdatedRects(); if( nRects == 0 ) return; const Rect * pUpdatedRects = pRoot->firstUpdatedRect(); SDL_Rect * pSDLRects = (SDL_Rect*) Base::memStackAlloc( sizeof(SDL_Rect) * nRects ); for( int i = 0 ; i < nRects ; i++ ) { pSDLRects[i].x = pUpdatedRects[i].x; pSDLRects[i].y = pUpdatedRects[i].y; pSDLRects[i].w = pUpdatedRects[i].w; pSDLRects[i].h = pUpdatedRects[i].h; } SDL_UpdateWindowSurfaceRects( pWindow, pSDLRects, nRects ); Base::memStackRelease( sizeof(SDL_Rect) * nRects ); }
void InputHandler::setFocusedWindow( const RootPanel_p& pRoot ) { if( pRoot == m_pFocusedRoot ) return; if( m_pFocusedRoot ) { Widget * p = m_pFocusedRoot->_focusedChild(); if( p ) _setUnfocused( p ); } m_pFocusedRoot = pRoot.rawPtr(); if( pRoot ) { Widget * p = pRoot->_focusedChild(); if( p ) _setFocused( p ); else _setFocused( pRoot->widget().rawPtr() ); // Bottom container gets focus per default. } }
int main ( int argc, char** argv ) { //------------------------------------------------------ // Init SDL //------------------------------------------------------ SDL_Init(SDL_INIT_VIDEO); int posX = 100, posY = 100, width = 320, height = 240; SDL_Window * pWin = SDL_CreateWindow("Hello WonderGUI", posX, posY, width, height, 0); SDL_Surface * pWinSurf = SDL_GetWindowSurface( pWin ); IMG_Init( IMG_INIT_JPG | IMG_INIT_PNG ); //------------------------------------------------------ // Init WonderGUI //------------------------------------------------------ Base::init(); InputHandler_p pInput = InputHandler::create(); pDebug = pInput.rawPtr(); WgPixelType type = WG_PIXEL_UNKNOWN; if( pWinSurf->format->BitsPerPixel == 32 ) type = WG_PIXEL_ARGB_8; else if( pWinSurf->format->BitsPerPixel == 24 ) type = WG_PIXEL_RGB_8; SoftSurface_p pCanvas = SoftSurface::create( Size(pWinSurf->w,pWinSurf->h), type, (unsigned char*) pWinSurf->pixels, pWinSurf->pitch, 0 ); SoftGfxDevice_p pGfxDevice = SoftGfxDevice::create( pCanvas ); RootPanel_p pRoot = RootPanel::create( pGfxDevice ); Base::msgRouter()->setRoot(pRoot); // MsgLogger_p pLogger = MsgLogger::create( std::cout ); pLogger->ignoreAllMsgs(); pLogger->logMouseMsgs(); Base::msgRouter()->broadcastTo( pLogger ); // Init font SDL_Surface * pFontSurf = IMG_Load( "../../../resources/anuvverbubbla_8x8.png" ); Blob_p pFontSurfBlob = Blob::create( pFontSurf, freeSDLSurfCallback ); SoftSurface_p pFontImg = SoftSurface::create( Size(pFontSurf->w,pFontSurf->h), WG_PIXEL_ARGB_8, (unsigned char*) pFontSurf->pixels, pFontSurf->pitch, pFontSurfBlob ); char * pFontSpec = (char*) loadFile( "../../../resources/anuvverbubbla_8x8.fnt" ); BitmapGlyphs_p pGlyphs = BitmapGlyphs::create( pFontImg, pFontSpec ); Font_p pFont = Font::create( pGlyphs, 8 ); Textprop prop; prop.setFont(pFont); prop.setSize(8); Textprop_p pProp = prop.reg(); Base::setDefaultTextprop( pProp ); TextStyle_p pStyle = TextStyle::create(); pStyle->setFont(pFont); pStyle->setSize(8); Base::setDefaultStyle(pStyle); // Init skins SDL_Surface * pSDLSurf = IMG_Load( "../../../resources/simple_button.bmp" ); SoftSurface_p pButtonSurface = SoftSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), WG_PIXEL_RGB_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, 0 ); BlockSkin_p pSimpleButtonSkin = BlockSkin::createClickableFromSurface( pButtonSurface, 0, Border(3) ); pSimpleButtonSkin->setContentPadding( Border(5) ); pSDLSurf = IMG_Load( "../../../resources/state_button.bmp" ); SoftSurface_p pStateButtonSurface = SoftSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), WG_PIXEL_RGB_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, 0 ); BlockSkin_p pStateButtonSkin = BlockSkin::createClickSelectableFromSurface( pStateButtonSurface, 0, Border(3) ); pStateButtonSkin->setContentPadding( Border(5) ); pSDLSurf = IMG_Load( "../../../resources/grey_pressable_plate.bmp" ); SoftSurface_p pPressablePlateSurface = SoftSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), WG_PIXEL_RGB_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, 0 ); Skin_p pPressablePlateSkin = BlockSkin::createClickableFromSurface( pPressablePlateSurface, 0, Border(3) ); pSDLSurf = IMG_Load( "../../../resources/list_entry.png" ); SoftSurface_p pListEntrySurface = SoftSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), WG_PIXEL_RGB_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, 0 ); Skin_p pListEntrySkin = BlockSkin::createClickableFromSurface( pListEntrySurface, 0, Border(3) ); //------------------------------------------------------ // Setup a simple GUI consisting of a filled background and // a button using scaled bitmaps. //------------------------------------------------------ FlexPanel_p pFlexPanel = FlexPanel::create(); pFlexPanel->setSkin( ColorSkin::create(Color::burlywood)); pRoot->setWidget(pFlexPanel); /* Filler_p pBackground = Filler::create(); pBackground->setSkin( ColorSkin::create(Color::aqua) ); pFlexPanel->addWidget(pBackground, WG_NORTHWEST, Coord(), WG_SOUTHEAST, Coord()); */ Image_p pImage = Image::create(); pImage->setSkin( pSimpleButtonSkin ); pFlexPanel->addWidget( pImage, Rect(0,0,80,33), WG_CENTER ); // pRoot->msgRouter()->AddCallback( MsgFilter::select(), pButton, myButtonClickCallback ); // Test transparency issue { FlexPanel_p pExtraFlex = FlexPanel::create(); pExtraFlex->setSkin( ColorSkin::create( Color(0,0,0,128))); TextDisplay_p pText = TextDisplay::create(); pText->text.set( "THIS IS SOME TEST TEXT" ); pExtraFlex->addWidget( pText, Rect( 10,10,100,100) ); addResizablePanel( pFlexPanel, pExtraFlex, Base::msgRouter() ); } /* SizeCapsule_p pCapsule = SizeCapsule::create(); pCapsule->setMaxSize( Size(100,1000)); pFlexPanel->addWidget( pCapsule ); StackPanel_p pStack = StackPanel::create(); pCapsule->setWidget( pStack ); TextDisplay_p pText = TextDisplay::create(); pText->text()->set( "THIS IS THE LONG TEXT THAT SHOULD WRAP AND BE FULLY DISPLAYED." ); pStack->addWidget(pText); */ /* CheckBoxPtr pCheckbox = CheckBox::create(); pCheckbox->Label()->set( "CHECKBOX" ); pCheckbox->Icon()->set( pCheckboxSkin ); */ /* ToggleGroup_p pGroup = ToggleGroup::create(); for( int i = 0 ; i < 4 ; i++ ) { ToggleButton_p pCheckbox = ToggleButton::create(); pCheckbox->label.set( "CHECKBOX" ); pCheckbox->setSkin( pStateButtonSkin ); pFlexPanel->addWidget( pCheckbox, Coord(10,20*i) ); pGroup->add( pCheckbox ); } */ /* TextDisplay_p pText = TextDisplay::create(); pText->text.set( "THIS IS THE TEXT\nLINE TWO.\nAN EXTRA LONG LONG LONG LINE TO TEST THE CLIPPING AND RAND BEHAVIOURS." ); pFlexPanel->addWidget( pText, WG_NORTHWEST, WG_EAST ); StandardPresenter_p pPresenter = StandardPresenter::create(); pPresenter->setAlignment( WG_CENTER ); pText->text.setPresenter( pPresenter ); ValueDisplay_p pValue = ValueDisplay::create(); pValue->value.setFormatter( TimeFormatter::create("%2H:%2M:%2S")); pValue->value.set(3600+60+12); pValue->value.setPresenter( pPresenter ); pFlexPanel->addWidget( pValue, WG_WEST, WG_SOUTHEAST ); */ //------------------------------------------------------ // Program Main Loop //------------------------------------------------------ while( !bQuit ) { translateEvents( pInput, pRoot ); SDL_LockSurface(pWinSurf); pRoot->render(); SDL_UnlockSurface(pWinSurf); updateWindowRects( pRoot, pWin ); SDL_Delay(20); } // Exit WonderGUI Base::exit(); // Exit SDL IMG_Quit(); SDL_Quit(); return 0; }
void MsgRouter::setRoot( const RootPanel_p& pRoot ) { m_pRoot = pRoot.rawPtr(); }
void InputHandler::setPointer( const RootPanel_p& pRoot, Coord pos, int64_t timestamp ) { Coord prevPointerPos = m_pointerPos; if( timestamp == 0 ) timestamp = m_timeStamp; m_pointerPos = pos; m_pMarkedRoot = 0; Widget_p pNowMarked = 0; Widget_p pWidgetTarget = 0; if( pRoot && pRoot->geo().contains( pos ) ) { m_pMarkedRoot = pRoot.rawPtr(); pWidgetTarget = pRoot->findWidget( m_pointerPos, SearchMode::ActionTarget ); } // Figure out which button of currently pressed has been pressed the longest. // Mouse is only allowed to mark Widgets that were marked on press of that button. int button = 0; // Button that has been pressed for longest, 0 = no button pressed for( int i = 1 ; i <= MouseButton_Max ; i++ ) { if( m_bButtonPressed[i] && (button == 0 || m_latestPressTimestamps[i] < m_latestPressTimestamps[button]) ) button = i; } // We are only marking the Widget if no mouse button is pressed or the first pressed button // was pressed on it. if( button == 0 || pWidgetTarget == m_latestPressWidgets[button].rawPtr() ) pNowMarked = pWidgetTarget; // Post Leave events for widgets no longer marked, // Post Enter events for new marked widgets // and Move events for those already marked Widget * pFirstAlreadyMarked = _updateEnteredWidgets( pNowMarked.rawPtr(), timestamp ); if( pFirstAlreadyMarked ) Base::msgRouter()->post( new MouseMoveMsg( m_inputId, pFirstAlreadyMarked, m_modKeys, pos, timestamp ) ); // Copy content of pNowMarked to m_pMarkedWidget m_pMarkedWidget = pNowMarked.rawPtr(); // Post events for button drag for( int i = 0 ; i <= MouseButton_Max ; i++ ) { if( m_bButtonPressed[i] ) Base::msgRouter()->post( new MouseDragMsg( m_inputId, (MouseButton) i, m_latestPressWidgets[i].rawPtr(), m_latestPressPosition[i], prevPointerPos, m_modKeys, m_pointerPos, timestamp ) ); } // Update PointerStyle PointerStyle newStyle; if( pNowMarked && pNowMarked->isEnabled() ) newStyle = pNowMarked->pointerStyle(); else if( button != 0 ) newStyle = m_pointerStyle; else newStyle = PointerStyle::Default; if( newStyle != m_pointerStyle ) { Base::msgRouter()->post( new PointerChangeMsg( m_inputId, newStyle ) ); m_pointerStyle = newStyle; } }
int main ( int argc, char** argv ) { //------------------------------------------------------ // Init SDL //------------------------------------------------------ SDL_Init(SDL_INIT_VIDEO); int posX = 100, posY = 100, width = 400, height = 400; SDL_Window * pWin = SDL_CreateWindow("Hello WonderGUI", posX, posY, width, height, SDL_WINDOW_OPENGL); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 3); SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 0 ); SDL_GLContext context = SDL_GL_CreateContext( pWin ); #ifdef WIN32 glewExperimental = GL_TRUE; GLenum err = glewInit(); #endif IMG_Init( IMG_INIT_JPG | IMG_INIT_PNG ); //------------------------------------------------------ // Init WonderGUI //------------------------------------------------------ Base::init(); // Base::initFreeType(); // VectorFont::setSurfaceFactory( GlSurfaceFactory::create() ); InputHandler_p pInput = Base::inputHandler(); pInput->mapKey( SDLK_LEFT, Key::Left ); pInput->mapKey( SDLK_RIGHT, Key::Right ); pInput->mapKey( SDLK_UP, Key::Up ); pInput->mapKey( SDLK_DOWN, Key::Down ); pInput->mapKey( SDLK_BACKSPACE, Key::Backspace ); pInput->mapKey( SDLK_DELETE, Key::Delete ); pInput->mapKey( SDLK_END, Key::End ); pInput->mapKey( SDLK_ESCAPE, Key::Escape ); pInput->mapKey( SDLK_HOME, Key::Home ); pInput->mapKey( SDLK_PAGEDOWN, Key::PageDown ); pInput->mapKey( SDLK_PAGEUP, Key::PageUp ); pInput->mapKey( SDLK_RETURN, Key::Return ); pInput->mapKey( SDLK_SPACE, Key::Space ); pInput->mapKey( SDLK_TAB, Key::Tab ); pInput->mapKey( SDLK_F1, Key::F1 ); pInput->mapKey( SDLK_F2, Key::F2 ); pInput->mapKey( SDLK_F3, Key::F3 ); pInput->mapKey( SDLK_F4, Key::F4 ); pInput->mapKey( SDLK_F5, Key::F5 ); pInput->mapKey( SDLK_F6, Key::F6 ); pInput->mapKey( SDLK_F7, Key::F7 ); pInput->mapKey( SDLK_F8, Key::F8 ); pInput->mapKey( SDLK_F9, Key::F9 ); pInput->mapKey( SDLK_F10, Key::F10 ); pInput->mapKey( SDLK_F11, Key::F11 ); pInput->mapKey( SDLK_F12, Key::F12 ); pInput->mapKey( SDLK_LCTRL, Key::Control ); pInput->mapKey( SDLK_RCTRL, Key::Control ); pInput->mapKey( SDLK_LSHIFT, Key::Shift ); pInput->mapKey( SDLK_RSHIFT, Key::Shift ); pInput->mapKey( SDLK_LALT, Key::Alt ); pInput->mapKey( SDLK_RALT, Key::Alt ); pInput->mapKey( SDLK_KP_ENTER, Key::Return ); pInput->mapCommand( SDLK_ESCAPE, MODKEY_NONE, EditCmd::Escape ); pInput->mapCommand( SDLK_x, MODKEY_CTRL, EditCmd::Cut ); pInput->mapCommand( SDLK_c, MODKEY_CTRL, EditCmd::Copy ); pInput->mapCommand( SDLK_v, MODKEY_CTRL, EditCmd::Paste ); pInput->mapCommand( SDLK_a, MODKEY_CTRL, EditCmd::SelectAll ); pInput->mapCommand( SDLK_z, MODKEY_CTRL, EditCmd::Undo ); pInput->mapCommand( SDLK_z, MODKEY_CTRL_SHIFT, EditCmd::Redo ); GlGfxDevice_p pGfxDevice = GlGfxDevice::create( Size(width,height) ); RootPanel_p pRoot = RootPanel::create( pGfxDevice ); Base::inputHandler()->setFocusedWindow( pRoot ); // MsgLogger_p pLogger = MsgLogger::create( std::cout ); pLogger->logAllMsgs(); pLogger->ignoreMsg( MsgType::Tick ); Base::msgRouter()->broadcastTo( pLogger ); // Init font char * pFontSpec = (char*)loadFile("../resources/anuvverbubbla_8x8.fnt"); assert( glGetError() == 0 ); SDL_Surface * pFontSurf = IMG_Load( "../resources/anuvverbubbla_8x8.png" ); GlSurface_p pFontImg = GlSurface::create( Size(pFontSurf->w,pFontSurf->h), PixelType::BGRA_8, (uint8_t*) pFontSurf->pixels, pFontSurf->pitch ); SDL_FreeSurface( pFontSurf ); assert( glGetError() == 0 ); BitmapFont_p pBmpFont = BitmapFont::create( pFontImg, pFontSpec ); assert( glGetError() == 0 ); // Blob_p pFontFile = loadBlob("../resources/DroidSans.ttf"); // VectorFont_p pFont = VectorFont::create( pFontFile, 1 ); TextStyle_p pStyle = TextStyle::create(); pStyle->setFont(pBmpFont); pStyle->setSize(10); Base::setDefaultStyle(pStyle); // Init skins PixelFormat format; SDL_Surface * pSDLSurf = IMG_Load( "../resources/simple_button.bmp" ); convertSDLFormat( &format, pSDLSurf->format ); GlSurface_p pButtonSurface = GlSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), PixelType::BGR_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, &format ); SDL_FreeSurface( pSDLSurf ); BlockSkin_p pSimpleButtonSkin = BlockSkin::createClickableFromSurface( pButtonSurface, 0, Border(3) ); pSimpleButtonSkin->setContentPadding( Border(5) ); pSDLSurf = IMG_Load( "../resources/state_button.bmp" ); convertSDLFormat( &format, pSDLSurf->format ); GlSurface_p pStateButtonSurface = GlSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), PixelType::BGR_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, &format ); SDL_FreeSurface( pSDLSurf ); BlockSkin_p pStateButtonSkin = BlockSkin::createClickSelectableFromSurface( pStateButtonSurface, 0, Border(3) ); pStateButtonSkin->setContentPadding( Border(5) ); pSDLSurf = IMG_Load( "../resources/grey_pressable_plate.bmp" ); convertSDLFormat( &format, pSDLSurf->format ); GlSurface_p pPressablePlateSurface = GlSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), PixelType::BGR_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, &format ); SDL_FreeSurface( pSDLSurf ); BlockSkin_p pPressablePlateSkin = BlockSkin::createClickableFromSurface( pPressablePlateSurface, 0, Border(3) ); pPressablePlateSkin->setContentPadding( Border(3) ); pSDLSurf = IMG_Load( "../resources/list_entry.png" ); convertSDLFormat( &format, pSDLSurf->format ); GlSurface_p pListEntrySurface = GlSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), PixelType::BGR_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, &format ); SDL_FreeSurface( pSDLSurf ); Skin_p pListEntrySkin = BlockSkin::createClickableFromSurface( pListEntrySurface, 0, Border(3) ); pSDLSurf = IMG_Load( "../resources/frog.jpg" ); convertSDLFormat( &format, pSDLSurf->format ); GlSurface_p pImgSurface = GlSurface::create( Size( pSDLSurf->w, pSDLSurf->h ), PixelType::BGR_8, (unsigned char*) pSDLSurf->pixels, pSDLSurf->pitch, &format ); SDL_FreeSurface( pSDLSurf ); BlockSkin_p pImgSkin = BlockSkin::createStaticFromSurface( pImgSurface, Border(3) ); //------------------------------------------------------ // Setup a simple GUI consisting of a filled background and // a button using scaled bitmaps. //------------------------------------------------------ FlexPanel_p pFlexPanel = FlexPanel::create(); pFlexPanel->setSkin( pImgSkin ); pRoot->setWidget(pFlexPanel); Image_p pImage = Image::create(); pImage->setSkin( pSimpleButtonSkin ); pFlexPanel->addWidget( pImage, Rect(0,0,80,33), Origo::Center ); // pRoot->msgRouter()->AddCallback( MsgFilter::select(), pButton, myButtonClickCallback ); // Test transparency issue { PackPanel_p pVert = PackPanel::create(); PackPanel_p pHorr = PackPanel::create(); Filler_p pFillerEast = Filler::create(); Filler_p pFillerSouth = Filler::create(); pFillerEast->setSkin( pPressablePlateSkin ); pFillerSouth->setSkin( pPressablePlateSkin ); pVert->setOrientation( Orientation::Vertical ); pVert->addWidget( pHorr ); pVert->addWidget( pFillerSouth ); TextEditor_p pText = TextEditor::create(); pText->setSkin( ColorSkin::create( Color::Black ) ); TextStyle_p pBig = TextStyle::create(); pBig->setSize( 16 ); TextStyle_p pRed = TextStyle::create(); pRed->setColor( Color::Red ); pRed->setSize( 25 ); TextStyle_p pAnuv = TextStyle::create(); pAnuv->setFont( pBmpFont ); TextStyle_p pLink = TextStyle::create(); pLink->setColor(Color::Green ); pLink->setLink( TextLink::create( "www.somewhere.net" ) ); pText->text.set( "This is a\npiece of TEXT with LINK" ); pText->text.setCharStyle( pBig, 5, 2 ); pText->text.setCharStyle( pRed, 10, 3 ); pText->text.setCharStyle( pAnuv, 19, 4 ); pText->text.setCharStyle( pLink, 29, 4 ); pHorr->addWidget( pText ); pHorr->addWidget( pFillerEast ); // pFlexPanel->addWidget( pVert, Origo::NorthWest, Origo::SouthEast ); pText->grabFocus(); } { Image_p pImage = Image::create(); pImage->setImage( generateTestSurface() ); pFlexPanel->addWidget( pImage, Origo::NorthWest, Origo::SouthEast, Border(20) ); } /* { TestWidget_p pTest = TestWidget::create(); pFlexPanel->addWidget( pTest, Origo::NorthWest, Origo::SouthEast, Border(20) ); pTest->start(); } */ /* { FlexPanel_p pExtraFlex = FlexPanel::create(); pExtraFlex->setSkin( ColorSkin::create( Color(0,0,0,128))); TextEditor_p pText = TextEditor::create(); TextStyle_p pBig = TextStyle::create(); pBig->setSize( 16 ); TextStyle_p pRed = TextStyle::create(); pRed->setColor( Color::Red ); pRed->setSize( 25 ); TextStyle_p pAnuv = TextStyle::create(); pAnuv->setFont( pBmpFont ); pText->text.set( "This is a\npiece of TEXT" ); pText->text.setCharStyle( pBig, 5, 2 ); pText->text.setCharStyle( pRed, 10, 3 ); pText->text.setCharStyle( pAnuv, 19, 20 ); pExtraFlex->addWidget( pText, Rect( 10,10,100,100) ); addResizablePanel( pFlexPanel, pExtraFlex, Base::msgRouter() ); pText->grabFocus(); translateEvents( pInput, pRoot ); pText->text.caretTextBegin(); pText->text.caretLineEnd(); } */ /* { VolumeMeter_p p = VolumeMeter::create(); p->setSkin( pPressablePlateSkin ); addResizablePanel( pFlexPanel, p, Base::msgRouter() ); } */ /* SizeCapsule_p pCapsule = SizeCapsule::create(); pCapsule->setMaxSize( Size(100,1000)); pFlexPanel->addWidget( pCapsule ); StackPanel_p pStack = StackPanel::create(); pCapsule->setWidget( pStack ); TextDisplay_p pText = TextDisplay::create(); pText->text()->set( "THIS IS THE LONG TEXT THAT SHOULD WRAP AND BE FULLY DISPLAYED." ); pStack->addWidget(pText); */ /* CheckBoxPtr pCheckbox = CheckBox::create(); pCheckbox->Label()->set( "CHECKBOX" ); pCheckbox->Icon()->set( pCheckboxSkin ); */ /* ToggleGroup_p pGroup = ToggleGroup::create(); for( int i = 0 ; i < 4 ; i++ ) { ToggleButton_p pCheckbox = ToggleButton::create(); pCheckbox->label.set( "CHECKBOX" ); pCheckbox->setSkin( pStateButtonSkin ); pFlexPanel->addWidget( pCheckbox, Coord(10,20*i) ); pGroup->add( pCheckbox ); } */ /* TextDisplay_p pText = TextDisplay::create(); pText->text.set( "THIS IS THE TEXT\nLINE TWO.\nAN EXTRA LONG LONG LONG LINE TO TEST THE CLIPPING AND RAND BEHAVIOURS." ); pFlexPanel->addWidget( pText, WG_NORTHWEST, WG_EAST ); StandardPrinter_p pPrinter = StandardPrinter::create(); pPrinter->setAlignment( WG_CENTER ); pText->text.setPrinter( pPrinter ); ValueDisplay_p pValue = ValueDisplay::create(); pValue->value.setFormatter( TimeFormatter::create("%2H:%2M:%2S")); pValue->value.set(3600+60+12); pValue->value.setPrinter( pPrinter ); pFlexPanel->addWidget( pValue, WG_WEST, WG_SOUTHEAST ); */ /* FpsDisplay_p pFps = FpsDisplay::create(); pFps->setSkin( pPressablePlateSkin ); pFlexPanel->addWidget( pFps, Coord(0,0), Origo::SouthWest ); */ //------------------------------------------------------ // Program Main Loop //------------------------------------------------------ int tick = 0; /* I need the following crap on my Windows dev machine to make something that resembles single buffering work :( Apparently single buffering in SDL2/Windows doesn't work on my dev machine, so I get double buffering although I specify single buffering when initializing. (don't know if it is SDL's, Windows' or crappy device drivers fault, it works fine in SDL2/Linux on same hardware) So I render to the front buffer instead, but apparently nothing will be displayed until the rendering pipeline has been filled and flushed twice... so we just clear the color buffer and flush() to make sure that everything is displayed on first render call. */ glDrawBuffer(GL_FRONT); glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT ); glFlush(); while( !bQuit ) { translateEvents( pInput, pRoot ); pRoot->render(); // updateWindowRects( pRoot, pWin ); // glClearColor(0.1f, 0.3f, 0.3f, 1.0f ); // glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // glFlush(); pGfxDevice->beginRender(); // pGfxDevice->setTintColor(Color::Red ); // pGfxDevice->fill( Rect(1,1,320-2,400-2), Color::Aquamarine); // pGfxDevice->wg::GfxDevice::blit( pButtonSurface, 50, 50 ); // pGfxDevice->wg::GfxDevice::stretchBlit(pButtonSurface, Rect(50,50,160,40)); Color plotColors[400]; Coord plotCoords[400]; for( int i = 0 ; i < 400 ; i++ ) { plotColors[i] = Color::Red; plotCoords[i] = Coord(i,i); } // pGfxDevice->clipPlotPixels( Rect(0,0,width,height), 100, plotCoords, plotColors); // for(int x = 0 ; x < 200 ; x++ ) // { // pGfxDevice->clipDrawVertLine(Rect(0,0,width,height), Coord(x*2,x), 40, Color::Aquamarine); // } // pGfxDevice->clipDrawHorrLine(Rect(10,10,width-20,height-20), Coord(0,20), 800, Color::Aquamarine); // pGfxDevice->clipDrawVertLine(Rect(10,10,width-20,height-20), Coord(20,0), 800, Color::Aquamarine); // pGfxDevice->drawLine( Coord(10,10), Coord(200,40), Color::Red, 3.f ); // pGfxDevice->fill(Rect(21, 21, 100, 100 ), Color::AntiqueWhite ); // pGfxDevice->fillSubPixel(RectF(21.8f, 21.5f, 0.4f, 0.4f ), Color::AntiqueWhite ); pGfxDevice->endRender(); SDL_Delay(20); tick++; } // Exit WonderGUI Base::exit(); // Exit SDL IMG_Quit(); SDL_Quit(); return 0; }