From: <geo...@us...> - 2012-08-16 20:17:09
|
Revision: 5143 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5143&view=rev Author: geoffthemedio Date: 2012-08-16 20:17:03 +0000 (Thu, 16 Aug 2012) Log Message: ----------- Implemented GG::ListBox::SetFirstRowShown and used to tweak ObjectListWnd updating. Modified Paths: -------------- branches/FreeOrion-GiGi-Fork/GG/GG/ListBox.h branches/FreeOrion-GiGi-Fork/GG/src/ListBox.cpp branches/FreeOrion-GiGi-Fork/UI/ObjectListWnd.cpp Modified: branches/FreeOrion-GiGi-Fork/GG/GG/ListBox.h =================================================================== --- branches/FreeOrion-GiGi-Fork/GG/GG/ListBox.h 2012-08-16 20:08:51 UTC (rev 5142) +++ branches/FreeOrion-GiGi-Fork/GG/GG/ListBox.h 2012-08-16 20:17:03 UTC (rev 5143) @@ -375,6 +375,7 @@ void SetSelections(const SelectionSet& s); ///< sets the set of selected rows to \a s void SetCaret(iterator it); ///< sets the position of the caret to \a it void BringRowIntoView(iterator it); ///< moves the scrollbars so that row \a it is visible + void SetFirstRowShown(iterator it); ///< moves the scrollbars so that row \a it is the first visible void SetInteriorColor(Clr c); ///< sets the color painted into the client area of the control void SetHiliteColor(Clr c); ///< sets the color behind selected line items Modified: branches/FreeOrion-GiGi-Fork/GG/src/ListBox.cpp =================================================================== --- branches/FreeOrion-GiGi-Fork/GG/src/ListBox.cpp 2012-08-16 20:08:51 UTC (rev 5142) +++ branches/FreeOrion-GiGi-Fork/GG/src/ListBox.cpp 2012-08-16 20:17:03 UTC (rev 5143) @@ -923,6 +923,20 @@ } } +void ListBox::SetFirstRowShown(iterator it) +{ + if (it != m_rows.end()) { + m_first_row_shown = it; + if (m_vscroll) { + Y acc(0); + for (iterator it2 = m_rows.begin(); it2 != m_first_row_shown; ++it2) + acc += (*it)->Height(); + m_vscroll->ScrollTo(Value(acc)); + SignalScroll(*m_vscroll, true); + } + } +} + void ListBox::SetInteriorColor(Clr c) { m_int_color = c; } Modified: branches/FreeOrion-GiGi-Fork/UI/ObjectListWnd.cpp =================================================================== --- branches/FreeOrion-GiGi-Fork/UI/ObjectListWnd.cpp 2012-08-16 20:08:51 UTC (rev 5142) +++ branches/FreeOrion-GiGi-Fork/UI/ObjectListWnd.cpp 2012-08-16 20:17:03 UTC (rev 5143) @@ -22,11 +22,11 @@ //////////////////////////////////////////////// class FilterDialog : public CUIWnd { public: - FilterDialog(GG::X x, GG::Y y) : CUIWnd(UserString("FILTERS"), x, y, GG::X(200), GG::Y(200), - GG::INTERACTIVE | GG::DRAGABLE | GG::MODAL | GG::RESIZABLE) - {} - ~FilterDialog() - {} + FilterDialog(GG::X x, GG::Y y) : CUIWnd(UserString("FILTERS"), x, y, GG::X(200), GG::Y(200), + GG::INTERACTIVE | GG::DRAGABLE | GG::MODAL | GG::RESIZABLE) + {} + ~FilterDialog() + {} //@} private: }; @@ -37,20 +37,20 @@ std::vector<boost::shared_ptr<GG::Texture> > retval; if (const Ship* ship = universe_object_cast<const Ship*>(obj)) { - if (const ShipDesign* design = ship->Design()) - retval.push_back(ClientUI::ShipDesignIcon(design->ID())); - else + if (const ShipDesign* design = ship->Design()) + retval.push_back(ClientUI::ShipDesignIcon(design->ID())); + else retval.push_back(ClientUI::ShipDesignIcon(INVALID_OBJECT_ID)); // default icon } else if (const Fleet* fleet = universe_object_cast<const Fleet*>(obj)) { - boost::shared_ptr<GG::Texture> head_icon = FleetHeadIcon(fleet, FleetButton::FLEET_BUTTON_LARGE); - retval.push_back(head_icon); - boost::shared_ptr<GG::Texture> size_icon = FleetSizeIcon(fleet, FleetButton::FLEET_BUTTON_LARGE); + boost::shared_ptr<GG::Texture> head_icon = FleetHeadIcon(fleet, FleetButton::FLEET_BUTTON_LARGE); + retval.push_back(head_icon); + boost::shared_ptr<GG::Texture> size_icon = FleetSizeIcon(fleet, FleetButton::FLEET_BUTTON_LARGE); retval.push_back(size_icon); } else if (const System* system = universe_object_cast<const System*>(obj)) { - StarType star_type = system->GetStarType(); - ClientUI* ui = ClientUI::GetClientUI(); - boost::shared_ptr<GG::Texture> disc_texture = ui->GetModuloTexture( - ClientUI::ArtDir() / "stars", ClientUI::StarTypeFilePrefixes()[star_type], system->ID()); + StarType star_type = system->GetStarType(); + ClientUI* ui = ClientUI::GetClientUI(); + boost::shared_ptr<GG::Texture> disc_texture = ui->GetModuloTexture( + ClientUI::ArtDir() / "stars", ClientUI::StarTypeFilePrefixes()[star_type], system->ID()); retval.push_back(disc_texture); boost::shared_ptr<GG::Texture> halo_texture = ui->GetModuloTexture( ClientUI::ArtDir() / "stars", ClientUI::HaloStarTypeFilePrefixes()[star_type], system->ID()); @@ -100,23 +100,23 @@ boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); GG::Clr clr = ClientUI::TextColor(); int client_empire_id = HumanClientApp::GetApp()->EmpireID(); - GG::Flags<GG::GraphicStyle> style = GG::GRAPHIC_CENTER | GG::GRAPHIC_VCENTER | GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE; - + GG::Flags<GG::GraphicStyle> style = GG::GRAPHIC_CENTER | GG::GRAPHIC_VCENTER | GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE; + if (m_have_contents) { m_expand_button = new GG::Button(GG::X0, GG::Y0, GG::X(16), GG::Y(16), - "", font, GG::CLR_WHITE, GG::CLR_ZERO, GG::ONTOP | GG::INTERACTIVE); + "", font, GG::CLR_WHITE, GG::CLR_ZERO, GG::ONTOP | GG::INTERACTIVE); AttachChild(m_expand_button); GG::Connect(m_expand_button->ClickedSignal, &ObjectPanel::ExpandCollapseButtonPressed, this); - } else { - m_dot = new GG::StaticGraphic(GG::X0, GG::Y0, GG::X(16), GG::Y(16), - ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "dot.png", true), - style, GG::Flags<GG::WndFlag>()); - AttachChild(m_dot); - } - + } else { + m_dot = new GG::StaticGraphic(GG::X0, GG::Y0, GG::X(16), GG::Y(16), + ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "dot.png", true), + style, GG::Flags<GG::WndFlag>()); + AttachChild(m_dot); + } + std::vector<boost::shared_ptr<GG::Texture> > textures = ObjectTextures(obj); - - m_icon = new MultiTextureStaticGraphic(GG::X0, GG::Y0, GG::X(Value(ClientHeight())), ClientHeight(), + + m_icon = new MultiTextureStaticGraphic(GG::X0, GG::Y0, GG::X(Value(ClientHeight())), ClientHeight(), textures, std::vector<GG::Flags<GG::GraphicStyle> >(textures.size(), style)); AttachChild(m_icon); @@ -146,7 +146,7 @@ } void Update() { - if (m_expand_button) { + if (m_expand_button) { if (m_expanded) { m_expand_button->SetUnpressedGraphic(GG::SubTexture(ClientUI::GetTexture( ClientUI::ArtDir() / "icons" / "minusnormal.png" , true), GG::X0, GG::Y0, GG::X(32), GG::Y(32))); m_expand_button->SetPressedGraphic (GG::SubTexture(ClientUI::GetTexture( ClientUI::ArtDir() / "icons" / "minusclicked.png" , true), GG::X0, GG::Y0, GG::X(32), GG::Y(32))); @@ -156,7 +156,7 @@ m_expand_button->SetPressedGraphic (GG::SubTexture(ClientUI::GetTexture( ClientUI::ArtDir() / "icons" / "plusclicked.png" , true), GG::X0, GG::Y0, GG::X(32), GG::Y(32))); m_expand_button->SetRolloverGraphic (GG::SubTexture(ClientUI::GetTexture( ClientUI::ArtDir() / "icons" / "plusmouseover.png", true), GG::X0, GG::Y0, GG::X(32), GG::Y(32))); } - } + } } mutable boost::signal<void ()> ExpandCollapseSignal; @@ -498,10 +498,11 @@ } } - if (!this->Empty()) + if (first_visible_queue_row < this->NumRows()) { + this->SetFirstRowShown(boost::next(this->begin(), first_visible_queue_row)); + } else if (!this->Empty()) { this->BringRowIntoView(--this->end()); - if (first_visible_queue_row < this->NumRows()) - this->BringRowIntoView(boost::next(this->begin(), first_visible_queue_row)); + } } private: @@ -533,22 +534,22 @@ GG::Connect(m_list_box->RightClickedSignal, &ObjectListWnd::ObjectRightClicked, this); AttachChild(m_list_box); - m_filter_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("FILTERS")); - GG::Connect(m_filter_button->ClickedSignal, &ObjectListWnd::FilterClicked, this); + m_filter_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("FILTERS")); + GG::Connect(m_filter_button->ClickedSignal, &ObjectListWnd::FilterClicked, this); AttachChild(m_filter_button); - m_sort_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("SORT")); - GG::Connect(m_sort_button->ClickedSignal, &ObjectListWnd::SortClicked, this); + m_sort_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("SORT")); + GG::Connect(m_sort_button->ClickedSignal, &ObjectListWnd::SortClicked, this); AttachChild(m_sort_button); m_sort_button->Disable(); - m_columns_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("COLUMNS")); - GG::Connect(m_columns_button->ClickedSignal, &ObjectListWnd::ColumnsClicked, this); + m_columns_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("COLUMNS")); + GG::Connect(m_columns_button->ClickedSignal, &ObjectListWnd::ColumnsClicked, this); AttachChild(m_columns_button); m_columns_button->Disable(); - m_collapse_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("COLLAPSE_ALL")); - GG::Connect(m_collapse_button->ClickedSignal, &ObjectListWnd::CollapseExpandClicked, this); + m_collapse_button = new CUIButton(GG::X0, GG::Y0, GG::X(30), UserString("COLLAPSE_ALL")); + GG::Connect(m_collapse_button->ClickedSignal, &ObjectListWnd::CollapseExpandClicked, this); AttachChild(m_collapse_button); m_collapse_button->Disable(); @@ -556,21 +557,21 @@ } void ObjectListWnd::DoLayout() { - GG::X BUTTON_WIDTH(ClientUI::Pts()*7); - GG::Y BUTTON_HEIGHT = m_filter_button->Height(); + GG::X BUTTON_WIDTH(ClientUI::Pts()*7); + GG::Y BUTTON_HEIGHT = m_filter_button->Height(); int PAD(3); GG::Pt button_ul(GG::X0, ClientHeight() - BUTTON_HEIGHT); - m_filter_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); - button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); - m_sort_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); - button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); - m_columns_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); - button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); - m_collapse_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); - button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); - + m_filter_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); + button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); + m_sort_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); + button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); + m_columns_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); + button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); + m_collapse_button->SizeMove(button_ul, button_ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT)); + button_ul += GG::Pt(BUTTON_WIDTH + GG::X(PAD), GG::Y0); + m_list_box->SizeMove(GG::Pt(GG::X0, GG::Y0), GG::Pt(ClientWidth(), button_ul.y)); SetMinSize(GG::Pt(5*BUTTON_WIDTH, 6*BUTTON_HEIGHT)); |