void CUIWindow::Update() { if (GetUICursor()->IsVisible()) { bool cursor_on_window; Fvector2 temp = GetUICursor()->GetCursorPosition(); Frect r; GetAbsoluteRect (r); cursor_on_window = !!r.in(temp); #ifndef NDEBUG if(cursor_on_window&&g_show_wnd_rect){ Frect r; GetAbsoluteRect(r); add_rect_to_draw(r); } #endif // RECEIVE and LOST focus if(m_bCursorOverWindow != cursor_on_window) { if(cursor_on_window) OnFocusReceive(); else OnFocusLost(); } } for(WINDOW_LIST_it it = m_ChildWndList.begin(); m_ChildWndList.end()!=it; ++it){ if(!(*it)->IsShown()) continue; (*it)->Update(); } }
void OOPLyric::OnTimerNotify(wxTimerEvent &) { wxASSERT(IsOk()); if (m_Window->IsExiting()) { return; } if (m_stopWatch->Time() >= m_parser->GetTimeSum()) { m_timer.Stop(); return; } //----------------------------------------------------- VdkDC dc(m_Window, GetAbsoluteRect(), NULL); LineIter next(m_currLine); ++next; if (next != m_parser->end()) { if ((*next)->GetStartTime() <= m_stopWatch->Time()) { NextLine(&dc, false); return; } } CorrectViewStart(&dc); }
CUIDragItem* CUICellItem::CreateDragItem() { CUIDragItem* tmp; tmp = xr_new<CUIDragItem>(this); Frect r; GetAbsoluteRect(r); if( m_UIStaticItem.GetFixedLTWhileHeading() ) { float w, h; w = r.width(); h = r.height(); if (Heading()) { // исправление пропорций w = w / m_cell_size.x * m_cell_size.y; h = h / m_cell_size.y * m_cell_size.x; } Fvector2 cp = GetUICursor()->GetCursorPosition(); // поворот на 90 градусов, и центрирование по курсору мыша r.x1 = (cp.x - h / 2.0f); r.y1 = (cp.y - w / 2.0f); r.x2 = r.x1 + h; r.y2 = r.y1 + w; } tmp->Init(GetShader(),r,GetUIStaticItem().GetOriginalRect()); return tmp; }
void ComboBox::PopupDropDownWindow() { auto window = GetWindow(); if (window == nullptr) { return; } auto window_rect = GetAbsoluteRect(); window_rect.Inflate(-1, 0); window_rect.position.y += GetHeight() - 2; std::size_t visible_item_count = drop_down_list_box_->GetItemCount(); visible_item_count = std::max(visible_item_count, GetMinimumVisibleItemCount()); visible_item_count = std::min(visible_item_count, GetMaximumVisibleItemCount()); window_rect.size.height = CalculateDropDownListHeight(visible_item_count) + drop_down_list_box_->GetBorderThickness() * 2; POINT screen_position = window_rect.position.ToPOINT(); ClientToScreen(window->GetHandle(), &screen_position); window_rect.position = Point::FromPOINT(screen_position); drop_down_window_->SetOwner(window); drop_down_window_->SetRect(window_rect); drop_down_window_->Show(); }
void axScrollBar::OnMouseLeftDragging(const axPoint& position) { axPoint pos = position - GetAbsoluteRect().position; if(_sliderHeight < _sliderMaxHeight) { // m_sliderPosition move with mouse position. _sliderPos = pos.y - _yClickDelta; // If m_sliderPosition reach bottom, clip m_sliderPosition. if(_sliderPos + _sliderHeight > GetRect().size.y - _imgHeight - 1) { _sliderPos = GetRect().size.y - _imgHeight - 1 - _sliderHeight; } // Clip top. if(_sliderPos < _imgHeight) { _sliderPos = _imgHeight; } // Slider position ratio. _value = (_sliderPos - _imgHeight) / double(_sliderMaxHeight - _sliderHeight - 1); _value = axClamp<double>(_value, 0.0, 1.0); PushEvent(axScrollBarEvents::VALUE_CHANGE, new axScrollBarMsg(this, std::string(""))); _handle->SetScrollDecay(axPoint(0, _value * (_panelSize.y - GetRect().size.y))); Update(); } }
void CUIButton::DrawHighlightedText(){ float right_offset; float down_offset; if(m_eButtonState == BUTTON_UP || m_eButtonState == BUTTON_NORMAL) { right_offset = 0.0f; down_offset = 0.0f; } else { right_offset = m_PushOffset.x; down_offset = m_PushOffset.y; } Frect rect; GetAbsoluteRect (rect); u32 def_col = m_pLines->GetTextColor(); m_pLines->SetTextColor(m_HighlightColor); m_pLines->Draw( rect.left + right_offset + 0 +m_TextOffset.x + m_ShadowOffset.x, rect.top + down_offset - 0 +m_TextOffset.y + m_ShadowOffset.y); m_pLines->SetTextColor(def_col); }
void FolderContent::OnMouseMotion(const axPoint& mousePos) { axPoint pos(mousePos - GetAbsoluteRect().position); pos += GetScrollDecay(); deque<DirectoryNavigation::FileInfo>& dirNames = *_dirNavigation->GetFileInfoDeque(); double height = dirNames.size() * 24.0; if(pos.y > 0) { double y = double(pos.y - 0) / height; if(dirNames.size()) { int temp = y * (dirNames.size()); if(_selected_file != temp) { _selected_file = temp; Update(); } } else { _selected_file = -1; } } }
void CUIButton::DrawTexture() { Frect rect; GetAbsoluteRect (rect); if(m_bAvailableTexture && m_bTextureEnable) { if(m_eButtonState == BUTTON_UP || m_eButtonState == BUTTON_NORMAL) m_UIStaticItem.SetPos(rect.left + m_TextureOffset.x, rect.top + m_TextureOffset.y); else m_UIStaticItem.SetPos(rect.left + m_PushOffset.x + m_TextureOffset.x, rect.top + m_PushOffset.y + m_TextureOffset.y); if(m_bStretchTexture) m_UIStaticItem.SetRect(0, 0, rect.width(), rect.height()); else { Frect r={0,0, m_UIStaticItem.GetOriginalRectScaled().width(), m_UIStaticItem.GetOriginalRectScaled().height()}; m_UIStaticItem.SetRect(r); } if( Heading() ) m_UIStaticItem.Render( GetHeading() ); else m_UIStaticItem.Render(); } }
void CUIGameLog::Update() { CUIScrollView::Update(); toDelList.clear(); // REMOVE ITEMS WITH COMPLETED ANIMATION WINDOW_LIST_it end_it = m_pad->GetChildWndList().end(); WINDOW_LIST_it begin_it = m_pad->GetChildWndList().begin(); for(WINDOW_LIST_it it = begin_it; it!=end_it; ++it) { CUIStatic* pItem = smart_cast<CUIStatic*>(*it); VERIFY(pItem); pItem->Update(); if (pItem->IsClrAnimStoped()) toDelList.push_back(pItem); } // Delete elements { xr_vector<CUIWindow*>::iterator it; for (it = toDelList.begin(); it != toDelList.end(); it++) RemoveWindow(*it); } // REMOVE INVISIBLE AND PART VISIBLE ITEMS if(m_flags.test (eNeedRecalc) ) RecalcSize (); toDelList.clear(); Frect visible_rect; GetAbsoluteRect(visible_rect); for( WINDOW_LIST_it it = m_pad->GetChildWndList().begin(); m_pad->GetChildWndList().end()!=it; ++it) { Frect r; (*it)->GetAbsoluteRect(r); if(! (visible_rect.in(r.x1, r.y1) && visible_rect.in(r.x2, r.y1) && visible_rect.in(r.x1, r.y2) && visible_rect.in(r.x2, r.y2))) { toDelList.push_back(*it); } } // Delete elements { xr_vector<CUIWindow*>::iterator it; for (it = toDelList.begin(); it != toDelList.end(); it++) RemoveWindow(*it); } if(m_flags.test (eNeedRecalc) ) RecalcSize (); }
void CUIListWnd::Draw() { WINDOW_LIST_it it; if(m_iFocusedItem != -1 && IsActiveBackgroundEnabled() ) { Frect rect; GetAbsoluteRect(rect); for (it = m_ChildWndList.begin(); it != m_ChildWndList.end(); ++it) { CUIListItem *pListItem2 = smart_cast<CUIListItem*>(*it); if (!pListItem2) continue; if (pListItem2->GetGroupID() == -1) continue; if ((pListItem2->GetGroupID() == m_iFocusedItemGroupID) && ((pListItem2->GetIndex() >= m_iFirstShownIndex) && (pListItem2->GetIndex() <= m_iRowNum + m_iFirstShownIndex - 1))) { DrawActiveBackFrame(rect, pListItem2); } } } if(m_iSelectedItem != -1 && m_bShowSelectedItem) { Frect rect; GetAbsoluteRect (rect); for (it = m_ChildWndList.begin(); it != m_ChildWndList.end(); ++it) { CUIListItem *pListItem2 = smart_cast<CUIListItem*>(*it); if (!pListItem2) continue; if (pListItem2->GetGroupID() == -1) continue; if (pListItem2->GetIndex() == m_iSelectedItem) { UI()->PushScissor(rect); DrawActiveBackFrame(rect, pListItem2); UI()->PopScissor(); } } } CUIWindow::Draw(); }
void axScrollBar::OnMouseLeftDown(const axPoint& position) { axPoint pos = position - GetAbsoluteRect().position; if(axRect(0, _sliderPos, GetRect().size.x, _sliderHeight).IsPointInside(pos)) { _currentScrollBarColor = &_info.hover; _yClickDelta = pos.y - _sliderPos; GrabMouse(); Update(); } }
void MidiPartition::OnMouseMotion(const axPoint& mouse) { double pos = (mouse - GetAbsoluteRect().position).x; int temp_index = _nSlice * pos / GetRect().size.x; if(_heightlighted_bar != temp_index) { _heightlighted_bar = temp_index; Update(); } }
void CUIWindow::Draw() { for(WINDOW_LIST_it it = m_ChildWndList.begin(); m_ChildWndList.end() != it; ++it){ if(!(*it)->IsShown()) continue; (*it)->Draw(); } #ifdef DEBUG if(g_show_wnd_rect2){ Frect r; GetAbsoluteRect(r); add_rect_to_draw(r); } #endif }
void OOPLyric::OnParentShow(wxShowEvent &e) { if (IsOk()) { if (!e.IsShown()) { m_timer.Stop(); } else { UpdateProgress(NULL); Start(); VdkDC dc(m_Window, GetAbsoluteRect(), NULL); Draw(dc); } } e.Skip(true); }
void axScrollBar::OnMouseMotion(const axPoint& position) { axPoint pos = position - GetAbsoluteRect().position; if(axRect(0, _sliderPos, GetRect().size.x, _sliderHeight).IsPointInside(pos)) { _currentScrollBarColor = &_info.hover; Update(); } else if(_currentScrollBarColor != &_info.normal) { _currentScrollBarColor = &_info.normal; Update(); } }
void CUIFrameLineWnd::DrawElements() { UIRender->SetShader (*m_shader); Fvector2 ts; UIRender->GetActiveTextureResolution(ts); Frect rect; GetAbsoluteRect (rect); UI().ClientToScreenScaled (rect.lt); UI().ClientToScreenScaled (rect.rb); float back_len = 0.0f; u32 prim_count = 6*2; //first&second if(bHorizontal) { back_len = rect.width()-m_tex_rect[flFirst].width()-m_tex_rect[flSecond].width(); if(back_len<0.0f) rect.x2 -= back_len; if(back_len>0.0f) prim_count += 6* iCeil(back_len / m_tex_rect[flBack].width()); }else { back_len = rect.height()-m_tex_rect[flFirst].height()-m_tex_rect[flSecond].height(); if(back_len<0) rect.y2 -= back_len; if(back_len>0.0f) prim_count += 6* iCeil(back_len / m_tex_rect[flBack].height()); } UIRender->StartPrimitive (prim_count, IUIRender::ptTriList, UI().m_currentPointType); for(int i=0; i<flMax; ++i) { Fvector2 LTt, RBt; Fvector2 LTp, RBp; int counter = 0; while(inc_pos(rect, counter, i, LTp, RBp, LTt, RBt)) { draw_rect (LTp, RBp, LTt, RBt, m_texture_color, ts); ++counter; }; } UIRender->FlushPrimitive (); }
void RegisterWindow(PWINDOW pWindow,PWINDOW pParent){ GetAbsoluteRect(pWindow,&pParent->rAbsolute,&pWindow->rAbsolute); if(pParent->wChildrenHead == 0){ pParent->wChildrenHead = pWindow; pWindow->leEntry.pFlink = &pWindow->leEntry; pWindow->leEntry.pBlink = &pWindow->leEntry; }else{ pWindow->leEntry.pBlink = &pParent->wChildrenHead->leEntry; pWindow->leEntry.pFlink = pParent->wChildrenHead->leEntry.pFlink; pParent->wChildrenHead->leEntry.pFlink->pBlink = (PLIST_ENTRY)pWindow; pParent->wChildrenHead->leEntry.pFlink = (PLIST_ENTRY)pWindow; } pWindow->wParent = pParent; }
void axGrid::OnMouseLeftDown(const axPoint& pos) { cout << "LEFT_DOWN" << endl; axRect rect = GetAbsoluteRect(); axPoint position = pos - rect.position; axArrayIndex index = GetElementIndexFromMouse(position); cout << index.x << " " << index.y << endl; if(_gridElements[index.y][index.x].on == false) { AddElement(index.y, index.x); } _selectedElement = index; Update(); }
void CUICarBodyWnd::ActivatePropertiesBox() { if(m_pInventoryBox) return; m_pUIPropertiesBox->RemoveAll(); //. CWeaponMagazined* pWeapon = smart_cast<CWeaponMagazined*>(CurrentIItem()); CEatableItem* pEatableItem = smart_cast<CEatableItem*>(CurrentIItem()); CMedkit* pMedkit = smart_cast<CMedkit*> (CurrentIItem()); CAntirad* pAntirad = smart_cast<CAntirad*> (CurrentIItem()); CBottleItem* pBottleItem = smart_cast<CBottleItem*> (CurrentIItem()); bool b_show = false; LPCSTR _action = NULL; if(pMedkit || pAntirad) { _action = "st_use"; b_show = true; } else if(pEatableItem) { if(pBottleItem) _action = "st_drink"; else _action = "st_eat"; b_show = true; } if(_action) m_pUIPropertiesBox->AddItem(_action, NULL, INVENTORY_EAT_ACTION); if(b_show){ m_pUIPropertiesBox->AutoUpdateSize (); m_pUIPropertiesBox->BringAllToTop (); Fvector2 cursor_pos; Frect vis_rect; GetAbsoluteRect (vis_rect); GetUICursor()->GetPos (cursor_pos.x, cursor_pos.y); cursor_pos.sub (vis_rect.lt); m_pUIPropertiesBox->Show (vis_rect, cursor_pos); } }
// try to positioning clipRect center to vNewPoint void CUICustomMap::SetActivePoint(const Fvector &vNewPoint) { Fvector2 pos; pos.set(vNewPoint.x,vNewPoint.z); Frect bound = BoundRect(); if( FALSE==bound.in(pos) )return; Fvector2 pos_on_map = ConvertRealToLocalNoTransform(pos); Frect map_abs_rect; GetAbsoluteRect(map_abs_rect); Fvector2 pos_abs; pos_abs.set(map_abs_rect.lt); pos_abs.add(pos_on_map); Frect clip_abs_rect = GetClipperRect(); Fvector2 clip_center; clip_abs_rect.getcenter(clip_center); clip_center.sub(pos_abs); MoveWndDelta (clip_center); SetHeadingPivot (pos_on_map, Fvector2().set(0,0), false); }
CUIDragItem* CUICellItem::CreateDragItem() { CUIDragItem* tmp; tmp = xr_new<CUIDragItem>(this); Frect r; GetAbsoluteRect(r); if( m_UIStaticItem.GetFixedLTWhileHeading() ) { float t1,t2; t1 = r.width(); t2 = r.height()*UI().get_current_kx(); Fvector2 cp = GetUICursor().GetCursorPosition(); r.x1 = (cp.x-t2/2.0f); r.y1 = (cp.y-t1/2.0f); r.x2 = r.x1 + t2; r.y2 = r.y1 + t1; } tmp->Init(GetShader(), r, GetUIStaticItem().GetTextureRect()); return tmp; }
void CUILevelMap::UpdateSpots () { DetachAll (); if( fsimilar(MapWnd()->GlobalMap()->GetCurrentZoom(),MapWnd()->GlobalMap()->GetMinZoom(),EPS_L ) ) return; Frect _r; GetAbsoluteRect(_r); if( FALSE==MapWnd()->ActiveMapRect().intersected(_r)) return; /* if(m_anomalies_map){ m_anomalies_map->SetWndPos (0.0f,0.0f); m_anomalies_map->SetWndSize (GetWndSize()); AttachChild (m_anomalies_map); } CLevelFogOfWar* F = Level().FogOfWarMngr().GetFogOfWar(MapName()); AttachChild (F); */ Locations& ls =Level().MapManager().Locations(); for(Locations_it it=ls.begin(); it!=ls.end(); ++it){ if ((*it).location->Update()) (*it).location->UpdateLevelMap(this); } }
//position and heading for drawing pointer to src pos bool CUICustomMap::GetPointerTo(const Fvector2& src, float item_radius, Fvector2& pos, float& heading) { Frect clip_rect_abs = GetClipperRect(); //absolute rect coords Frect map_rect_abs; GetAbsoluteRect(map_rect_abs); Frect rect; BOOL res = rect.intersection(clip_rect_abs, map_rect_abs); if(!res) return false; rect = clip_rect_abs; rect.sub(map_rect_abs.lt.x,map_rect_abs.lt.y); Fbox2 f_clip_rect_local; f_clip_rect_local.set(rect.x1, rect.y1, rect.x2, rect.y2 ); Fvector2 f_center; f_clip_rect_local.getcenter(f_center); Fvector2 f_dir, f_src; f_src.set(src.x, src.y ); f_dir.sub(f_center, f_src ); f_dir.normalize_safe(); Fvector2 f_intersect_point; res = f_clip_rect_local.Pick2(f_src,f_dir,f_intersect_point); VERIFY(res); heading = -f_dir.getH(); f_intersect_point.mad(f_intersect_point,f_dir,item_radius ); pos.set( iFloor(f_intersect_point.x), iFloor(f_intersect_point.y) ); return true; }
void CUIScrollBar::Draw() { if (IsShown()) { //нарисовать фоновую подложку Frect rect; GetAbsoluteRect(rect); if(m_bIsHorizontal){ if (m_StaticBackground->GetOriginalRect().width()){ float size = GetWidth() - m_DecButton->GetWidth() - m_IncButton->GetWidth(); float w = m_StaticBackground->GetOriginalRect().width(); int tile = iFloor(size/w); float rem = size - tile*w; m_StaticBackground->SetTile(tile,1,rem,0.0f); m_StaticBackground->SetPos(rect.left + m_DecButton->GetWidth(),rect.top); } }else{ if (m_StaticBackground->GetOriginalRect().height()){ float size = GetHeight()- m_IncButton->GetHeight() - m_DecButton->GetHeight(); float h = m_StaticBackground->GetOriginalRect().height(); int tile = iFloor(size/h); float rem = size - tile*h; m_StaticBackground->SetTile(1,tile,0.0f,rem); m_StaticBackground->SetPos(rect.left,rect.top + m_DecButton->GetHeight()); } } m_StaticBackground->Render(); } inherited::Draw(); }
void OOPLyric::OnMouseEvent(VdkMouseEvent &e) { switch (e.evtCode) { case RIGHT_UP: { // 拖动歌词时不要响应右键事件 if (TestState(OLST_DRAGGING)) { return; } wxPoint menuPos(AbsoluteRect().GetPosition()); menuPos.x += e.mousePos.x; menuPos.y += e.mousePos.y; m_Window->ShowContextMenu(this, menuPos); break; } case LEFT_DOWN: { m_draggDistance = e.mousePos.y; SetAddinState(OLST_DRAGGING_STARTED); break; } case DRAGGING: { // 不接受先在一首歌的会话中拖动歌词,然后在未释放鼠标的情况下 // 另一首歌开始播放,继续前面的拖动事件 if (!TestState(OLST_DRAGGING_STARTED)) { break; } if (!IsOk()) { break; } if (m_timer.IsRunning()) { Pause(); SetAddinState(OLST_RUNNING_BEFORE_DRAGGING); } SetAddinState(OLST_DRAGGING); //====================================================== int ystart; GetViewStartCoord(NULL, &ystart); int dY = e.mousePos.y - m_draggDistance; m_draggDistance = e.mousePos.y; // 这是一行我们手工加上去的空行 int rowHeight = GetRowHeight(); int upperBound = (*(m_parser->begin()))->GetLyric().empty() ? rowHeight : 0; // 无法继续将帘布向上卷(再拖下去就到下一首了) // 我们将拖到尽头的事件视为无效 bool lastLine = false; // 情景:将虚拟画布像窗帘一样向下拖 // 拖动尽头了,不能再把窗帘哪怕拖下一寸 if (ystart - dY < upperBound) { dY = ystart - upperBound; // 加加减减的原因参照(*) } else { int maxy; GetMaxViewStartCoord(NULL, &maxy); // 将帘布向上卷,卷到尽头了,再卷下去就会导致 // 无法完整遮住窗口 if (ystart - dY > maxy) { dY = ystart - maxy; // 加加减减的原因参照(*) // 无效拖动事件 lastLine = true; } } if (dY) { SetViewStart(0, ystart - dY, &e.dc); //………………(*) } // 无效拖动事件 if (lastLine) { m_draggHit = m_parser->end(); } //=================================================== // 绘制中间线段 wxRect rc(GetAbsoluteRect()); int y = rc.y + m_blankLinesTop * GetRowHeight(); m_Window->ResetDcOrigin(e.dc); e.dc.SetPen(wxPen(m_TextColor)); e.dc.DrawLine(rc.x, y, rc.GetRight(), y); break; } case NORMAL: case LEFT_UP: { if (!TestState(OLST_DRAGGING) || !TestState(OLST_DRAGGING_STARTED)) { break; } wxASSERT(IsOk()); //----------------------------------------------------- RemoveState(OLST_DRAGGING | OLST_DRAGGING_STARTED); // 拖到最下面了,尽头 if (m_draggHit == m_parser->end()) { RefreshState(&e.dc); } else { int ystart; // 起始绘图坐标 GetViewStartCoord(NULL, &ystart); LineInfo *lineDraggHit = *m_draggHit; size_t timeToGo = lineDraggHit->GetStartTime(); int rowHeight = GetRowHeight(); double linePercentage = double(ystart % rowHeight) / rowHeight ; timeToGo += lineDraggHit->GetMilSeconds() * linePercentage; // 歌词可能并不匹配正在播放的歌曲 if (timeToGo < m_parser->GetTimeSum()) { m_currLine = m_draggHit; if (IsReadyForEvent()) { FireEvent(&e.dc, (void *) timeToGo); } } } bool resume = TestState(OLST_RUNNING_BEFORE_DRAGGING); if (resume) { RemoveState(OLST_RUNNING_BEFORE_DRAGGING); Resume(); } break; } default: break; } }
void CUIFrameWindow::DrawElements() { UIRender->SetShader (*m_shader); Fvector2 ts; UIRender->GetActiveTextureResolution(ts); Frect rect; GetAbsoluteRect (rect); UI().ClientToScreenScaled (rect.lt); UI().ClientToScreenScaled (rect.rb); Fvector2 back_len = {0.0f, 0.0f}; u32 rect_count = 4; //lt+rt+lb+rb back_len.x = rect.width()-m_tex_rect[fmLT].width()-m_tex_rect[fmRT].width(); back_len.y = rect.height()-m_tex_rect[fmLT].height()-m_tex_rect[fmRB].height(); R_ASSERT (back_len.x+EPS_L>=0.0f && back_len.y+EPS_L>=0.0f); u32 cnt =0; if(back_len.x>0.0f)//top+bottom cnt = 2* iCeil(back_len.x/m_tex_rect[fmT].width()); rect_count += cnt; if(back_len.y>0.0f)//left+right cnt = 2* iCeil(back_len.y/m_tex_rect[fmL].height()); rect_count += cnt; if(back_len.x>0.0f && back_len.y>0.0f) //back cnt = iCeil(back_len.x/m_tex_rect[fmBK].width()) * iCeil(back_len.y/m_tex_rect[fmBK].height()) ; rect_count += cnt; rect_count *= 6; UIRender->StartPrimitive (rect_count, IUIRender::ptTriList, UI().m_currentPointType); Fvector2 LTt, RBt; Fvector2 LTp, RBp; Frect tmp = rect; get_points (tmp, fmLT, LTp, RBp, LTt, RBt); draw_rect (LTp, RBp, LTt, RBt, m_texture_color, ts); tmp.lt.x = rect.lt.x; tmp.lt.y = rect.rb.y - m_tex_rect[fmLB].height(); get_points (tmp, fmLB, LTp, RBp, LTt, RBt); draw_rect (LTp, RBp, LTt, RBt, m_texture_color, ts); tmp.lt.x = rect.rb.x - m_tex_rect[fmRT].width(); tmp.lt.y = rect.lt.y;; get_points (tmp, fmRT, LTp, RBp, LTt, RBt); draw_rect (LTp, RBp, LTt, RBt, m_texture_color, ts); tmp.lt.x = rect.rb.x - m_tex_rect[fmRB].width(); tmp.lt.y = rect.rb.y - m_tex_rect[fmRB].height(); get_points (tmp, fmRB, LTp, RBp, LTt, RBt); draw_rect (LTp, RBp, LTt, RBt, m_texture_color, ts); if(back_len.x>0.0f) { tmp.lt = rect.lt; tmp.lt.x += m_tex_rect[fmLT].width(); tmp.rb.x = rect.rb.x-m_tex_rect[fmRT].width(); tmp.rb.y = rect.lt.y+m_tex_rect[fmT].height(); draw_tile_line (tmp, fmT, true, ts); tmp.lt.x = rect.lt.x+m_tex_rect[fmLT].width(); tmp.lt.y = rect.rb.y-m_tex_rect[fmB].height(); tmp.rb.x = rect.rb.x-m_tex_rect[fmRT].width(); tmp.rb.y = rect.rb.y; draw_tile_line (tmp, fmB, true, ts); } if(back_len.y>0.0f) { tmp.lt = rect.lt; tmp.lt.y += m_tex_rect[fmLT].height(); tmp.rb.x = rect.lt.x+m_tex_rect[fmL].width(); tmp.rb.y = rect.rb.y-m_tex_rect[fmLB].height(); draw_tile_line (tmp, fmL, false, ts); tmp.lt.x = rect.rb.x-m_tex_rect[fmR].width(); tmp.lt.y = rect.lt.y+m_tex_rect[fmRT].height();; tmp.rb.x = rect.rb.x; tmp.rb.y = rect.rb.y-m_tex_rect[fmRB].height(); draw_tile_line (tmp, fmR, false, ts); } if(back_len.x>0.0f && back_len.y>0.0f) { tmp.lt.x = rect.lt.x+m_tex_rect[fmLT].width(); tmp.lt.y = rect.lt.y+m_tex_rect[fmLT].height(); tmp.rb.x = rect.rb.x-m_tex_rect[fmRB].width(); tmp.rb.y = rect.rb.y-m_tex_rect[fmRB].height(); draw_tile_rect (tmp, fmBK, ts); } UIRender->FlushPrimitive (); }
VdkCusdrawReturnFlag OOPLyric::DoDrawCellText (const VdkLcCell *cell, int col_index, int index0, wxDC &dc, VdkLcHilightState state) { wxASSERT(m_parser); // 注意:index 是不计算加入的空行的 int index = (int) (cell->GetClientData()) - 1; if (index == -1) { // 此时 ClientData == NULL,是我们添加的空行 return VCCDRF_DODEFAULT; } dc.SetTextForeground(m_TextColor); // 暂停时高亮当前行,情景见于用户正在拖动歌词。 // 另外先暂停,然后拖动歌词完毕,此时假如歌词秀是以卡拉OK // 方式进行显示时,那么不会保持半高亮的状态,而是全高亮。 if (TestState(OLST_PAUSED)) { int yStart; GetViewStartCoord(NULL, &yStart); int rowHeight = GetRowHeight(); int dragRegion = yStart + rowHeight * m_blankLinesTop; int index2 = index + m_blankLinesTop; // 检测拖动歌词时中间线下面的一行 if (rowHeight * index2 <= dragRegion && rowHeight * (index2 + 1) > dragRegion) { m_draggHit = m_parser->GetLine(index); dc.SetTextForeground(m_HilightColor); } return VCCDRF_DODEFAULT; } LineInfo *currLine = *m_currLine; // TODO: 是否考虑优化? size_t currLineIndex = m_parser->IndexOf(m_currLine); int lineHasGone = m_stopWatch->Time() - currLine->GetStartTime(); if ((index == currLineIndex - 1) && !cell->GetLabel().empty()) { // 使用渐变色还原上一句歌词 if (lineHasGone < ALPHA_SHOW_LAST_LINE_MS) { unsigned char r, g, b; double alpha2 = double(lineHasGone) / ALPHA_SHOW_LAST_LINE_MS; double alpha1 = 1 - alpha2; r = m_HilightColor.Red() * alpha1 + m_TextColor.Red() * alpha2; g = m_HilightColor.Green() * alpha1 + m_TextColor.Green() * alpha2; b = m_HilightColor.Blue() * alpha1 + m_TextColor.Blue() * alpha2; dc.SetTextForeground(wxColour(r, g, b)); } } else if (index == currLineIndex) { // 高亮当前文本行 // 尽管这是一种很罕见的情况,但一旦出现了就会导致下面 (*) 表达式 // 的除数为 0 if (currLine->GetMilSeconds() == 0) { return VCCDRF_DODEFAULT; } if (!cell->IsEmpty()) { /* 经验教训: 1. SetClippingRegiion 有叠加效应,因此在执行新的 SetClippingRegiion 前别忘了销毁原来的 ClippingRegiion 。 2. 关于表达式中整数与浮点数混用:注意中间运算结果会 被强制转换成 int 然后参加下一步的运算,并不是对 最终结果进行转换,使之成为一个浮点数。 */ const int rowHeight = GetRowHeight(); int y = (currLineIndex + m_blankLinesTop) * rowHeight; cell->DrawLabel(dc, 0, y); // (*) double lineProgress = double(lineHasGone) / currLine->GetMilSeconds(); // 要实现 KALA-OK 效果的文本宽度 int w = (m_Rect.width - cell->GetX_Padding() * 2) * lineProgress; wxRect rc(GetAbsoluteRect()); const int bottom = rc.y + rc.height; int yStart; VdkScrolledWindow::GetViewStartCoord(NULL, &yStart); rc.y += y - yStart; rc.width = cell->GetX_Padding() + w; rc.height = rowHeight; // 不能使 KALA-OK 效果的 ClippingRegion 超出列表窗口 if ((rc.y + rc.height) > bottom) { rc.height = bottom - rc.y; } VdkDcDeviceOriginSaver saver(dc); dc.SetDeviceOrigin(0, 0); VdkDcClippingRegionDestroyer destroyer(dc, rc); # ifdef __WXGTK__ dc.SetBrush(m_crossBrush1); dc.DrawRectangle(rc); # endif dc.SetTextForeground(m_HilightColor); cell->DrawLabel(dc, rc.x, rc.y); } return VCCDRF_SKIPDEFAULT; } return VCCDRF_DODEFAULT; }
void CUIInventoryWnd::ActivatePropertiesBox() { // Флаг-признак для невлючения пункта контекстного меню: Dreess Outfit, если костюм уже надет bool bAlreadyDressed = false; UIPropertiesBox.RemoveAll(); CMedkit* pMedkit = smart_cast<CMedkit*> (CurrentIItem()); CAntirad* pAntirad = smart_cast<CAntirad*> (CurrentIItem()); CEatableItem* pEatableItem = smart_cast<CEatableItem*> (CurrentIItem()); CCustomOutfit* pOutfit = smart_cast<CCustomOutfit*> (CurrentIItem()); //. CArtefact* pArtefact = smart_cast<CArtefact*> (CurrentIItem()); CWeapon* pWeapon = smart_cast<CWeapon*> (CurrentIItem()); CScope* pScope = smart_cast<CScope*> (CurrentIItem()); CSilencer* pSilencer = smart_cast<CSilencer*> (CurrentIItem()); CGrenadeLauncher* pGrenadeLauncher = smart_cast<CGrenadeLauncher*> (CurrentIItem()); CBottleItem* pBottleItem = smart_cast<CBottleItem*> (CurrentIItem()); bool b_show = false; if(!pOutfit && CurrentIItem()->GetSlot()!=NO_ACTIVE_SLOT && !m_pInv->m_slots[CurrentIItem()->GetSlot()].m_bPersistent && m_pInv->CanPutInSlot(CurrentIItem())) { UIPropertiesBox.AddItem("st_move_to_slot", NULL, INVENTORY_TO_SLOT_ACTION); b_show = true; } if(CurrentIItem()->Belt() && m_pInv->CanPutInBelt(CurrentIItem())) { UIPropertiesBox.AddItem("st_move_on_belt", NULL, INVENTORY_TO_BELT_ACTION); b_show = true; } if(CurrentIItem()->Ruck() && m_pInv->CanPutInRuck(CurrentIItem()) && (CurrentIItem()->GetSlot()==u32(-1) || !m_pInv->m_slots[CurrentIItem()->GetSlot()].m_bPersistent) ) { if(!pOutfit) UIPropertiesBox.AddItem("st_move_to_bag", NULL, INVENTORY_TO_BAG_ACTION); else UIPropertiesBox.AddItem("st_undress_outfit", NULL, INVENTORY_TO_BAG_ACTION); bAlreadyDressed = true; b_show = true; } if(pOutfit && !bAlreadyDressed ) { UIPropertiesBox.AddItem("st_dress_outfit", NULL, INVENTORY_TO_SLOT_ACTION); b_show = true; } //отсоединение аддонов от вещи if(pWeapon) { if(pWeapon->GrenadeLauncherAttachable() && pWeapon->IsGrenadeLauncherAttached()) { UIPropertiesBox.AddItem("st_detach_gl", NULL, INVENTORY_DETACH_GRENADE_LAUNCHER_ADDON); b_show = true; } if(pWeapon->ScopeAttachable() && pWeapon->IsScopeAttached()) { UIPropertiesBox.AddItem("st_detach_scope", NULL, INVENTORY_DETACH_SCOPE_ADDON); b_show = true; } if(pWeapon->SilencerAttachable() && pWeapon->IsSilencerAttached()) { UIPropertiesBox.AddItem("st_detach_silencer", NULL, INVENTORY_DETACH_SILENCER_ADDON); b_show = true; } if(smart_cast<CWeaponMagazined*>(pWeapon) && IsGameTypeSingle()) { bool b = (0!=pWeapon->GetAmmoElapsed()); if(!b) { CUICellItem * itm = CurrentItem(); for(u32 i=0; i<itm->ChildsCount(); ++i) { pWeapon = smart_cast<CWeaponMagazined*>((CWeapon*)itm->Child(i)->m_pData); if(pWeapon->GetAmmoElapsed()) { b = true; break; } } } if(b){ UIPropertiesBox.AddItem("st_unload_magazine", NULL, INVENTORY_UNLOAD_MAGAZINE); b_show = true; } } } //присоединение аддонов к активному слоту (2 или 3) if(pScope) { if(m_pInv->m_slots[PISTOL_SLOT].m_pIItem != NULL && m_pInv->m_slots[PISTOL_SLOT].m_pIItem->CanAttach(pScope)) { PIItem tgt = m_pInv->m_slots[PISTOL_SLOT].m_pIItem; UIPropertiesBox.AddItem("st_attach_scope_to_pistol", (void*)tgt, INVENTORY_ATTACH_ADDON); b_show = true; } if(m_pInv->m_slots[RIFLE_SLOT].m_pIItem != NULL && m_pInv->m_slots[RIFLE_SLOT].m_pIItem->CanAttach(pScope)) { PIItem tgt = m_pInv->m_slots[RIFLE_SLOT].m_pIItem; UIPropertiesBox.AddItem("st_attach_scope_to_rifle", (void*)tgt, INVENTORY_ATTACH_ADDON); b_show = true; } } else if(pSilencer) { if(m_pInv->m_slots[PISTOL_SLOT].m_pIItem != NULL && m_pInv->m_slots[PISTOL_SLOT].m_pIItem->CanAttach(pSilencer)) { PIItem tgt = m_pInv->m_slots[PISTOL_SLOT].m_pIItem; UIPropertiesBox.AddItem("st_attach_silencer_to_pistol", (void*)tgt, INVENTORY_ATTACH_ADDON); b_show = true; } if(m_pInv->m_slots[RIFLE_SLOT].m_pIItem != NULL && m_pInv->m_slots[RIFLE_SLOT].m_pIItem->CanAttach(pSilencer)) { PIItem tgt = m_pInv->m_slots[RIFLE_SLOT].m_pIItem; UIPropertiesBox.AddItem("st_attach_silencer_to_rifle", (void*)tgt, INVENTORY_ATTACH_ADDON); b_show = true; } } else if(pGrenadeLauncher) { if(m_pInv->m_slots[RIFLE_SLOT].m_pIItem != NULL && m_pInv->m_slots[RIFLE_SLOT].m_pIItem->CanAttach(pGrenadeLauncher)) { PIItem tgt = m_pInv->m_slots[RIFLE_SLOT].m_pIItem; UIPropertiesBox.AddItem("st_attach_gl_to_rifle", (void*)tgt, INVENTORY_ATTACH_ADDON); b_show = true; } } LPCSTR _action = NULL; if(pMedkit || pAntirad) { _action = "st_use"; } else if(pEatableItem) { if(pBottleItem) _action = "st_drink"; else _action = "st_eat"; } if(_action){ UIPropertiesBox.AddItem(_action, NULL, INVENTORY_EAT_ACTION); b_show = true; } //. if(pArtefact&&pArtefact->CanBeActivated()) //. UIPropertiesBox.AddItem("st_activate_artefact", NULL, INVENTORY_ACTIVATE_ARTEFACT_ACTION); if(!CurrentIItem()->IsQuestItem()){ UIPropertiesBox.AddItem("st_drop", NULL, INVENTORY_DROP_ACTION); b_show = true; if(CurrentItem()->ChildsCount()) UIPropertiesBox.AddItem("st_drop_all", (void*)33, INVENTORY_DROP_ACTION); } if(b_show) { UIPropertiesBox.AutoUpdateSize (); UIPropertiesBox.BringAllToTop (); Fvector2 cursor_pos; Frect vis_rect; GetAbsoluteRect (vis_rect); GetUICursor()->GetPos (cursor_pos.x, cursor_pos.y); cursor_pos.sub (vis_rect.lt); UIPropertiesBox.Show (vis_rect, cursor_pos); PlaySnd (eInvProperties); } }
void CUIProgressShape::Draw() { if(m_bText) DrawText (); UIRender->SetShader (*GetShader()); Fvector2 tsize; UIRender->GetActiveTextureResolution(tsize); UIRender->StartPrimitive (m_sectorCount*3,IUIRender::ptTriList, UI().m_currentPointType); Frect pos_rect; GetAbsoluteRect (pos_rect); UI().ClientToScreenScaled (pos_rect.lt, pos_rect.x1, pos_rect.y1); UI().ClientToScreenScaled (pos_rect.rb, pos_rect.x2, pos_rect.y2); Fvector2 center_pos; pos_rect.getcenter (center_pos); Frect tex_rect = GetUIStaticItem().GetTextureRect(); tex_rect.lt.x /= tsize.x; tex_rect.lt.y /= tsize.y; tex_rect.rb.x /= tsize.x; tex_rect.rb.y /= tsize.y; Fvector2 center_tex; tex_rect.getcenter (center_tex); float radius_pos = pos_rect.width()/2.0f; float radius_tex = tex_rect.width()/2.0f; float curr_angle = m_angle_begin; float sin_a = _sin(curr_angle); float cos_a = _cos(curr_angle); Fvector2 start_pos_pt, prev_pos_pt; Fvector2 start_tex_pt, prev_tex_pt; start_pos_pt.set (0.0f, -radius_pos); prev_pos_pt = start_pos_pt; start_tex_pt.set (0.0f, -radius_tex); prev_tex_pt = start_tex_pt; _make_rot_tex(prev_pos_pt, start_pos_pt.y, sin_a, cos_a); _make_rot_tex(prev_tex_pt, start_tex_pt.y, sin_a, cos_a); float angle_range = PI_MUL_2; if ( m_bClockwise ) { angle_range = -abs( m_angle_end - m_angle_begin ); } else { angle_range = abs( m_angle_end - m_angle_begin ); } for ( u32 i = 0; i < m_sectorCount; ++i ) { float ffff = calc_color (i+1, m_sectorCount, m_stage, 1.0f, m_blend); u32 color = color_argb_f (ffff,1.0f,1.0f,1.0f); UIRender->PushPoint(center_pos.x, center_pos.y, 0, color, center_tex.x, center_tex.y); Fvector2 tp; tp.set (prev_pos_pt); tp.add (center_pos); Fvector2 tx; tx.set (prev_tex_pt); tx.add (center_tex); Fvector2 tp1; Fvector2 tx1; tp1.set(tp); tx1.set(tx); curr_angle += angle_range/float(m_sectorCount); sin_a = _sin(curr_angle); cos_a = _cos(curr_angle); _make_rot_tex(prev_pos_pt, start_pos_pt.y, sin_a, cos_a); _make_rot_tex(prev_tex_pt, start_tex_pt.y, sin_a, cos_a); tp.set (prev_pos_pt); tp.add (center_pos); tx.set (prev_tex_pt); tx.add (center_tex); if (m_bClockwise) { UIRender->PushPoint(tp1.x, tp1.y, 0, color, tx1.x, tx1.y); UIRender->PushPoint(tp.x, tp.y, 0, color, tx.x, tx.y); } else { UIRender->PushPoint(tp.x, tp.y, 0, color, tx.x, tx.y); UIRender->PushPoint(tp1.x, tp1.y, 0, color, tx1.x, tx1.y); } } UIRender->FlushPrimitive(); }