void AppGroupView::_DrawCloseButton(const BRect& updateRect) { PushState(); BRect closeRect = fCloseRect; rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); float tint = B_DARKEN_2_TINT; if (fCloseClicked) { BRect buttonRect(closeRect.InsetByCopy(-4, -4)); be_control_look->DrawButtonFrame(this, buttonRect, updateRect, base, base, BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME); be_control_look->DrawButtonBackground(this, buttonRect, updateRect, base, BControlLook::B_ACTIVATED); tint *= 1.2; closeRect.OffsetBy(1, 1); } base = tint_color(base, tint); SetHighColor(base); SetPenSize(2); StrokeLine(closeRect.LeftTop(), closeRect.RightBottom()); StrokeLine(closeRect.LeftBottom(), closeRect.RightTop()); PopState(); }
nsAccessibleTreeWalker::~nsAccessibleTreeWalker() { // Clear state stack from memory while (NS_SUCCEEDED(PopState())) /* do nothing */ ; MOZ_COUNT_DTOR(nsAccessibleTreeWalker); }
tGameEngine::~tGameEngine() { while (m_States.empty() == false) { PopState(); } }
virtual void Draw(BRect updateRect) { BRegion region; region.Include(BRect(20, 20, 40, 40)); region.Include(BRect(30, 30, 80, 80)); ConstrainClippingRegion(®ion); SetHighColor(55, 255, 128, 255); FillRect(BRect(0, 0, 100, 100)); PushState(); SetOrigin(15, 15); ConstrainClippingRegion(®ion); SetHighColor(155, 255, 128, 255); FillRect(BRect(0, 0, 100, 100)); // ConstrainClippingRegion(NULL); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(2, 2), BPoint(80, 80)); SetHighColor(255, 0, 0, 255); StrokeLine(BPoint(2, 2), BPoint(4, 2)); PopState(); SetHighColor(0, 0, 0, 255); StrokeLine(BPoint(4, 2), BPoint(82, 80)); }
void BBox::Draw(BRect updateRect) { if (!IsVisible() || fBorder == B_NO_BORDER) return; e_theme_engine *theme = get_current_theme_engine(); if (theme == NULL || theme->get_border_margins == NULL || theme->draw_border == NULL) return; float l = 0, t = 0, r = 0, b = 0; theme->get_border_margins(theme, this, &l, &t, &r, &b, fBorder, PenSize()); BRect rect = Frame().OffsetToSelf(B_ORIGIN); if (!(fLabelView == NULL || fLabelView->Frame().Width() <= 0 || fLabelView->Frame().Height() < t)) rect.top += (fLabelView->Frame().Height() - t) / 2.f; PushState(); BRegion clipping(updateRect); if (!(fLabelView == NULL || fLabelView->Frame().IsValid() == false)) clipping.Exclude(fLabelView->Frame()); ConstrainClippingRegion(&clipping); if (clipping.CountRects() > 0) theme->draw_border(theme, this, rect, fBorder, PenSize()); PopState(); }
void VideoEngine::DrawGrid(float x, float y, float x_step, float y_step, const Color &c) { PushState(); Move(0, 0); float x_max = _current_context.coordinate_system.GetRight(); float y_max = _current_context.coordinate_system.GetBottom(); std::vector<GLfloat> vertices; int32 num_vertices = 0; for(; x <= x_max; x += x_step) { vertices.push_back(x); vertices.push_back(_current_context.coordinate_system.GetBottom()); vertices.push_back(x); vertices.push_back(_current_context.coordinate_system.GetTop()); num_vertices += 2; } for(; y < y_max; y += y_step) { vertices.push_back(_current_context.coordinate_system.GetLeft()); vertices.push_back(y); vertices.push_back(_current_context.coordinate_system.GetRight()); vertices.push_back(y); num_vertices += 2; } glColor4fv(&c[0]); DisableTexture2D(); EnableVertexArray(); glVertexPointer(2, GL_FLOAT, 0, &(vertices[0])); glDrawArrays(GL_LINES, 0, num_vertices); PopState(); }
void GameEngine::Escaper() //this should be done in seperate class if I'm correct? { if(event.type == ALLEGRO_EVENT_KEY_DOWN) //this thing shouldn't be here imo { switch(event.keyboard.keycode) { case ALLEGRO_KEY_ESCAPE: if (IsGameStateActive()) { PushState(menuState); menuState->SwitchToMenu("Wave Menu"); } else if (menuState->CurrentMenu->GetName() == "Wave Menu") { PopState(); } break; case ALLEGRO_KEY_B: //this should seriously be left somewhere else, or this method should change its name if (IsGameStateActive()) { if (collisionDetector->IsHitboxDisplayEnabled()) collisionDetector->EnableHitboxDisplay(false); else collisionDetector->EnableHitboxDisplay(true); } break; } } else if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) Quit(); }
/***************************************************************** * Update(): Handles updating the current state and * switching states at the correct point * * Ins: N/A * * Outs: N/A * * Returns: N/A * * Mod. Date: 8/11/2015 * Mod. Initials: SS *****************************************************************/ bool CStateMachine::Update() { m_AudioManager.Update(); Input->Update(); IState* m_pCurrState = activeStates.top(); if (m_pCurrState) { EInputResult result = m_pCurrState->Input(); switch (result) { case eContinue: m_pCurrState->Update(); return true; break; case eRemove: PopState(); break; default: break; } } return false; }
void NetListView::FrameResized(float width, float height) { BListView::FrameResized(width, height); //Ensure the bevel on the right is drawn properly if(width < oldWidth) oldWidth = width; PushState(); BRect invalRect(oldWidth, 0, oldWidth, height); ConvertFromParent(&invalRect); BRegion lineRegion(invalRect); ConstrainClippingRegion(&lineRegion); Draw(invalRect); oldWidth = width; PopState(); //Do word wrapping BFont curFont; GetFont(&curFont); float itemWidth = Bounds().Width(); float wrapWidth = (itemWidth - 6)/curFont.Size(); for(int itemNum = 0; itemNum < CountItems(); itemNum++) { NetListItem* item = (NetListItem*)(Items()[itemNum]); item->SetWidth(itemWidth); item->CalcWordWrap(wrapWidth); } //DoForEach(UpdateItem, (void*)this); Invalidate(); BListView::FrameResized(width, height); }
void CShopState::KeyInput(const SDL_Event& rEvent) { if (rEvent.type == SDL_KEYDOWN) if (rEvent.key.keysym.sym == SDLK_BACKQUOTE) PopState(); mpShop->KeyInput(rEvent); }
void TExportZone::DrawInMarker(BRect updateRect) { // Set up environment PushState(); BPoint drawPt; // Draw left marker if (updateRect.Intersects(m_InRect) ) { // Draw indicator in new location drawPt.Set(m_InRect.left, m_InRect.top); DrawBitmap(m_InMarker, drawPt); } // Draw right marker if (updateRect.Intersects(m_OutRect) ) { // Draw indicator in new location drawPt.Set(m_OutRect.left, m_OutRect.top); DrawBitmap(m_OutMarker, drawPt); } // Restore environment PopState(); }
NS_IMETHODIMP nsAccessibleTreeWalker::GetNextSibling() { // Make sure mState.prevState and mState.siblingIndex are initialized so we can walk forward NS_ASSERTION(mState.prevState && mState.siblingIndex != eSiblingsUninitialized, "Error - GetNextSibling() only works after a GetFirstChild(), so we must have a prevState."); mState.accessible = nsnull; while (PR_TRUE) { // Get next frame UpdateFrame(PR_FALSE); GetNextDOMNode(); if (!mState.domNode) { // Done with current siblings PopState(); // Use parent - go up in stack. Can always pop state because we have to start with a GetFirstChild(). if (!mState.prevState) { mState.accessible = nsnull; break; // Back to original accessible that we did GetFirstChild() from } } else if ((mState.domNode != mState.prevState->domNode && GetAccessible()) || NS_SUCCEEDED(GetFirstChild())) { return NS_OK; // if next is accessible, use it } } return NS_ERROR_FAILURE; }
void tGameEngine::ChangeState(tState * pState) { if (m_States.empty() == false) { PopState(); } PushState(pState); }
void AudacityProject::SetStateTo(unsigned int n) { TrackList *l = mUndoManager.SetStateTo(n, &mViewInfo.sel0, &mViewInfo.sel1); PopState(l); FixScrollbars(); mTrackPanel->Refresh(false); }
nsAccTreeWalker::~nsAccTreeWalker() { // Clear state stack from memory while (mState) PopState(); MOZ_COUNT_DTOR(nsAccTreeWalker); }
void VikeWin::ResetState() { while(m_state.Count() > 1){ PopState(); } SetState(VIKE_START); ClearDupNumber(); }
NS_IMETHODIMP nsThebesRenderingContext::PopTranslation(PushedTranslation* aState) { PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::PopTranslation\n", this)); // XXX this is slow! PopState(); return NS_OK; }
void TCueSheetTimeView::Draw(BRect updateRect) { // Set up environment PushState(); const BRect bounds = Bounds(); BPoint startPt, endPt; // Draw TimeRect frame SetHighColor(kLightGrey); FillRect(bounds); // Draw black outline SetHighColor(kBlack); startPt.Set(bounds.left, bounds.top); endPt.Set(bounds.left, bounds.bottom); StrokeLine(startPt, endPt); startPt.Set(bounds.right, bounds.top); endPt.Set(bounds.right, bounds.bottom); StrokeLine(startPt, endPt); // Draw shadow SetHighColor(kMediumGrey); startPt.Set(bounds.right-1, bounds.top); endPt.Set(bounds.right-1, bounds.bottom); StrokeLine(startPt, endPt); startPt.Set(bounds.right-1, bounds.bottom); endPt.Set(bounds.left+1, bounds.bottom); StrokeLine(startPt, endPt); // Draw highlight SetHighColor(kWhite); startPt.Set(bounds.left+1, bounds.bottom - 2); endPt.Set(bounds.left+1, bounds.top); StrokeLine(startPt, endPt); startPt.Set(bounds.left+1, bounds.top); endPt.Set(bounds.right-2, bounds.top); StrokeLine(startPt, endPt); // Draw cue sheet start time BFont font; GetFont(&font); SetFont(be_bold_font); SetHighColor(kBlack); BPoint textPt; char timeStr[256]; int32 startTime = m_CueSheetWindow->GetCueSheetView()->StartTime(); textPt.Set(bounds.left + 9, bounds.top + 16); TimeToString(startTime, m_CueSheetWindow->GetCueSheetView()->GetTimeFormat(), timeStr, FALSE); DrawString(timeStr, textPt); // Restore environment PopState(); }
/* virtual */ OP_STATUS Google2011NetworkApiResponseParser::LeaveObject() { RETURN_IF_ERROR(PopState()); // PopAttributeState returns ERR if there is nothing left on the state stack. // Here is it a valid situation if we're leaving the top-level object. OpStatus::Ignore(PopAttributeState()); return OpStatus::OK; }
void AudioView::Redo() { wxASSERT(undoManager.RedoAvailable()); TrackList *l = undoManager.Redo(&sel0, &sel1); PopState(l); FixScrollbars(); REDRAW(trackPanel); }
OP_STATUS Google2011NetworkApiResponseParser::PopAttributeState() { if (m_state_stack_size == 0) return OpStatus::ERR; if (IsAttributeState(m_state_stack[m_state_stack_size-1])) return PopState(); else return OpStatus::OK; }
void CContinueState::KeyInput(const SDL_Event& rEvent) { if (rEvent.key.keysym.sym == SDLK_z) { mpMenu->Select(); if (mpMenu->GetIndex() == 1) { PopState();} if (mpMenu->GetIndex() == 2) { ChangeState(State::INTRO);} //todo: gameoverstate } if (rEvent.key.keysym.sym == SDLK_DOWN) mpMenu->MoveIndex(1); else if (rEvent.key.keysym.sym == SDLK_UP) mpMenu->MoveIndex(-1); }
void VideoEngine::_DrawFPS() { if(!_fps_display || !_FPS_textimage) return; PushState(); SetStandardCoordSys(); SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, VIDEO_X_NOFLIP, VIDEO_Y_NOFLIP, VIDEO_BLEND, 0); Move(930.0f, 40.0f); // Upper right hand corner of the screen _FPS_textimage->Draw(); PopState(); } // void GUISystem::_DrawFPS()
void nuiDrawContext::DrawShape(nuiShape* pShape, nuiShapeMode Mode, float Quality) { NGL_ASSERT(pShape != NULL); PushState(); switch (Mode) { case eStrokeShape: { nuiRenderObject* pObject = pShape->Outline(Quality, mCurrentState.mLineWidth, mCurrentState.mLineJoin, mCurrentState.mLineCap); SetFillColor(GetStrokeColor()); SetTexture(mpAATexture); EnableTexturing(true); EnableBlending(true); SetBlendFunc(nuiBlendTransp);//GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawObject(*pObject); delete pObject; } break; case eFillShape: { nuiTessellator* pTess = new nuiTessellator(pShape); pTess->SetFill(true); nuiRenderObject* pObject = pTess->Generate(Quality); DrawObject(*pObject); delete pObject; delete pTess; } break; case eStrokeAndFillShape: { { nuiRenderObject* pObject = pShape->Fill(Quality); DrawObject(*pObject); delete pObject; } { nuiRenderObject* pObject = pShape->Outline(Quality, mCurrentState.mLineWidth, mCurrentState.mLineJoin, mCurrentState.mLineCap); SetFillColor(GetStrokeColor()); SetTexture(mpAATexture); EnableTexturing(true); EnableBlending(true); SetBlendFunc(nuiBlendTransp);//GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawObject(*pObject); delete pObject; } } break; case eDefault: //? break; } PopState(); }
/* Main Loop running the project engine. Cycles through an infinite loop while States are still running. Pushes in the first state of main menu of the editor application and it will cycle through the States registered events Then it will perform that States keypress method and mouse activity method. If a states resulting processing will decide that the state is no longer needed. EG: closing current map or option menu it will push or pop the State stack and destroy/dispose/clean those objects from memory. If those State directions have not been triggered. The game will run the current states Update(game logic) method and then run the Draw method */ void Engine::Run() { ALLEGRO_EVENT ev; while(currentState_->GetRunning()){ al_wait_for_event(currentState_->GetEventQueue(),&ev); currentState_->SetEvent(&ev); currentState_->KeyPress(); currentState_->MouseActivity(); if(currentState_->GetStateDirection() == EnumDLL::STATEDIRECTION::PUSH){ PushState(); continue; } else if(currentState_->GetStateDirection() == EnumDLL::STATEDIRECTION::POP){ PopState(); continue; } else if(currentState_->GetStateDirection() == EnumDLL::STATEDIRECTION::POPPUSH){ PopPushState(); continue; } else if(currentState_->GetStateDirection() == EnumDLL::STATEDIRECTION::POPTOFIRST){ PopStateToFirst(); continue; } if(currentState_->GetEvent()->type == ALLEGRO_EVENT_DISPLAY_CLOSE) { //close window if display is closed via X in top right corner currentState_->SetRunning(false); } currentState_->Update(); if(currentState_->GetRedraw() && al_is_event_queue_empty(currentState_->GetEventQueue())) { currentState_->SetRedraw(false); currentState_->Draw(); //bread and butter al_draw_textf(currentState_->GetFont(), chosenColorText_, 0, 20, ALLEGRO_ALIGN_LEFT, "%f" , ev.timer.timestamp); al_flip_display(); al_clear_to_color(chosenColor_);//clears color to dark green to remove all back image } /* Get state done or not if done == true delete current state and Set new state if not done and state change push new state to stack if neither do normal again (-2 default) */ //Get keypress state //mmm change state } }
void ETextEditable::DrawSelectedBackground(ERect updateRect) { if(fCount <= 0 || !IsEnabled()) return; if(fSelectStart < 0 || fSelectEnd < 0 || fSelectEnd < fSelectStart || fSelectEnd >= fCount || fCharWidths == NULL) return; ERect rect = Frame().OffsetToSelf(E_ORIGIN); rect.left += fMargins.left; rect.top += fMargins.top; rect.right -= fMargins.right; rect.bottom -= fMargins.bottom; if(!rect.IsValid()) return; EFont font; e_font_height fontHeight; GetFont(&font); font.GetHeight(&fontHeight); float sHeight = fontHeight.ascent + fontHeight.descent; ERect hlRect; if(!GetCharLocation(0, &(hlRect.left), NULL, &font)) return; hlRect.top = rect.Center().y - sHeight / 2.f - 1; hlRect.bottom = rect.Center().y + sHeight / 2.f + 1; for(eint32 i = 0; i < fSelectStart; i++) { hlRect.left += (float)ceil((double)fCharWidths[i]); hlRect.left += (float)ceil((double)(font.Spacing() * font.Size())); } hlRect.right = hlRect.left; for(eint32 i = fSelectStart; i <= fSelectEnd; i++) { hlRect.right += (float)ceil((double)fCharWidths[i]); if(i != fSelectEnd) hlRect.right += (float)ceil((double)(font.Spacing() * font.Size())); } hlRect &= updateRect; if(!hlRect.IsValid()) return; e_rgb_color hlColor = e_ui_color(E_DOCUMENT_HIGHLIGHT_COLOR); PushState(); SetDrawingMode(E_OP_COPY); SetPenSize(0); SetHighColor(hlColor); FillRect(hlRect, E_SOLID_HIGH); PopState(); }
void ETextEditable::DrawCursor() { if(!IsEnabled() || !IsEditable() || fPosition < 0 || fPosition > fCount || (fCount > 0 && fCharWidths == NULL)) return; if(Window() == NULL || Window()->IsActivate() == false) return; if(!(IsFocus() || IsFocusChanging())) return; ERect rect = Frame().OffsetToSelf(E_ORIGIN); rect.left += fMargins.left; rect.top += fMargins.top; rect.right -= fMargins.right; rect.bottom -= fMargins.bottom; if(!rect.IsValid()) return; EFont font; e_font_height fontHeight; GetFont(&font); font.GetHeight(&fontHeight); float sHeight = fontHeight.ascent + fontHeight.descent; EPoint pt1; if(!GetCharLocation(fPosition, &(pt1.x), NULL, &font)) return; pt1.x -= 1; pt1.y = rect.Center().y - sHeight / 2.f; EPoint pt2 = pt1; pt2.y += sHeight; e_rgb_color crColor = e_ui_color(E_DOCUMENT_CURSOR_COLOR); if(IsFocusChanging() && !IsFocus()) { if(fPosition > fSelectStart && fPosition <= fSelectEnd && fSelectEnd > fSelectStart) { crColor = e_ui_color(E_DOCUMENT_HIGHLIGHT_COLOR); } else { crColor = e_ui_color(E_DOCUMENT_BACKGROUND_COLOR); } } PushState(); SetDrawingMode(E_OP_COPY); SetPenSize(0); SetHighColor(crColor); StrokeLine(pt1, pt2, E_SOLID_HIGH); PopState(); }
void cMessageBoxWindow::OnEvent(const cEvent& event) { if (event.type == cEvent::TYPE_CLICK) { switch (event.widget) { case pYesButton: { listener.OnMessageBoxReturnYes(); PopState(); break; } case pNoButton: { listener.OnMessageBoxReturnNo(); PopState(); break; } case pCancelButton: { listener.OnMessageBoxReturnCancel(); PopState(); break; } }; } }
void CContinueState::Update(const int& rDeltaTime) { mpMenu->Update(rDeltaTime, mAlpha); mpTitle->Update(); mpCounter->Update(); if (mpCounter->IsDone()) PopState(); if (mFadeTimer.GetTicks() > 10) { if (mAlpha < 100) mAlpha += 5; mFadeTimer.Start(); } }
void GameStateManager::Stop() { if (!s_Started) return; while (!s_StateStack.empty()) { GameState* st = PopState(); delete st; } s_Started = false; }