void ScreenFader::BeginFade(const Color &final_color, uint32_t duration, bool transitional) { // If last fade is made by the system, don't permit to fade: if(!transitional && _is_fading && _transitional_fading) return; _transitional_fading = transitional; _is_fading = true; _end_time = duration; _initial_color = _current_color; _final_color = final_color; _current_time = 0; // If we are fading to or from transparent, then the RGB values do not need to be interpolated if(IsFloatEqual(_final_color[3], 0.0f)) { _interpolate_rgb_values = true; _current_color[0] = _initial_color[0]; _current_color[1] = _initial_color[1]; _current_color[2] = _initial_color[2]; } else if(IsFloatEqual(_initial_color[3], 0.0f)) { _interpolate_rgb_values = true; _current_color[0] = _final_color[0]; _current_color[1] = _final_color[1]; _current_color[2] = _final_color[2]; } else { _interpolate_rgb_values = false; } Update(0); // Do an initial update } // void ScreenFader::BeginFade(const Color &final, uint32_t time)
void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR lParam) { if (m_bEnableNotify) { if (wParam == SBT_VSCROLL) { switch (msg) { case PNM_SETSCROLLINFO: if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) { if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) || !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) { m_bSizeChanged = TRUE; if (CPWL_Wnd * pParent = this->GetParentWindow()) { pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); } m_fOldMax = pInfo->fContentMax; m_fOldMin = pInfo->fContentMin; return; } } } } } CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam); if (m_bEnableNotify) { switch (msg) { case PNM_SETCARETINFO: if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam) { PWL_CARET_INFO newInfo = *pInfo; newInfo.bVisible = TRUE; newInfo.ptHead = this->ChildToParent(pInfo->ptHead); newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot); if (CPWL_Wnd * pParent = this->GetParentWindow()) { pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0); } } break; } } }
void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, FX_FLOAT fContentMin, FX_FLOAT fContentMax, FX_FLOAT fSmallStep, FX_FLOAT fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; this->OnNotify(this,PNM_SETSCROLLINFO,SBT_VSCROLL,(FX_INTPTR)&Info); // PWL_TRACE("set scroll info:%f\n",fContentMax - fContentMin); if (IsFloatBigger(Info.fPlateWidth,Info.fContentMax-Info.fContentMin) || IsFloatEqual(Info.fPlateWidth,Info.fContentMax-Info.fContentMin)) { this->ShowVScrollBar(FALSE); } else { this->ShowVScrollBar(TRUE); } }
void CPWL_List_Notify::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, FX_FLOAT fContentMin, FX_FLOAT fContentMax, FX_FLOAT fSmallStep, FX_FLOAT fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; m_pList->OnNotify(m_pList, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info); if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) { if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { if (pScroll->IsVisible()) { pScroll->SetVisible(false); m_pList->RePosChildWnd(); } } else { if (!pScroll->IsVisible()) { pScroll->SetVisible(true); m_pList->RePosChildWnd(); } } } }
void CPWL_List_Notify::IOnSetScrollInfoY(float fPlateMin, float fPlateMax, float fContentMin, float fContentMax, float fSmallStep, float fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; m_pList->SetScrollInfo(Info); CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar(); if (!pScroll) return; if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { if (pScroll->IsVisible()) { pScroll->SetVisible(false); m_pList->RePosChildWnd(); } } else { if (!pScroll->IsVisible()) { pScroll->SetVisible(true); m_pList->RePosChildWnd(); } } }
void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) { if (!IsFloatEqual(m_ptScrollPos.y, fy)) { CFX_FloatRect rcPlate = GetPlateRect(); CFX_FloatRect rcContent = GetContentRectInternal(); if (rcPlate.Height() > rcContent.Height()) { fy = rcPlate.top; } else { if (IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { fy = rcContent.bottom + rcPlate.Height(); } else if (IsFloatBigger(fy, rcContent.top)) { fy = rcContent.top; } } m_ptScrollPos.y = fy; InvalidateItem(-1); if (m_pNotify) { if (!m_bNotifyFlag) { m_bNotifyFlag = true; m_pNotify->IOnSetScrollPosY(fy); m_bNotifyFlag = false; } } } }
void TextImage::Draw(const Color &draw_color) const { // Don't draw anything if this image is completely transparent (invisible) if(IsFloatEqual(draw_color[3], 0.0f)) return; VideoManager->PushMatrix(); for(uint32 i = 0; i < _text_sections.size(); ++i) { _text_sections[i]->Draw(draw_color); VideoManager->MoveRelative(0.0f, TextManager->GetFontProperties(_style.font)->line_skip * -VideoManager->_current_context.coordinate_system.GetVerticalDirection()); } VideoManager->PopMatrix(); }
void CPWL_EditCtrl::IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, FX_FLOAT fContentMin, FX_FLOAT fContentMax, FX_FLOAT fSmallStep, FX_FLOAT fBigStep) { PWL_SCROLL_INFO Info; Info.fPlateWidth = fPlateMax - fPlateMin; Info.fContentMin = fContentMin; Info.fContentMax = fContentMax; Info.fSmallStep = fSmallStep; Info.fBigStep = fBigStep; OnNotify(this, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info); if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) || IsFloatEqual(Info.fPlateWidth, Info.fContentMax - Info.fContentMin)) { ShowVScrollBar(FALSE); } else { ShowVScrollBar(TRUE); } }
void TextElement::Draw(const Color &draw_color) const { // Don't draw anything if this image is completely transparent (invisible) if(IsFloatEqual(draw_color[3], 0.0f)) return; VideoManager->PushMatrix(); _DrawOrientation(); if(draw_color == Color::white) { _DrawTexture(_color); } else { Color modulated_colors[4]; modulated_colors[0] = _color[0] * draw_color; modulated_colors[1] = _color[1] * draw_color; modulated_colors[2] = _color[2] * draw_color; modulated_colors[3] = _color[3] * draw_color; _DrawTexture(modulated_colors); } VideoManager->PopMatrix(); } // void TextElement::Draw(const Color& draw_color) const
bool CQuater::operator!=(const CQuater& q) { return (!IsFloatEqual(x,q.x) || !IsFloatEqual(y,q.y) || !IsFloatEqual(z,q.z) || !IsFloatEqual(w,q.w)); }
bool CQuater::operator==(const CQuater& q) { return (IsFloatEqual(x,q.x) && IsFloatEqual(y,q.y) && IsFloatEqual(z,q.z) && IsFloatEqual(w,q.w)); }
void MenuWindow::Update(uint32 frame_time) { _display_timer += frame_time; if (_display_timer >= VIDEO_MENU_SCROLL_TIME) { if (_window_state == VIDEO_MENU_STATE_SHOWING) _window_state = VIDEO_MENU_STATE_SHOWN; else if (_window_state == VIDEO_MENU_STATE_HIDING) _window_state = VIDEO_MENU_STATE_HIDDEN; } // TODO: This does not need to be done every update call (it always retuns the same thing so long // as the window does not move. This is a performance problem and should be fixed so that this is // only done with the window size or alignment changes. if (_window_state == VIDEO_MENU_STATE_HIDDEN || _window_state == VIDEO_MENU_STATE_SHOWN) { // if (_is_scissored == true) { float x_buffer = (_width - _inner_width) / 2; float y_buffer = (_height - _inner_height) / 2; float left, right, bottom, top; left = 0.0f; right = _width; bottom = 0.0f; top = _height; VideoManager->PushState(); VideoManager->SetDrawFlags(_xalign, _yalign, 0); CalculateAlignedRect(left, right, bottom, top); VideoManager->PopState(); _scissor_rect = VideoManager->CalculateScreenRect(left, right, bottom, top); _scissor_rect.left += static_cast<int32>(x_buffer); _scissor_rect.width -= static_cast<int32>(x_buffer * 2); _scissor_rect.top += static_cast<int32>(y_buffer); _scissor_rect.height -= static_cast<int32>(y_buffer * 2); // } _is_scissored = false; return; } _is_scissored = true; // Holds the amount of the window that should be drawn (1.0 == 100%) float draw_percent = 1.0f; if (_display_mode != VIDEO_MENU_INSTANT && _window_state != VIDEO_MENU_STATE_SHOWN) { float time = static_cast<float>(_display_timer) / static_cast<float>(VIDEO_MENU_SCROLL_TIME); if (time > 1.0f) time = 1.0f; if (_window_state == VIDEO_MENU_STATE_HIDING) time = 1.0f - time; draw_percent = time; } if (IsFloatEqual(draw_percent, 1.0f) == false) { if (_display_mode == VIDEO_MENU_EXPAND_FROM_CENTER) { float left, right, bottom, top; left = 0.0f; right = _width; bottom = 0.0f; top = _height; VideoManager->PushState(); VideoManager->SetDrawFlags(_xalign, _yalign, 0); CalculateAlignedRect(left, right, bottom, top); VideoManager->PopState(); float center = (top + bottom) * 0.5f; bottom = center * (1.0f - draw_percent) + bottom * draw_percent; top = center * (1.0f - draw_percent) + top * draw_percent; _scissor_rect = VideoManager->CalculateScreenRect(left, right, bottom, top); } } } // void MenuWindow::Update(uint32 frame_time)