From: <tz...@us...> - 2006-02-11 03:12:59
|
Revision: 1747 Author: tzlaine Date: 2006-02-10 19:12:47 -0800 (Fri, 10 Feb 2006) ViewCVS: http://svn.sourceforge.net/freeorion?rev=1747&view=rev Log Message: ----------- Implemented rollover highlighting for techs in TechNavigator. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2006-02-10 07:46:12 UTC (rev 1746) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2006-02-11 03:12:47 UTC (rev 1747) @@ -64,6 +64,8 @@ const double OUTER_LINE_THICKNESS = 2.0; + const double TECH_NAVIGATOR_ROLLOVER_BRIGHTENING_FACTOR = 1.5; + GG::Clr CategoryColor(const std::string& category_name) { const std::vector<std::string>& tech_categories = GetTechManager().CategoryNames(); @@ -627,12 +629,15 @@ virtual GG::Pt ClientLowerRight() const {return LowerRight() - GG::Pt(2, 2);} virtual void Render(); virtual void LClick(const GG::Pt& pt, Uint32 keys) {ClickedSignal(m_tech);} + virtual void MouseEnter(const GG::Pt& pt, Uint32 keys) {m_selected = true;} + virtual void MouseLeave(const GG::Pt& pt, Uint32 keys) {m_selected = false;} const Tech * const m_tech; GG::Clr m_border_color; GG::TextControl* m_name_text; mutable boost::signal<void (const Tech*)> ClickedSignal; private: int m_indentation; + bool m_selected; }; static const int TECH_ROW_INDENTATION = 8; @@ -744,7 +749,8 @@ TechTreeWnd::TechNavigator::TechControl::TechControl(int w, int h, const Tech* tech, int indentation) : GG::Control(0, 0, w, h), m_tech(tech), - m_indentation(indentation) + m_indentation(indentation), + m_selected(false) { EnableChildClipping(true); #ifndef FREEORION_BUILD_UTIL @@ -782,15 +788,21 @@ GG::Rect rect(UpperLeft(), LowerRight()); rect += GG::Pt(m_indentation, 0); TechType tech_type = m_tech->Type(); + GG::Clr color_to_use = Color(); + GG::Clr border_color_to_use = m_border_color; + if (!Disabled() && m_selected) { + AdjustBrightness(color_to_use, TECH_NAVIGATOR_ROLLOVER_BRIGHTENING_FACTOR); + AdjustBrightness(border_color_to_use, TECH_NAVIGATOR_ROLLOVER_BRIGHTENING_FACTOR); + } glDisable(GL_TEXTURE_2D); - FillTechPanelInterior(tech_type, rect, GG::Rect(), Color(), false, 0.0); + FillTechPanelInterior(tech_type, rect, GG::Rect(), color_to_use, false, 0.0); glEnable(GL_LINE_SMOOTH); glLineWidth(OUTER_LINE_THICKNESS); - glColor4ub(m_border_color.r, m_border_color.g, m_border_color.b, 127); + glColor4ub(border_color_to_use.r, border_color_to_use.g, border_color_to_use.b, 127); TraceTechPanelOutline(tech_type, rect, GG::Rect(), false); glLineWidth(1.0); glDisable(GL_LINE_SMOOTH); - glColor4ubv(m_border_color.v); + glColor4ubv(border_color_to_use.v); TraceTechPanelOutline(tech_type, rect, GG::Rect(), false); glEnable(GL_TEXTURE_2D); } @@ -1359,7 +1371,6 @@ } } -#include <iostream> void TechTreeWnd::LayoutPanel::Layout(bool keep_position) { GG::Pt final_position = keep_position ? m_scroll_position : GG::Pt(); |
From: <tz...@us...> - 2006-03-05 03:33:09
|
Revision: 1800 Author: tzlaine Date: 2006-03-04 19:33:02 -0800 (Sat, 04 Mar 2006) ViewCVS: http://svn.sourceforge.net/freeorion?rev=1800&view=rev Log Message: ----------- Made a small change to TechTreeWnd::LayoutPanel::TechPanel to inprove the placement of cost-strings in application and refinement techs. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2006-03-04 23:37:48 UTC (rev 1799) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2006-03-05 03:33:02 UTC (rev 1800) @@ -979,11 +979,13 @@ m_selected(selected) { int name_font_pts = ClientUI::PTS + 2; - GG::Pt TECH_TEXT_OFFSET(4, 2); + GG::Pt UPPER_TECH_TEXT_OFFSET(4, 2); + GG::Pt LOWER_TECH_TEXT_OFFSET(4, 0); if (m_tech->Type() == TT_THEORY) { Resize(GG::Pt(THEORY_TECH_PANEL_LAYOUT_WIDTH, THEORY_TECH_PANEL_LAYOUT_HEIGHT)); name_font_pts += 2; - TECH_TEXT_OFFSET += GG::Pt(2, 2); + UPPER_TECH_TEXT_OFFSET += GG::Pt(2, 2); + LOWER_TECH_TEXT_OFFSET += GG::Pt(2, 4); } else if (m_tech->Type() == TT_APPLICATION) { Resize(GG::Pt(APPLICATION_TECH_PANEL_LAYOUT_WIDTH, APPLICATION_TECH_PANEL_LAYOUT_HEIGHT)); } else { // m_tech->Type() == TT_REFINEMENT @@ -1032,11 +1034,11 @@ } boost::shared_ptr<GG::Font> font = GG::GUI::GetGUI()->GetFont(ClientUI::FONT, name_font_pts); - m_category_icon = new GG::StaticGraphic(TECH_TEXT_OFFSET.x, TECH_TEXT_OFFSET.y, font->Lineskip(), font->Lineskip(), + m_category_icon = new GG::StaticGraphic(UPPER_TECH_TEXT_OFFSET.x, UPPER_TECH_TEXT_OFFSET.y, font->Lineskip(), font->Lineskip(), CategoryIcon(m_tech->Category()), GG::GR_FITGRAPHIC); m_category_icon->SetColor(CategoryColor(m_tech->Category())); - m_tech_name_text = new GG::TextControl(m_category_icon->LowerRight().x + 4, TECH_TEXT_OFFSET.y, Width() - (m_category_icon->LowerRight().x + 4) - PROGRESS_PANEL_LEFT_EXTRUSION - 4, + m_tech_name_text = new GG::TextControl(m_category_icon->LowerRight().x + 4, UPPER_TECH_TEXT_OFFSET.y, Width() - (m_category_icon->LowerRight().x + 4) - PROGRESS_PANEL_LEFT_EXTRUSION - 4, font->Lineskip(), UserString(m_tech->Name()), font, m_text_and_border_color, GG::TF_TOP | GG::TF_LEFT); m_tech_name_text->ClipText(true); AttachChild(m_category_icon); @@ -1045,8 +1047,8 @@ std::string cost_str; if (!known_tech) cost_str = str(format(UserString("TECH_TOTAL_COST_STR")) % static_cast<int>(m_tech->ResearchCost() + 0.5) % m_tech->ResearchTurns()); - m_tech_cost_text = new GG::TextControl(TECH_TEXT_OFFSET.x, 0, - Width() - TECH_TEXT_OFFSET.x, Height() - TECH_TEXT_OFFSET.y - PROGRESS_PANEL_BOTTOM_EXTRUSION, + m_tech_cost_text = new GG::TextControl(UPPER_TECH_TEXT_OFFSET.x, 0, + Width() - LOWER_TECH_TEXT_OFFSET.x, Height() - LOWER_TECH_TEXT_OFFSET.y - PROGRESS_PANEL_BOTTOM_EXTRUSION, cost_str, GG::GUI::GetGUI()->GetFont(ClientUI::FONT, ClientUI::PTS), m_text_and_border_color, GG::TF_BOTTOM | GG::TF_LEFT); AttachChild(m_tech_cost_text); |
From: <geo...@us...> - 2007-01-15 21:50:36
|
Revision: 1984 http://svn.sourceforge.net/freeorion/revision/?rev=1984&view=rev Author: geoffthemedio Date: 2007-01-14 16:56:48 -0800 (Sun, 14 Jan 2007) Log Message: ----------- Added clickable zoom in/out buttons on TechTreeWnd, so users without mouse scrollwheels can zoom in/out Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-01-14 22:59:11 UTC (rev 1983) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-01-15 00:56:48 UTC (rev 1984) @@ -903,6 +903,8 @@ void TechDoubleClickedSlot(const Tech* tech); void TreeDraggedSlot(const GG::Pt& move); void TreeZoomedSlot(int move); + void TreeZoomInClicked(); + void TreeZoomOutClicked(); double m_scale; std::string m_category_shown; @@ -920,6 +922,8 @@ CUIScroll* m_vscroll; CUIScroll* m_hscroll; GG::Pt m_scroll_position; + CUIButton* m_zoom_in_button; + CUIButton* m_zoom_out_button; friend struct CollapseSubtreeFunctor; }; @@ -1197,7 +1201,9 @@ m_selected_tech(0), m_layout_surface(0), m_vscroll(0), - m_hscroll(0) + m_hscroll(0), + m_zoom_in_button(0), + m_zoom_out_button(0) { EnableChildClipping(true); @@ -1205,14 +1211,27 @@ m_vscroll = new CUIScroll(w - ClientUI::ScrollWidth(), 0, ClientUI::ScrollWidth(), h - ClientUI::ScrollWidth(), GG::VERTICAL); m_hscroll = new CUIScroll(0, h - ClientUI::ScrollWidth(), w - ClientUI::ScrollWidth(), ClientUI::ScrollWidth(), GG::HORIZONTAL); + int zbsize = ClientUI::ScrollWidth() * 2; + int zboffset = ClientUI::ScrollWidth() / 2; + int top = UpperLeft().y; + int left = UpperLeft().x; + m_zoom_in_button = new CUIButton(w - zbsize - zboffset - ClientUI::ScrollWidth(), zboffset, zbsize, "+"); + + m_zoom_out_button = new CUIButton(m_zoom_in_button->UpperLeft().x - left, + m_zoom_in_button->LowerRight().y + zboffset - top, zbsize, "-"); + AttachChild(m_layout_surface); AttachChild(m_vscroll); AttachChild(m_hscroll); + AttachChild(m_zoom_in_button); + AttachChild(m_zoom_out_button); GG::Connect(m_layout_surface->DraggedSignal, &TechTreeWnd::LayoutPanel::TreeDraggedSlot, this); GG::Connect(m_layout_surface->ZoomedSignal, &TechTreeWnd::LayoutPanel::TreeZoomedSlot, this); GG::Connect(m_vscroll->ScrolledSignal, &TechTreeWnd::LayoutPanel::ScrolledSlot, this); GG::Connect(m_hscroll->ScrolledSignal, &TechTreeWnd::LayoutPanel::ScrolledSlot, this); + GG::Connect(m_zoom_in_button->ClickedSignal, &TechTreeWnd::LayoutPanel::TreeZoomInClicked, this); + GG::Connect(m_zoom_out_button->ClickedSignal, &TechTreeWnd::LayoutPanel::TreeZoomOutClicked, this); } GG::Pt TechTreeWnd::LayoutPanel::ClientLowerRight() const @@ -1683,7 +1702,16 @@ SetScale(m_scale / ZOOM_STEP_SIZE); } +void TechTreeWnd::LayoutPanel::TreeZoomInClicked() +{ + TreeZoomedSlot(1); +} +void TechTreeWnd::LayoutPanel::TreeZoomOutClicked() +{ + TreeZoomedSlot(-1); +} + ////////////////////////////////////////////////// // TechTreeWnd // ////////////////////////////////////////////////// |
From: <geo...@us...> - 2007-02-18 07:08:51
|
Revision: 2011 http://svn.sourceforge.net/freeorion/revision/?rev=2011&view=rev Author: geoffthemedio Date: 2007-02-17 23:08:52 -0800 (Sat, 17 Feb 2007) Log Message: ----------- Added short summary text to Research screen TechDetailPanel Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-02-18 03:15:12 UTC (rev 2010) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-02-18 07:08:52 UTC (rev 2011) @@ -480,7 +480,7 @@ const Tech* m_tech; GG::TextControl* m_tech_name_text; GG::TextControl* m_cost_text; - GG::TextControl* m_category_and_type_text; + GG::TextControl* m_summary_text; CUIButton* m_recenter_button; CUIButton* m_add_to_queue_button; CUIMultiEdit* m_description_box; @@ -491,21 +491,21 @@ GG::Wnd(0, 0, w, h, 0), m_tech(0) { - const int NAME_PTS = ClientUI::Pts() + 8; - const int CATEGORY_AND_TYPE_PTS = ClientUI::Pts() + 4; + const int NAME_PTS = ClientUI::Pts() + 6; + const int SUMMARY_PTS = ClientUI::Pts() + 3; const int COST_PTS = ClientUI::Pts(); const int BUTTON_WIDTH = 150; const int BUTTON_MARGIN = 5; m_tech_name_text = new GG::TextControl(1, 0, w - 1 - BUTTON_WIDTH, NAME_PTS + 4, "", GG::GUI::GetGUI()->GetFont(ClientUI::FontBold(), NAME_PTS), ClientUI::TextColor()); m_cost_text = new GG::TextControl(1, m_tech_name_text->LowerRight().y, w - 1 - BUTTON_WIDTH, COST_PTS + 4, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), COST_PTS), ClientUI::TextColor()); - m_category_and_type_text = new GG::TextControl(1, m_cost_text->LowerRight().y, w - 1 - BUTTON_WIDTH, CATEGORY_AND_TYPE_PTS + 4, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), CATEGORY_AND_TYPE_PTS), ClientUI::TextColor()); + m_summary_text = new GG::TextControl(1, m_cost_text->LowerRight().y, w - 1 - BUTTON_WIDTH, SUMMARY_PTS + 4, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), SUMMARY_PTS), ClientUI::TextColor()); m_add_to_queue_button = new CUIButton(w - 1 - BUTTON_WIDTH, 1, BUTTON_WIDTH, UserString("TECH_DETAIL_ADD_TO_QUEUE")); m_recenter_button = new CUIButton(w - 1 - BUTTON_WIDTH, m_add_to_queue_button->LowerRight().y + BUTTON_MARGIN, BUTTON_WIDTH, UserString("TECH_DETAIL_CENTER_ON_TECH")); m_recenter_button->Hide(); m_add_to_queue_button->Hide(); m_recenter_button->Disable(); m_add_to_queue_button->Disable(); - m_description_box = new CUIMultiEdit(1, m_category_and_type_text->LowerRight().y, w - 2 - BUTTON_WIDTH, h - m_category_and_type_text->LowerRight().y - 2, "", GG::TF_WORDBREAK | GG::MultiEdit::READ_ONLY); + m_description_box = new CUIMultiEdit(1, m_summary_text->LowerRight().y, w - 2 - BUTTON_WIDTH, h - m_summary_text->LowerRight().y - 2, "", GG::TF_WORDBREAK | GG::MultiEdit::READ_ONLY); m_description_box->SetColor(GG::CLR_ZERO); m_description_box->SetInteriorColor(GG::CLR_ZERO); @@ -516,7 +516,7 @@ AttachChild(m_tech_name_text); AttachChild(m_cost_text); - AttachChild(m_category_and_type_text); + AttachChild(m_summary_text); AttachChild(m_recenter_button); AttachChild(m_add_to_queue_button); AttachChild(m_description_box); @@ -538,7 +538,7 @@ void TechTreeWnd::TechDetailPanel::Reset() { m_tech_name_text->SetText(""); - m_category_and_type_text->SetText(""); + m_summary_text->SetText(""); m_cost_text->SetText(""); m_description_box->SetText(""); @@ -573,10 +573,11 @@ m_tech_name_text->SetText(UserString(m_tech->Name())); using boost::io::str; using boost::format; - m_category_and_type_text->SetText("<i>" + str(format(UserString("TECH_DETAIL_TYPE_STR")) + m_summary_text->SetText("<i>" + str(format(UserString("TECH_DETAIL_TYPE_STR")) % UserString(m_tech->Category()) - % UserString(boost::lexical_cast<std::string>(m_tech->Type()))) + "</i>"); - m_category_and_type_text->SetColor(CategoryColor(m_tech->Category())); + % UserString(boost::lexical_cast<std::string>(m_tech->Type()))) + " - " + + str(format(UserString(m_tech->ShortDescription()))) + "</i>"); + m_summary_text->SetColor(CategoryColor(m_tech->Category())); m_cost_text->SetText(str(format(UserString("TECH_TOTAL_COST_STR")) % static_cast<int>(m_tech->ResearchCost() + 0.5) % m_tech->ResearchTurns())); |
From: <geo...@us...> - 2007-02-25 12:35:35
|
Revision: 2014 http://svn.sourceforge.net/freeorion/revision/?rev=2014&view=rev Author: geoffthemedio Date: 2007-02-25 04:35:36 -0800 (Sun, 25 Feb 2007) Log Message: ----------- Recentred tech tree zooming at centre of tech tree panel, fixing minor bug that appeared where the centre point of zooms was offset from the centre by the margin space I added at the edges of the panel recently. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-02-22 12:51:53 UTC (rev 2013) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-02-25 12:35:36 UTC (rev 2014) @@ -1757,6 +1757,8 @@ void TechTreeWnd::LayoutPanel::Layout(bool keep_position, double old_scale/* = -1.0*/) { + const int TECH_PANEL_MARGIN = ClientUI::Pts()*16; + if (old_scale < 0.0) old_scale = m_scale; GG::Pt final_position; @@ -1766,8 +1768,8 @@ } else { GG::Pt cl_sz = ClientSize(); GG::Pt center = m_scroll_position + GG::Pt(cl_sz.x / 2, cl_sz.y / 2); - center.x = static_cast<int>(center.x * m_scale / old_scale + 0.5); - center.y = static_cast<int>(center.y * m_scale / old_scale + 0.5); + center.x = static_cast<int>((center.x - TECH_PANEL_MARGIN) * m_scale / old_scale + 0.5 + TECH_PANEL_MARGIN); + center.y = static_cast<int>((center.y - TECH_PANEL_MARGIN) * m_scale / old_scale + 0.5 + TECH_PANEL_MARGIN); final_position = GG::Pt(center.x - cl_sz.x / 2, center.y - cl_sz.y / 2); } } @@ -1824,7 +1826,6 @@ gvLayout(gvc, graph, "dot"); // create new tech panels and new dependency arcs - const int TECH_PANEL_MARGIN = ClientUI::Pts()*16; m_dependency_arcs.clear(); //const std::set<const Tech*>& collapsed_subtree_techs = m_collapsed_subtree_techs_per_view[m_category_shown]; for (Agnode_t* node = agfstnode(graph); node; node = agnxtnode(graph, node)) { @@ -1837,7 +1838,6 @@ GG::Connect(m_techs[tech]->TechBrowsedSignal, &TechTreeWnd::LayoutPanel::TechBrowsedSlot, this); GG::Connect(m_techs[tech]->TechClickedSignal, &TechTreeWnd::LayoutPanel::TechClickedSlot, this); GG::Connect(m_techs[tech]->TechDoubleClickedSignal, &TechTreeWnd::LayoutPanel::TechDoubleClickedSlot, this); - //GG::Connect(m_techs[tech]->CollapseSubtreeSignal(), CollapseSubtreeFunctor(this, tech)); for (Agedge_t* edge = agfstout(graph, node); edge; edge = agnxtout(graph, edge)) { const Tech* from = tech; |
From: <geo...@us...> - 2007-03-10 10:37:21
|
Revision: 2024 http://svn.sourceforge.net/freeorion/revision/?rev=2024&view=rev Author: geoffthemedio Date: 2007-03-10 02:37:21 -0800 (Sat, 10 Mar 2007) Log Message: ----------- Fixed bug where type or status toggles wouldn't update properly when using the technavigator to examine / centre on a tech whose type or status was not being shown. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-03-09 16:08:07 UTC (rev 2023) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-03-10 10:37:21 UTC (rev 2024) @@ -1057,10 +1057,12 @@ void SetScale(double scale); void ShowCategory(const std::string& category); void HideCategory(const std::string& category); + void ShowType(const TechType type); + void HideType(const TechType type); + void ShowStatus(const TechStatus status); + void HideStatus(const TechStatus status); void ShowTech(const Tech* tech); void CenterOnTech(const Tech* tech); - void SetTechTypesShown(std::set<TechType> tech_types); - void SetTechStatusesShown(std::set<TechStatus> tech_statuses); //@} static const double ZOOM_STEP_SIZE; @@ -1587,9 +1589,38 @@ } } +void TechTreeWnd::LayoutPanel::ShowType(const TechType type) { + if (m_tech_types_shown.find(type) == m_tech_types_shown.end()) { + m_tech_types_shown.insert(type); + Layout(true); + } +} + +void TechTreeWnd::LayoutPanel::HideType(const TechType type) { + std::set<TechType>::iterator it = m_tech_types_shown.find(type); + if (it != m_tech_types_shown.end()) { + m_tech_types_shown.erase(it); + Layout(true); + } +} + +void TechTreeWnd::LayoutPanel::ShowStatus(const TechStatus status) { + if (m_tech_statuses_shown.find(status) == m_tech_statuses_shown.end()) { + m_tech_statuses_shown.insert(status); + Layout(true); + } +} + +void TechTreeWnd::LayoutPanel::HideStatus(const TechStatus status) { + std::set<TechStatus>::iterator it = m_tech_statuses_shown.find(status); + if (it != m_tech_statuses_shown.end()) { + m_tech_statuses_shown.erase(it); + Layout(true); + } +} + void TechTreeWnd::LayoutPanel::ShowTech(const Tech* tech) { - ShowCategory(tech->Category()); // ensure tech's category is visible TechClickedSlot(tech); } @@ -1605,18 +1636,6 @@ } } -void TechTreeWnd::LayoutPanel::SetTechTypesShown(std::set<TechType> tech_types) -{ - m_tech_types_shown = tech_types; - Layout(true); -} - -void TechTreeWnd::LayoutPanel::SetTechStatusesShown(std::set<TechStatus> tech_statuses) -{ - m_tech_statuses_shown = tech_statuses; - Layout(true); -} - void TechTreeWnd::LayoutPanel::Layout(bool keep_position, double old_scale/* = -1.0*/) { const int TECH_PANEL_MARGIN = ClientUI::Pts()*16; @@ -2016,26 +2035,16 @@ void TechTreeWnd::ShowStatus(const TechStatus status) { - std::set<TechStatus> statuses = m_layout_panel->GetTechStatusesShown(); - if (statuses.find(status) != statuses.end()) return; // check if status is already shown - - statuses.insert(status); - m_layout_panel->SetTechStatusesShown(statuses); - + m_layout_panel->ShowStatus(status); + CUIButton* button = m_tech_tree_controls->m_tech_status_buttons[status]; button->MarkSelectedGray(); } void TechTreeWnd::HideStatus(const TechStatus status) { - std::set<TechStatus> statuses = m_layout_panel->GetTechStatusesShown(); - std::set<TechStatus>::iterator it = statuses.find(status); - if (it == statuses.end()) return; // check if status is shown... if not, don't need to hide it - - statuses.erase(it); + m_layout_panel->HideStatus(status); - m_layout_panel->SetTechStatusesShown(statuses); - CUIButton* button = m_tech_tree_controls->m_tech_status_buttons[status]; button->MarkNotSelected(); } @@ -2053,11 +2062,7 @@ void TechTreeWnd::ShowType(const TechType type) { - std::set<TechType> types = m_layout_panel->GetTechTypesShown(); - if (types.find(type) != types.end()) return; // check if status is already shown - - types.insert(type); - m_layout_panel->SetTechTypesShown(types); + m_layout_panel->ShowType(type); CUIButton* button = m_tech_tree_controls->m_tech_type_buttons[type]; button->MarkSelectedGray(); @@ -2065,14 +2070,8 @@ void TechTreeWnd::HideType(const TechType type) { - std::set<TechType> types = m_layout_panel->GetTechTypesShown(); - std::set<TechType>::iterator it = types.find(type); - if (it == types.end()) return; // check if status is shown... if not, don't need to hide it - - types.erase(it); + m_layout_panel->HideType(type); - m_layout_panel->SetTechTypesShown(types); - CUIButton* button = m_tech_tree_controls->m_tech_type_buttons[type]; button->MarkNotSelected(); } @@ -2096,6 +2095,14 @@ void TechTreeWnd::CenterOnTech(const Tech* tech) { + // ensure tech is visible + const Empire* empire = Empires().Lookup(HumanClientApp::GetApp()->EmpireID()); + + ShowCategory(tech->Category()); + ShowStatus(empire->GetTechStatus(tech->Name())); + ShowType(tech->Type()); + + // centre on it m_layout_panel->ShowTech(tech); m_layout_panel->CenterOnTech(tech); } |
From: <geo...@us...> - 2007-04-27 10:34:12
|
Revision: 2043 http://svn.sourceforge.net/freeorion/revision/?rev=2043&view=rev Author: geoffthemedio Date: 2007-04-27 03:33:53 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Made TechTreeControls draggable around the tech tree layout panel, and made it a CUIWnd so it has a title bar with which to do the dragging. Current has hard-coded title text that needs to be made into a UserString... Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-04-26 05:50:44 UTC (rev 2042) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-04-27 10:33:53 UTC (rev 2043) @@ -3,6 +3,7 @@ #include "ClientUI.h" #include "CUIControls.h" #include "CUIDrawUtil.h" +#include "CUIWnd.h" #include "../util/MultiplayerCommon.h" #include "../util/OptionsDB.h" #include "../universe/Tech.h" @@ -343,7 +344,7 @@ ////////////////////////////////////////////////// /** A panel of buttons that control how the tech tree is displayed: what categories, statuses and types of techs to show. */ -class TechTreeWnd::TechTreeControls : public GG::Wnd +class TechTreeWnd::TechTreeControls : public CUIWnd { public: //! \name Structors //@{ @@ -377,17 +378,10 @@ static const int BUTTON_SEPARATION = 3; // vertical or horizontal sepration between adjacent buttons static const int UPPER_LEFT_PAD = 2; // offset of buttons' position from top left of controls box - static const int BORDER_LEFT = 4; - static const int BORDER_TOP = 4; - static const int BORDER_RIGHT = 4; - static const int BORDER_BOTTOM = 4; - static const int OUTER_EDGE_ANGLE_OFFSET = 11; - static const int RESIZE_HASHMARK1_OFFSET = 7; - static const int RESIZE_HASHMARK2_OFFSET = 3; }; TechTreeWnd::TechTreeControls::TechTreeControls(int x, int y, int w) : - GG::Wnd(x, y, w, 10, GG::CLICKABLE | GG::ONTOP) + CUIWnd("Tech Tree Display", x, y, w, 10, GG::CLICKABLE | GG::DRAGABLE) { // create a button for each tech category... const std::vector<std::string>& cats = GetTechManager().CategoryNames(); @@ -430,7 +424,7 @@ void TechTreeWnd::TechTreeControls::DoButtonLayout() { - const int RIGHT_EDGE_PAD = 12; + const int RIGHT_EDGE_PAD = 8; const int USABLE_WIDTH = std::max(ClientWidth() - RIGHT_EDGE_PAD, 1); // space in which to do layout const int PTS = ClientUI::Pts(); const int PTS_WIDE = PTS/2; // how wide per character the font needs... not sure how better to get this @@ -496,20 +490,22 @@ m_status_or_type_button_rows = 1; // only one row, three buttons per row // prevent window from being shrunk less than one button width, or current number of rows of height - SetMinSize(GG::Pt(UPPER_LEFT_PAD + MIN_BUTTON_WIDTH + 3*RIGHT_EDGE_PAD, UPPER_LEFT_PAD + (++row)*m_row_offset)); + SetMinSize(GG::Pt(UPPER_LEFT_PAD + MIN_BUTTON_WIDTH + 3*RIGHT_EDGE_PAD, CUIWnd::BORDER_TOP + CUIWnd::BORDER_BOTTOM + UPPER_LEFT_PAD + (++row)*m_row_offset)); } void TechTreeWnd::TechTreeControls::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { // maybe later do something interesting with docking - Wnd::SizeMove(ul, lr); // set width and upper left as user-requested + CUIWnd::SizeMove(ul, lr); // set width and upper left as user-requested DoButtonLayout(); // given set width, position buttons and set appropriate minimum height - Wnd::SizeMove(ul, GG::Pt(lr.x, ul.y + MinSize().y)); // width and upper left unchanged. set height to minimum height + CUIWnd::SizeMove(ul, GG::Pt(lr.x, ul.y + MinSize().y)); // width and upper left unchanged. set height to minimum height } void TechTreeWnd::TechTreeControls::Render() { + CUIWnd::Render(); + GG::Pt ul = UpperLeft(); GG::Pt lr = LowerRight(); GG::Pt cl_ul = ClientUpperLeft(); @@ -520,41 +516,7 @@ GLint initial_modes[2]; glGetIntegerv(GL_POLYGON_MODE, initial_modes); - // draw background - glPolygonMode(GL_BACK, GL_FILL); // filled in polygon - glBegin(GL_POLYGON); - glColor(ClientUI::WndColor()); - glVertex2i(ul.x, ul.y); - glVertex2i(lr.x, ul.y); - glVertex2i(lr.x, lr.y); - glVertex2i(ul.x, lr.y); - glVertex2i(ul.x, ul.y); - glEnd(); - - // draw border - glPolygonMode(GL_BACK, GL_LINE); // polygon outline only - glBegin(GL_POLYGON); - glColor(ClientUI::WndInnerBorderColor()); - glVertex2i(ul.x, ul.y); - glVertex2i(lr.x, ul.y); - glVertex2i(lr.x, lr.y - OUTER_EDGE_ANGLE_OFFSET); - glVertex2i(lr.x - OUTER_EDGE_ANGLE_OFFSET, lr.y); - glVertex2i(ul.x, lr.y); - glVertex2i(ul.x, ul.y); - glEnd(); - //*/ - glBegin(GL_LINES); - // draw extra resize-tab lines - glColor(ClientUI::WndInnerBorderColor()); - - glVertex2i(cl_lr.x, cl_lr.y - RESIZE_HASHMARK1_OFFSET); - glVertex2i(cl_lr.x - RESIZE_HASHMARK1_OFFSET, cl_lr.y); - - glVertex2i(cl_lr.x, cl_lr.y - RESIZE_HASHMARK2_OFFSET); - glVertex2i(cl_lr.x - RESIZE_HASHMARK2_OFFSET, cl_lr.y); - - // draw separator lines between types of buttons glColor(ClientUI::WndOuterBorderColor()); int category_bottom = cl_ul.y + m_category_button_rows*m_row_offset - BUTTON_SEPARATION/2 + UPPER_LEFT_PAD; @@ -593,13 +555,36 @@ void TechTreeWnd::TechTreeControls::LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys) { - if (m_drag_offset != GG::Pt(-1, -1)) { // resize-dragging - Resize((GG::Pt(pt.x, 0) - m_drag_offset) - UpperLeft()); // only respond to horizontal drags - } else { // normal-dragging - GG::Pt ul = UpperLeft(), lr = LowerRight(); - GG::Pt final_move(std::max(-ul.x, std::min(move.x, GG::GUI::GetGUI()->AppWidth() - 1 - lr.x)), - std::max(-ul.y, std::min(move.y, GG::GUI::GetGUI()->AppHeight() - 1 - lr.y))); - GG::Wnd::LDrag(pt + final_move - move, final_move, keys); + if (m_drag_offset != GG::Pt(-1, -1)) { // resize-dragging + GG::Pt new_lr = pt - m_drag_offset; + + new_lr.y = this->LowerRight().y; // ignore y-resizes + + // constrain to within parent + if (GG::Wnd* parent = Parent()) { + GG::Pt max_lr = parent->ClientLowerRight(); + new_lr.x = std::min(new_lr.x, max_lr.x); + } + + Resize(new_lr - UpperLeft()); // only respond to horizontal resize + } else { // normal-dragging + GG::Pt final_move = move; + + if (GG::Wnd* parent = Parent()) { + GG::Pt ul = UpperLeft(), lr = LowerRight(); + GG::Pt new_ul = ul + move, new_lr = lr + move; + + GG::Pt min_ul = parent->ClientUpperLeft(); + GG::Pt max_lr = parent->ClientLowerRight(); + GG::Pt max_ul = max_lr - this->Size(); + + new_ul.x = std::max(min_ul.x, std::min(max_ul.x, new_ul.x)); + new_ul.y = std::max(min_ul.y, std::min(max_ul.y, new_ul.y)); + + final_move = new_ul - ul; + } + + GG::Wnd::LDrag(pt, final_move, keys); } } @@ -1385,10 +1370,13 @@ const unsigned int ZBOFFSET = ClientUI::ScrollWidth() / 2; const unsigned int TOP = UpperLeft().y; const unsigned int LEFT = UpperLeft().x; - m_zoom_in_button = new CUIButton(w - ZBSIZE - ZBOFFSET - ClientUI::ScrollWidth(), ZBOFFSET, ZBSIZE, "+"); + + boost::shared_ptr<GG::Font> font = GG::GUI::GetGUI()->GetFont(ClientUI::Font(), ClientUI::Pts()); + + m_zoom_in_button = new CUIButton(w - ZBSIZE - ZBOFFSET - ClientUI::ScrollWidth(), ZBOFFSET, ZBSIZE, "+", font, ClientUI::ButtonColor(), ClientUI::CtrlBorderColor(), 1, ClientUI::TextColor(), GG::CLICKABLE | GG::ONTOP); m_zoom_out_button = new CUIButton(m_zoom_in_button->UpperLeft().x - LEFT, - m_zoom_in_button->LowerRight().y + ZBOFFSET - TOP, ZBSIZE, "-"); + m_zoom_in_button->LowerRight().y + ZBOFFSET - TOP, ZBSIZE, "-", font, ClientUI::ButtonColor(), ClientUI::CtrlBorderColor(), 1, ClientUI::TextColor(), GG::CLICKABLE | GG::ONTOP); AttachChild(m_layout_surface); AttachChild(m_vscroll); @@ -1919,9 +1907,7 @@ GG::Connect(m_layout_panel->TechDoubleClickedSignal, &TechTreeWnd::TechDoubleClickedSlot, this); AttachChild(m_layout_panel); - const unsigned int TREECONTWIDTH = m_layout_panel->Width() - ClientUI::ScrollWidth()*4; - m_tech_tree_controls = new TechTreeControls(0, 0, TREECONTWIDTH); - m_tech_tree_controls->SetMaxSize(GG::Pt(TREECONTWIDTH, m_layout_panel->Height() - ClientUI::ScrollWidth())); + m_tech_tree_controls = new TechTreeControls(0, 0, m_layout_panel->Width() - ClientUI::ScrollWidth()*4); m_tech_tree_controls->MoveTo(GG::Pt(1, 1)); const std::vector<std::string>& tech_categories = GetTechManager().CategoryNames(); // connect category button clicks to update display |
From: <geo...@us...> - 2007-04-28 05:10:19
|
Revision: 2045 http://svn.sourceforge.net/freeorion/revision/?rev=2045&view=rev Author: geoffthemedio Date: 2007-04-27 22:10:20 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Made TechNavigator and TechDetailPanel into resizable and draggable CUIWnds, like the TechTreeControls. Still need to fix layout of TechDetailPanel. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-04-28 04:39:47 UTC (rev 2044) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-04-28 05:10:20 UTC (rev 2045) @@ -59,8 +59,6 @@ const double MIN_SCALE = 0.1073741824; // = 1.0/(1.25)^10 const double MAX_SCALE = 1.0; - const int TECH_DETAIL_PANEL_ICON_SIZE = 128; - pointf Bezier(pointf* patch, double t) { pointf temp[6][6]; @@ -354,10 +352,7 @@ //! \name Mutators //@{ virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); virtual void Render(); - virtual void LButtonDown(const GG::Pt& pt, Uint32 keys); virtual void LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys); - virtual void LButtonUp(const GG::Pt& pt, Uint32 keys); - virtual void LClick(const GG::Pt& pt, Uint32 keys) {return LButtonUp(pt, keys);} //@} std::vector<CUIButton*> m_category_buttons; @@ -367,8 +362,6 @@ private: void DoButtonLayout(); - GG::Pt m_drag_offset; //!< offset from the lower-right corner of the point being used to drag-resize - int m_buttons_per_row; int m_col_offset; //!< horizontal distance between each column of buttons int m_row_offset; //!< vertical distance between each row of buttons @@ -377,11 +370,10 @@ static const int BUTTON_SEPARATION = 3; // vertical or horizontal sepration between adjacent buttons static const int UPPER_LEFT_PAD = 2; // offset of buttons' position from top left of controls box - }; TechTreeWnd::TechTreeControls::TechTreeControls(int x, int y, int w) : - CUIWnd("Tech Tree Display", x, y, w, 10, GG::CLICKABLE | GG::DRAGABLE) + CUIWnd("Display", x, y, w, 10, GG::CLICKABLE | GG::DRAGABLE | GG::RESIZABLE) { // create a button for each tech category... const std::vector<std::string>& cats = GetTechManager().CategoryNames(); @@ -496,10 +488,9 @@ void TechTreeWnd::TechTreeControls::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { // maybe later do something interesting with docking - - CUIWnd::SizeMove(ul, lr); // set width and upper left as user-requested - DoButtonLayout(); // given set width, position buttons and set appropriate minimum height - CUIWnd::SizeMove(ul, GG::Pt(lr.x, ul.y + MinSize().y)); // width and upper left unchanged. set height to minimum height + CUIWnd::SizeMove(ul, lr); // set width and upper left as user-requested + DoButtonLayout(); // given set width, position buttons and set appropriate minimum height + CUIWnd::SizeMove(ul, GG::Pt(lr.x, ul.y + MinSize().y)); // width and upper left unchanged. set height to minimum height } void TechTreeWnd::TechTreeControls::Render() @@ -544,14 +535,6 @@ glEnable(GL_TEXTURE_2D); } -void TechTreeWnd::TechTreeControls::LButtonDown(const GG::Pt& pt, Uint32 keys) -{ - GG::Pt cl_lr = LowerRight() - GG::Pt(BORDER_RIGHT, BORDER_BOTTOM); - GG::Pt dist_from_lr = cl_lr - pt; - if (dist_from_lr.x + dist_from_lr.y <= RESIZE_HASHMARK1_OFFSET) { - m_drag_offset = pt - LowerRight(); - } -} void TechTreeWnd::TechTreeControls::LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys) { @@ -566,7 +549,7 @@ new_lr.x = std::min(new_lr.x, max_lr.x); } - Resize(new_lr - UpperLeft()); // only respond to horizontal resize + Resize(new_lr - UpperLeft()); } else { // normal-dragging GG::Pt final_move = move; @@ -574,7 +557,7 @@ GG::Pt ul = UpperLeft(), lr = LowerRight(); GG::Pt new_ul = ul + move, new_lr = lr + move; - GG::Pt min_ul = parent->ClientUpperLeft(); + GG::Pt min_ul = parent->ClientUpperLeft() + GG::Pt(1, 1); GG::Pt max_lr = parent->ClientLowerRight(); GG::Pt max_ul = max_lr - this->Size(); @@ -588,24 +571,24 @@ } } -void TechTreeWnd::TechTreeControls::LButtonUp(const GG::Pt& pt, Uint32 keys) -{ - m_drag_offset = GG::Pt(-1, -1); -} ////////////////////////////////////////////////// // TechTreeWnd::TechDetailPanel // ////////////////////////////////////////////////// /** A panel of text controls and/or graphics that shows a greater level of detail about a tech (such as its full description text and effects text) than what appears in the tech graph. */ -class TechTreeWnd::TechDetailPanel : public GG::Wnd +class TechTreeWnd::TechDetailPanel : public CUIWnd { public: TechDetailPanel(int w, int h); const Tech* CurrentTech() const {return m_tech;} - virtual void Render(); + void SizeMove(const GG::Pt& ul, const GG::Pt& lr); + void Render(); + void LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys); + GG::Pt ClientUpperLeft() const; + void SetTech(const Tech* tech) {m_tech = tech; Reset();} private: @@ -622,7 +605,7 @@ }; TechTreeWnd::TechDetailPanel::TechDetailPanel(int w, int h) : - GG::Wnd(0, 0, w, h, 0), + CUIWnd("", 0, 0, w, h, GG::CLICKABLE | GG::DRAGABLE | GG::RESIZABLE), m_tech(0) { const int PTS = ClientUI::Pts(); @@ -631,10 +614,10 @@ const int SUMMARY_PTS = PTS*4/3; const int DESCRIPTION_PTS = PTS; - m_tech_name_text = new GG::TextControl(0, 0, w, 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::FontBold(), NAME_PTS), ClientUI::TextColor()); - m_cost_text = new GG::TextControl(0, 0, w, 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), COST_PTS), ClientUI::TextColor()); - m_summary_text = new GG::TextControl(0, 0, w, 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), SUMMARY_PTS), ClientUI::TextColor()); - m_description_box = new CUIMultiEdit(0, 0, w, 10, "", GG::TF_WORDBREAK | GG::MultiEdit::READ_ONLY); + m_tech_name_text = new GG::TextControl(0, 0, ClientWidth(), 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::FontBold(), NAME_PTS), ClientUI::TextColor()); + m_cost_text = new GG::TextControl(0, 0, ClientWidth(), 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), COST_PTS), ClientUI::TextColor()); + m_summary_text = new GG::TextControl(0, 0, ClientWidth(), 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), SUMMARY_PTS), ClientUI::TextColor()); + m_description_box = new CUIMultiEdit(0, 0, ClientWidth(), 10, "", GG::TF_WORDBREAK | GG::MultiEdit::READ_ONLY); m_description_box->SetColor(GG::CLR_ZERO); m_description_box->SetInteriorColor(GG::CLR_ZERO); @@ -690,11 +673,87 @@ } } +void TechTreeWnd::TechDetailPanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) +{ + // maybe later do something interesting with docking + GG::Wnd::SizeMove(ul, lr); + DoLayout(); +} + +GG::Pt TechTreeWnd::TechDetailPanel::ClientUpperLeft() const +{ + return UpperLeft() + GG::Pt(BORDER_LEFT, BORDER_TOP); +} + void TechTreeWnd::TechDetailPanel::Render() { + CUIWnd::Render(); + /* GG::Pt ul = UpperLeft(); GG::Pt lr = LowerRight(); + GG::Pt cl_ul = ClientUpperLeft(); + GG::Pt cl_lr = ClientLowerRight(); + // use GL to draw the lines + glDisable(GL_TEXTURE_2D); + GLint initial_modes[2]; + glGetIntegerv(GL_POLYGON_MODE, initial_modes); + + // draw background + glPolygonMode(GL_BACK, GL_FILL); + glBegin(GL_POLYGON); + glColor(ClientUI::WndColor()); + glVertex2i(ul.x, ul.y); + glVertex2i(lr.x, ul.y); + glVertex2i(lr.x, lr.y - OUTER_EDGE_ANGLE_OFFSET); + glVertex2i(lr.x - OUTER_EDGE_ANGLE_OFFSET, lr.y); + glVertex2i(ul.x, lr.y); + glVertex2i(ul.x, ul.y); + glEnd(); + + // draw outer border on pixel inside of the outer edge of the window + glPolygonMode(GL_BACK, GL_LINE); + glBegin(GL_POLYGON); + glColor(ClientUI::WndOuterBorderColor()); + glVertex2i(ul.x, ul.y); + glVertex2i(lr.x, ul.y); + glVertex2i(lr.x, lr.y - OUTER_EDGE_ANGLE_OFFSET); + glVertex2i(lr.x - OUTER_EDGE_ANGLE_OFFSET, lr.y); + glVertex2i(ul.x, lr.y); + glVertex2i(ul.x, ul.y); + glEnd(); + + // reset this to whatever it was initially + glPolygonMode(GL_BACK, initial_modes[1]); + + // draw inner border, including extra resize-tab lines + glBegin(GL_LINE_STRIP); + glColor(ClientUI::WndInnerBorderColor()); + glVertex2i(cl_ul.x, cl_ul.y); + glVertex2i(cl_lr.x, cl_ul.y); + glVertex2i(cl_lr.x, cl_lr.y - INNER_BORDER_ANGLE_OFFSET); + glVertex2i(cl_lr.x - INNER_BORDER_ANGLE_OFFSET, cl_lr.y); + glVertex2i(cl_ul.x, cl_lr.y); + glVertex2i(cl_ul.x, cl_ul.y); + glEnd(); + glBegin(GL_LINES); + // draw the extra lines of the resize tab + if (m_resizable) { + glColor(ClientUI::WndInnerBorderColor()); + } else { + glColor(GG::DisabledColor(ClientUI::WndInnerBorderColor())); + } + glVertex2i(cl_lr.x, cl_lr.y - RESIZE_HASHMARK1_OFFSET); + glVertex2i(cl_lr.x - RESIZE_HASHMARK1_OFFSET, cl_lr.y); + + glVertex2i(cl_lr.x, cl_lr.y - RESIZE_HASHMARK2_OFFSET); + glVertex2i(cl_lr.x - RESIZE_HASHMARK2_OFFSET, cl_lr.y); + glEnd(); + glEnable(GL_TEXTURE_2D); + */ + GG::Pt ul = UpperLeft(); + GG::Pt lr = LowerRight(); + // use GL to draw the lines glDisable(GL_TEXTURE_2D); GLint initial_modes[2]; @@ -724,6 +783,43 @@ } } +void TechTreeWnd::TechDetailPanel::LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys) +{ + if (m_drag_offset != GG::Pt(-1, -1)) { // resize-dragging + GG::Pt new_lr = pt - m_drag_offset; + + // constrain to within parent + if (GG::Wnd* parent = Parent()) { + GG::Pt max_lr = parent->ClientLowerRight(); + new_lr.x = std::min(new_lr.x, max_lr.x); + new_lr.y = std::min(new_lr.y, max_lr.y); + } + + Resize(new_lr - UpperLeft()); + } else { // normal-dragging + GG::Pt final_move = move; + + if (GG::Wnd* parent = Parent()) { + GG::Pt ul = UpperLeft(), lr = LowerRight(); + GG::Pt new_ul = ul + move, new_lr = lr + move; + + GG::Pt min_ul = parent->ClientUpperLeft() + GG::Pt(1, 1); + GG::Pt max_lr = parent->ClientLowerRight(); + GG::Pt max_ul = max_lr - this->Size(); + + new_ul.x = std::max(min_ul.x, std::min(max_ul.x, new_ul.x)); + new_ul.y = std::max(min_ul.y, std::min(max_ul.y, new_ul.y)); + + final_move = new_ul - ul; + } + + GG::Wnd::LDrag(pt, final_move, keys); + } +} + + + + void TechTreeWnd::TechDetailPanel::Reset() { if (m_tech_graphic) { @@ -792,7 +888,7 @@ ////////////////////////////////////////////////// /** A window with a single lisbox in it. The listbox represents the techs that are required for and are unlocked by some tech. Clicking on a prereq or unlocked tech will bring up that tech. */ -class TechTreeWnd::TechNavigator : public GG::Wnd +class TechTreeWnd::TechNavigator : public CUIWnd { public: enum {ROW_HEIGHT = 25}; @@ -805,6 +901,9 @@ mutable boost::signal<void (const Tech*)> TechClickedSignal; + virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); + virtual void LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys); + private: /** A control with a label \a str on it, and that is rendered partially onto the next row. The "Requires" and "Unlocks" rows are in of this class. */ @@ -837,6 +936,8 @@ }; static const int TECH_ROW_INDENTATION = 8; + static const int LB_MARGIN_X = 5; + static const int LB_MARGIN_Y = 5; GG::ListBox::Row* NewSectionHeaderRow(const std::string& str); GG::ListBox::Row* NewTechRow(const Tech* tech); @@ -849,12 +950,13 @@ }; TechTreeWnd::TechNavigator::TechNavigator(int w, int h) : - GG::Wnd(0, 0, w, h), + CUIWnd("Navigation", 0, 0, w, h, GG::CLICKABLE | GG::DRAGABLE | GG::RESIZABLE), m_current_tech(0) { - m_lb = new CUIListBox(1, 0, w, h - 2); + m_lb = new CUIListBox(LB_MARGIN_X, LB_MARGIN_Y, ClientWidth() - LB_MARGIN_X, ClientHeight() - LB_MARGIN_Y); m_lb->SetStyle(GG::LB_NOSORT | GG::LB_NOSEL); AttachChild(m_lb); + EnableChildClipping(true); } GG::ListBox::Row* TechTreeWnd::TechNavigator::NewSectionHeaderRow(const std::string& str) @@ -897,6 +999,49 @@ } } +void TechTreeWnd::TechNavigator::SizeMove(const GG::Pt& ul, const GG::Pt& lr) +{ + // maybe later do something interesting with docking + CUIWnd::SizeMove(ul, lr); + m_lb->Resize(ClientSize() - GG::Pt(2*LB_MARGIN_X, 2*LB_MARGIN_Y)); +} + +void TechTreeWnd::TechNavigator::LDrag(const GG::Pt& pt, const GG::Pt& move, Uint32 keys) +{ + if (m_drag_offset != GG::Pt(-1, -1)) { // resize-dragging + GG::Pt new_lr = pt - m_drag_offset; + + // constrain to within parent + if (GG::Wnd* parent = Parent()) { + GG::Pt max_lr = parent->ClientLowerRight(); + new_lr.x = std::min(new_lr.x, max_lr.x); + new_lr.y = std::min(new_lr.y, max_lr.y); + } + + Resize(new_lr - UpperLeft()); + } else { // normal-dragging + GG::Pt final_move = move; + + if (GG::Wnd* parent = Parent()) { + GG::Pt ul = UpperLeft(), lr = LowerRight(); + GG::Pt new_ul = ul + move, new_lr = lr + move; + + GG::Pt min_ul = parent->ClientUpperLeft() + GG::Pt(1, 1); + GG::Pt max_lr = parent->ClientLowerRight(); + GG::Pt max_ul = max_lr - this->Size(); + + new_ul.x = std::max(min_ul.x, std::min(max_ul.x, new_ul.x)); + new_ul.y = std::max(min_ul.y, std::min(max_ul.y, new_ul.y)); + + final_move = new_ul - ul; + } + + GG::Wnd::LDrag(pt, final_move, keys); + } +} + + + TechTreeWnd::TechNavigator::SectionHeaderControl::SectionHeaderControl(int w, int h, const std::string& str) : GG::Control(0, 0, w, h) { @@ -1892,23 +2037,21 @@ const int NAVIGATOR_WIDTH = 214; - m_tech_detail_panel = new TechDetailPanel(w - NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); - AttachChild(m_tech_detail_panel); - - m_tech_navigator = new TechNavigator(NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); - m_tech_navigator->MoveTo(GG::Pt(m_tech_detail_panel->Width(), 0)); - GG::Connect(m_tech_navigator->TechClickedSignal, &TechTreeWnd::CenterOnTech, this); - AttachChild(m_tech_navigator); - - m_layout_panel = new LayoutPanel(w, h - m_tech_detail_panel->Height()); - m_layout_panel->MoveTo(GG::Pt(0, m_tech_detail_panel->Height())); + m_layout_panel = new LayoutPanel(w, h); GG::Connect(m_layout_panel->TechBrowsedSignal, &TechTreeWnd::TechBrowsedSlot, this); GG::Connect(m_layout_panel->TechClickedSignal, &TechTreeWnd::TechClickedSlot, this); GG::Connect(m_layout_panel->TechDoubleClickedSignal, &TechTreeWnd::TechDoubleClickedSlot, this); AttachChild(m_layout_panel); - m_tech_tree_controls = new TechTreeControls(0, 0, m_layout_panel->Width() - ClientUI::ScrollWidth()*4); - m_tech_tree_controls->MoveTo(GG::Pt(1, 1)); + m_tech_detail_panel = new TechDetailPanel(m_layout_panel->ClientWidth() - NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); + m_layout_panel->AttachChild(m_tech_detail_panel); + + m_tech_navigator = new TechNavigator(NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); + m_tech_navigator->MoveTo(GG::Pt(m_tech_detail_panel->Width(), 1)); + GG::Connect(m_tech_navigator->TechClickedSignal, &TechTreeWnd::CenterOnTech, this); + m_layout_panel->AttachChild(m_tech_navigator); + + m_tech_tree_controls = new TechTreeControls(1, NAVIGATOR_AND_DETAIL_HEIGHT, m_layout_panel->Width() - ClientUI::ScrollWidth()*4); const std::vector<std::string>& tech_categories = GetTechManager().CategoryNames(); // connect category button clicks to update display for (unsigned int i = 0; i < m_tech_tree_controls->m_category_buttons.size() - 1; ++i) |
From: <geo...@us...> - 2008-04-20 10:38:29
|
Revision: 2505 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2505&view=rev Author: geoffthemedio Date: 2008-04-20 03:38:30 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Moved default location of tech tree controls to bottom of screen Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-04-20 09:24:14 UTC (rev 2504) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-04-20 10:38:30 UTC (rev 2505) @@ -2016,7 +2016,9 @@ GG::Connect(m_tech_navigator->TechClickedSignal, &TechTreeWnd::CenterOnTech, this); m_layout_panel->AttachChild(m_tech_navigator); - m_tech_tree_controls = new TechTreeControls(1, NAVIGATOR_AND_DETAIL_HEIGHT, m_layout_panel->Width() - ClientUI::ScrollWidth()*4); + m_tech_tree_controls = new TechTreeControls(1, NAVIGATOR_AND_DETAIL_HEIGHT, m_layout_panel->Width() - ClientUI::ScrollWidth()); + m_tech_tree_controls->MoveTo(GG::Pt(1, m_layout_panel->Height() - ClientUI::ScrollWidth() - m_tech_tree_controls->Height())); + const std::vector<std::string>& tech_categories = GetTechManager().CategoryNames(); // connect category button clicks to update display for (unsigned int i = 0; i < m_tech_tree_controls->m_category_buttons.size() - 1; ++i) |
From: <geo...@us...> - 2008-04-20 22:59:24
|
Revision: 2507 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2507&view=rev Author: geoffthemedio Date: 2008-04-20 15:59:30 -0700 (Sun, 20 Apr 2008) Log Message: ----------- -Made the tech tree panel spacing option have a step size of 0.05 instead of 1.0, so that it's actually useful. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-04-20 11:44:38 UTC (rev 2506) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-04-20 22:59:30 UTC (rev 2507) @@ -25,8 +25,8 @@ // command-line options void AddOptions(OptionsDB& db) { - db.Add("UI.tech-layout-horz-spacing", "OPTIONS_DB_UI_TECH_LAYOUT_HORZ_SPACING", 0.75, RangedValidator<double>(0.1, 10.0)); - db.Add("UI.tech-layout-vert-spacing", "OPTIONS_DB_UI_TECH_LAYOUT_VERT_SPACING", 1.0, RangedValidator<double>(0.1, 10.0)); + db.Add("UI.tech-layout-horz-spacing", "OPTIONS_DB_UI_TECH_LAYOUT_HORZ_SPACING", 0.75, RangedStepValidator<double>(0.05, 0.1, 10.0)); + db.Add("UI.tech-layout-vert-spacing", "OPTIONS_DB_UI_TECH_LAYOUT_VERT_SPACING", 1.0, RangedStepValidator<double>(0.05, 0.1, 10.0)); } bool temp_bool = RegisterOptions(&AddOptions); |
From: <geo...@us...> - 2008-05-19 07:59:41
|
Revision: 2561 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2561&view=rev Author: geoffthemedio Date: 2008-05-19 00:59:44 -0700 (Mon, 19 May 2008) Log Message: ----------- Improved tech list view Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-05-18 15:04:51 UTC (rev 2560) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-05-19 07:59:44 UTC (rev 2561) @@ -835,26 +835,26 @@ m_tech_name_text->SetText(UserString(m_tech->Name())); using boost::io::str; - using boost::format; - m_summary_text->SetText("<i>" + str(format(UserString("TECH_DETAIL_TYPE_STR")) - % UserString(m_tech->Category()) - % UserString(boost::lexical_cast<std::string>(m_tech->Type())) - % str(format(UserString(m_tech->ShortDescription())))) + "</i>"); + m_summary_text->SetText("<i>" + str(FlexibleFormat(UserString("TECH_DETAIL_TYPE_STR")) + % UserString(m_tech->Category()) + % UserString(boost::lexical_cast<std::string>(m_tech->Type())) + % UserString(m_tech->ShortDescription())) + + "</i>"); m_summary_text->SetColor(ClientUI::CategoryColor(m_tech->Category())); - m_cost_text->SetText(str(format(UserString("TECH_TOTAL_COST_STR")) - % static_cast<int>(m_tech->ResearchCost() + 0.5) - % m_tech->ResearchTurns())); + m_cost_text->SetText(str(FlexibleFormat(UserString("TECH_TOTAL_COST_STR")) + % static_cast<int>(m_tech->ResearchCost() + 0.5) + % m_tech->ResearchTurns())); - std::string description_str = str(format(UserString("TECH_DETAIL_DESCRIPTION_STR")) + std::string description_str = str(FlexibleFormat(UserString("TECH_DETAIL_DESCRIPTION_STR")) % UserString(m_tech->Description())); if (!m_tech->Effects().empty()) { - description_str += str(format(UserString("TECH_DETAIL_EFFECTS_STR")) + description_str += str(FlexibleFormat(UserString("TECH_DETAIL_EFFECTS_STR")) % EffectsDescription(m_tech->Effects())); } @@ -863,7 +863,7 @@ if (!unlocked_items.empty()) description_str += UserString("TECH_DETAIL_UNLOCKS_SECTION_STR"); for (unsigned int i = 0; i < unlocked_items.size(); ++i) { - description_str += str(format(UserString("TECH_DETAIL_UNLOCKED_ITEM_STR")) + description_str += str(FlexibleFormat(UserString("TECH_DETAIL_UNLOCKED_ITEM_STR")) % UserString(boost::lexical_cast<std::string>(unlocked_items[i].type)) % UserString(unlocked_items[i].name)); } @@ -2035,84 +2035,80 @@ class TechRow : public CUIListBox::Row { public: - TechRow(int w, int h, const Tech* tech); - const Tech* GetTech() { return m_tech; } + TechRow(int w, const Tech* tech); + const Tech* GetTech() { return m_tech; } + virtual void Render(); + static std::vector<int> ColWidths(int total_width); private: - class TechListBoxPanel; - TechListBoxPanel* m_panel; - const Tech* m_tech; - - class TechListBoxPanel : public GG::Control { - public: - TechListBoxPanel(int w, int h, const Tech* tech); - const Tech* GetTech() { return m_tech; } - virtual void Render(); - virtual void MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys); - private: - const Tech* m_tech; - GG::StaticGraphic* m_icon; - GG::TextControl* m_name; - GG::TextControl* m_cost; - GG::TextControl* m_description; - }; + const Tech* m_tech; }; }; -TechTreeWnd::TechListBox::TechRow::TechListBoxPanel::TechListBoxPanel(int w, int h, const Tech* tech) : - GG::Control(0, 0, w, h, GG::Flags<GG::WndFlag>()), - m_tech(tech), - m_icon(0), - m_name(0), - m_cost(0), - m_description(0) +void TechTreeWnd::TechListBox::TechRow::Render() { + GG::Pt ul = UpperLeft(); + GG::Pt lr = LowerRight(); + GG::FlatRectangle(ul.x, ul.y, lr.x, lr.y, ClientUI::WndColor(), GG::CLR_WHITE, 1); +} + +std::vector<int> TechTreeWnd::TechListBox::TechRow::ColWidths(int total_width) { + const int GRAPHIC_WIDTH = ClientUI::Pts() * 2; + const int NAME_WIDTH = ClientUI::Pts() * 18; + const int COST_WIDTH = ClientUI::Pts() * 2; + const int TIME_WIDTH = ClientUI::Pts() * 2; + const int DESC_WIDTH = std::max(1, total_width - GRAPHIC_WIDTH - NAME_WIDTH - COST_WIDTH - TIME_WIDTH); + std::vector<int> retval; + retval.push_back(GRAPHIC_WIDTH); + retval.push_back(NAME_WIDTH); + retval.push_back(COST_WIDTH); + retval.push_back(TIME_WIDTH); + retval.push_back(DESC_WIDTH); + return retval; +} + +TechTreeWnd::TechListBox::TechRow::TechRow(int w, const Tech* tech) : + CUIListBox::Row(w, ClientUI::Pts() * 2 + 5, "TechListBox::TechRow"), + m_tech(tech) { if (!tech) return; - const int PAD = 3; - const int NAME_WIDTH = ClientUI::Pts() * 20; - const int COST_WIDTH = ClientUI::Pts() * 20; + std::vector<int> col_widths = ColWidths(w); + const int GRAPHIC_WIDTH = col_widths[0]; + const int NAME_WIDTH = col_widths[1]; + const int COST_WIDTH = col_widths[2]; + const int TIME_WIDTH = col_widths[3]; + const int DESC_WIDTH = col_widths[4]; + const int HEIGHT = GRAPHIC_WIDTH; - const int HEIGHT = h - 6; // for some reason, full height isn't available... + GG::StaticGraphic* graphic = new GG::StaticGraphic(0, 0, GRAPHIC_WIDTH, HEIGHT, ClientUI::TechTexture(m_tech->Name()), GG::GRAPHIC_PROPSCALE | GG::GRAPHIC_FITGRAPHIC); + graphic->SetColor(ClientUI::CategoryColor(m_tech->Category())); + push_back(graphic); - m_icon = new GG::StaticGraphic(1, 1, HEIGHT, HEIGHT, ClientUI::TechTexture(m_tech->Name()), GG::GRAPHIC_PROPSCALE | GG::GRAPHIC_FITGRAPHIC); - m_icon->SetColor(ClientUI::CategoryColor(m_tech->Category())); - AttachChild(m_icon); - int left = HEIGHT + PAD; - boost::shared_ptr<GG::Font> font = GG::GUI::GetGUI()->GetFont(ClientUI::Font(), ClientUI::Pts()); - m_name = new GG::TextControl(left, 1, NAME_WIDTH, HEIGHT, UserString(m_tech->Name()), font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); - m_name->ClipText(true); - AttachChild(m_name); - left += NAME_WIDTH + PAD; + GG::TextControl* name = new GG::TextControl(0, 0, NAME_WIDTH, HEIGHT, UserString(m_tech->Name()), font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + name->ClipText(true); + push_back(name); - std::string cost_str = boost::io::str(FlexibleFormat(UserString("TECH_TOTAL_COST_STR")) % static_cast<int>(m_tech->ResearchCost() + 0.5) % m_tech->ResearchTurns()); - m_cost = new GG::TextControl(left, 1, COST_WIDTH, HEIGHT, cost_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); - AttachChild(m_cost); -} + std::string cost_str = boost::lexical_cast<std::string>(static_cast<int>(m_tech->ResearchCost() + 0.5)); + GG::TextControl* cost = new GG::TextControl(0, 0, COST_WIDTH, HEIGHT, cost_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(cost); -void TechTreeWnd::TechListBox::TechRow::TechListBoxPanel::MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys) { - GG::Wnd* parent = Parent(); - if (parent) - parent->MouseWheel(pt, move, mod_keys); -} + std::string time_str = boost::lexical_cast<std::string>(m_tech->ResearchTurns()); + GG::TextControl* time = new GG::TextControl(0, 0, TIME_WIDTH, HEIGHT, time_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(time); -void TechTreeWnd::TechListBox::TechRow::TechListBoxPanel::Render() { - GG::Pt ul = UpperLeft(); - GG::Pt lr = LowerRight(); - GG::FlatRectangle(ul.x, ul.y, lr.x, lr.y, ClientUI::WndColor(), GG::CLR_WHITE, 1); + using boost::io::str; + std::string desc_str = "<i>" + str(FlexibleFormat(UserString("TECH_DETAIL_TYPE_STR")) + % UserString(m_tech->Category()) + % UserString(boost::lexical_cast<std::string>(m_tech->Type())) + % UserString(m_tech->ShortDescription())) + + "</i>"; + GG::TextControl* desc = new GG::TextControl(0, 0, DESC_WIDTH, HEIGHT, desc_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(desc); } -TechTreeWnd::TechListBox::TechRow::TechRow(int w, int h, const Tech* tech) : - CUIListBox::Row(w, h, "TechListBox::TechRow"), - m_tech(tech) -{ - GG::Control* panel = new TechListBoxPanel(w, h, m_tech); - push_back(panel); -} - TechTreeWnd::TechListBox::TechListBox(int x, int y, int w, int h) : CUIListBox(x, y, w, h), m_categories_shown(), @@ -2139,6 +2135,14 @@ m_tech_types_shown.insert(TT_THEORY); m_tech_types_shown.insert(TT_APPLICATION); m_tech_types_shown.insert(TT_REFINEMENT); + + std::vector<int> col_widths = TechRow::ColWidths(w - ClientUI::ScrollWidth() - 6); + SetNumCols(col_widths.size()); + LockColWidths(); + for (unsigned int i = 0; i < col_widths.size(); ++i) { + SetColWidth(i, col_widths[i]); + SetColAlignment(i, GG::ALIGN_LEFT); + } } std::set<std::string> TechTreeWnd::TechListBox::GetCategoriesShown() const @@ -2170,13 +2174,11 @@ // remove techs in listbox Clear(); - const int ROW_HEIGHT = ClientUI::Pts() * 2 + 5; - TechManager& manager = GetTechManager(); for (TechManager::iterator it = manager.begin(); it != manager.end(); ++it) { const Tech* tech = *it; if (TechVisible(tech)) - Insert(new TechRow(Width() - ClientUI::ScrollWidth() - 6, ROW_HEIGHT, tech)); + Insert(new TechRow(Width() - ClientUI::ScrollWidth() - 6, tech)); } } |
From: <geo...@us...> - 2008-05-21 14:23:49
|
Revision: 2564 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2564&view=rev Author: geoffthemedio Date: 2008-05-21 07:23:20 -0700 (Wed, 21 May 2008) Log Message: ----------- Broke up tech list details into a few more columns to aide future sorting Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-05-21 13:39:51 UTC (rev 2563) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-05-21 14:23:20 UTC (rev 2564) @@ -2056,12 +2056,17 @@ const int NAME_WIDTH = ClientUI::Pts() * 18; const int COST_WIDTH = ClientUI::Pts() * 2; const int TIME_WIDTH = ClientUI::Pts() * 2; - const int DESC_WIDTH = std::max(1, total_width - GRAPHIC_WIDTH - NAME_WIDTH - COST_WIDTH - TIME_WIDTH); + const int CATEGORY_WIDTH = ClientUI::Pts() * 8; + const int TYPE_WIDTH = ClientUI::Pts() * 8; + + const int DESC_WIDTH = std::max(1, total_width - GRAPHIC_WIDTH - NAME_WIDTH - COST_WIDTH - TIME_WIDTH - CATEGORY_WIDTH - TYPE_WIDTH); std::vector<int> retval; retval.push_back(GRAPHIC_WIDTH); retval.push_back(NAME_WIDTH); retval.push_back(COST_WIDTH); retval.push_back(TIME_WIDTH); + retval.push_back(CATEGORY_WIDTH); + retval.push_back(TYPE_WIDTH); retval.push_back(DESC_WIDTH); return retval; } @@ -2075,11 +2080,13 @@ std::vector<int> col_widths = ColWidths(w); const int GRAPHIC_WIDTH = col_widths[0]; - const int NAME_WIDTH = col_widths[1]; - const int COST_WIDTH = col_widths[2]; - const int TIME_WIDTH = col_widths[3]; - const int DESC_WIDTH = col_widths[4]; - const int HEIGHT = GRAPHIC_WIDTH; + const int NAME_WIDTH = col_widths[1]; + const int COST_WIDTH = col_widths[2]; + const int TIME_WIDTH = col_widths[3]; + const int CATEGORY_WIDTH = col_widths[4]; + const int TYPE_WIDTH = col_widths[5]; + const int DESC_WIDTH = col_widths[6]; + const int HEIGHT = GRAPHIC_WIDTH; GG::StaticGraphic* graphic = new GG::StaticGraphic(0, 0, GRAPHIC_WIDTH, HEIGHT, ClientUI::TechTexture(m_tech->Name()), GG::GRAPHIC_PROPSCALE | GG::GRAPHIC_FITGRAPHIC); graphic->SetColor(ClientUI::CategoryColor(m_tech->Category())); @@ -2087,26 +2094,29 @@ boost::shared_ptr<GG::Font> font = GG::GUI::GetGUI()->GetFont(ClientUI::Font(), ClientUI::Pts()); - GG::TextControl* name = new GG::TextControl(0, 0, NAME_WIDTH, HEIGHT, UserString(m_tech->Name()), font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); - name->ClipText(true); - push_back(name); + GG::TextControl* text = new GG::TextControl(0, 0, NAME_WIDTH, HEIGHT, UserString(m_tech->Name()), font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + text->ClipText(true); + push_back(text); std::string cost_str = boost::lexical_cast<std::string>(static_cast<int>(m_tech->ResearchCost() + 0.5)); - GG::TextControl* cost = new GG::TextControl(0, 0, COST_WIDTH, HEIGHT, cost_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); - push_back(cost); + text = new GG::TextControl(0, 0, COST_WIDTH, HEIGHT, cost_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(text); std::string time_str = boost::lexical_cast<std::string>(m_tech->ResearchTurns()); - GG::TextControl* time = new GG::TextControl(0, 0, TIME_WIDTH, HEIGHT, time_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); - push_back(time); + text = new GG::TextControl(0, 0, TIME_WIDTH, HEIGHT, time_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(text); - using boost::io::str; - std::string desc_str = "<i>" + str(FlexibleFormat(UserString("TECH_DETAIL_TYPE_STR")) - % UserString(m_tech->Category()) - % UserString(boost::lexical_cast<std::string>(m_tech->Type())) - % UserString(m_tech->ShortDescription())) - + "</i>"; - GG::TextControl* desc = new GG::TextControl(0, 0, DESC_WIDTH, HEIGHT, desc_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); - push_back(desc); + std::string category_str = UserString(m_tech->Category()); + text = new GG::TextControl(0, 0, CATEGORY_WIDTH, HEIGHT, category_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(text); + + std::string type_str = UserString(boost::lexical_cast<std::string>(m_tech->Type())); + text = new GG::TextControl(0, 0, TYPE_WIDTH, HEIGHT, type_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(text); + + std::string desc_str = UserString(m_tech->ShortDescription()); + text = new GG::TextControl(0, 0, DESC_WIDTH, HEIGHT, desc_str, font, ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_VCENTER); + push_back(text); } TechTreeWnd::TechListBox::TechListBox(int x, int y, int w, int h) : |
From: <tz...@us...> - 2008-06-22 05:11:52
|
Revision: 2602 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2602&view=rev Author: tzlaine Date: 2008-06-21 21:20:35 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Changed TechTreeWnd::TechListBox to cache TechRows for future reuse, instead of recreating all of them everytime it is repopulated. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-22 02:48:12 UTC (rev 2601) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-22 04:20:35 UTC (rev 2602) @@ -2128,15 +2128,6 @@ mutable boost::signal<void (const Tech*)> TechDoubleClickedSignal; ///< emitted when a technology is double-clicked private: - void Populate(); - - void PropegateDoubleClickSignal(int index, GG::ListBox::Row* row); - void PropegateLeftClickSignal(int index, GG::ListBox::Row* row, const GG::Pt& pt); - - std::set<std::string> m_categories_shown; - std::set<TechType> m_tech_types_shown; - std::set<TechStatus> m_tech_statuses_shown; - class TechRow : public CUIListBox::Row { public: TechRow(int w, const Tech* tech); @@ -2147,6 +2138,15 @@ private: const Tech* m_tech; }; + + void Populate(); + void PropegateDoubleClickSignal(int index, GG::ListBox::Row* row); + void PropegateLeftClickSignal(int index, GG::ListBox::Row* row, const GG::Pt& pt); + + std::set<std::string> m_categories_shown; + std::set<TechType> m_tech_types_shown; + std::set<TechStatus> m_tech_statuses_shown; + std::vector<TechRow*> m_all_tech_rows; }; void TechTreeWnd::TechListBox::TechRow::Render() { @@ -2232,6 +2232,8 @@ GG::Connect(DoubleClickedSignal, &TechListBox::PropegateDoubleClickSignal, this); GG::Connect(LeftClickedSignal, &TechListBox::PropegateLeftClickSignal, this); + SetStyle(GG::LIST_NOSORT); + // show all categories... m_categories_shown.clear(); const std::vector<std::string> categories = GetTechManager().CategoryNames(); @@ -2285,24 +2287,37 @@ if (!Visible()) return; - // remove techs in listbox - Clear(); - Logger().debugStream() << "Tech List Box Populating"; - TechManager& manager = GetTechManager(); double creation_elapsed = 0.0; double insertion_elapsed = 0.0; boost::timer creation_timer; boost::timer insertion_timer; - for (TechManager::iterator it = manager.begin(); it != manager.end(); ++it) { - const Tech* tech = *it; - if (TechVisible(tech)) { + // HACK! This caching of TechRows works only if there are no "hidden" techs + // that are added to the manager mid-game. + TechManager& manager = GetTechManager(); + if (m_all_tech_rows.empty()) { + for (TechManager::iterator it = manager.begin(); it != manager.end(); ++it) { + const Tech* tech = *it; creation_timer.restart(); - TechRow* tr = new TechRow(Width() - ClientUI::ScrollWidth() - 6, tech); + m_all_tech_rows.push_back(new TechRow(Width() - ClientUI::ScrollWidth() - 6, tech)); creation_elapsed += creation_timer.elapsed(); + } + } + + // remove techs in listbox, then reset the rest of its state + for (reverse_iterator it = RBegin(); it != REnd(); ) { + Erase((++it).base()); + } + Clear(); + + for (std::vector<TechRow*>::iterator it = m_all_tech_rows.begin(); + it != m_all_tech_rows.end(); + ++it) { + TechRow* tech_row = *it; + if (TechVisible(tech_row->GetTech())) { insertion_timer.restart(); - Insert(tr); + Insert(*it); insertion_elapsed += insertion_timer.elapsed(); } } |
From: <geo...@us...> - 2008-06-22 09:37:36
|
Revision: 2600 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2600&view=rev Author: geoffthemedio Date: 2008-06-21 19:19:00 -0700 (Sat, 21 Jun 2008) Log Message: ----------- Switching back to redoing the tree layout when updating the tech tree panel to fix [ 1999643 ] Research Items (COMPLETED) Show When Hidden. Updating happens now after any changes to the queue or view filters, and the filters also cause the list to be repopulated. Most of the present speed issues on the tech tree are when the list gets repopulated, so this change isn't a huge performance hit, at least for me. If redoing the tree layout is actually a problem in future, we can alter things so only the affected techs' panels are updated when something is enqueued or dequeued. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-21 20:49:07 UTC (rev 2599) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-22 02:19:00 UTC (rev 2600) @@ -1734,9 +1734,8 @@ void TechTreeWnd::LayoutPanel::Update(const Tech* tech) { if (!tech) { - // update all tech panels - for (std::map<const Tech*, TechPanel*>::iterator tech_it = m_techs.begin(); tech_it != m_techs.end(); ++tech_it) - tech_it->second->Update(); + // redo entire layout + Layout(true); } else { // update just specified tech's panel std::map<const Tech*, TechPanel*>::iterator tech_it = m_techs.find(tech); |
From: <tz...@us...> - 2006-03-05 20:05:02
|
Revision: 1804 Author: tzlaine Date: 2006-03-05 12:04:56 -0800 (Sun, 05 Mar 2006) ViewCVS: http://svn.sourceforge.net/freeorion?rev=1804&view=rev Log Message: ----------- made TechTreeWnd::LayoutPanel's LayoutSurface at least as large as the client area, so that the entire client area is draggable. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2006-03-05 19:51:28 UTC (rev 1803) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2006-03-05 20:04:56 UTC (rev 1804) @@ -1481,8 +1481,12 @@ } GG::Pt client_sz = ClientSize(); - GG::Pt layout_size(static_cast<int>(PS2INCH(GD_bb(graph).UR.x - GD_bb(graph).LL.x) + 2 * TECH_PANEL_MARGIN + PROGRESS_PANEL_LEFT_EXTRUSION), - static_cast<int>(PS2INCH(GD_bb(graph).UR.y - GD_bb(graph).LL.y) + 2 * TECH_PANEL_MARGIN + PROGRESS_PANEL_BOTTOM_EXTRUSION)); + GG::Pt layout_size(std::max(client_sz.x, + static_cast<int>(PS2INCH(GD_bb(graph).UR.x - GD_bb(graph).LL.x) + + 2 * TECH_PANEL_MARGIN + PROGRESS_PANEL_LEFT_EXTRUSION)), + std::max(client_sz.y, + static_cast<int>(PS2INCH(GD_bb(graph).UR.y - GD_bb(graph).LL.y) + + 2 * TECH_PANEL_MARGIN + PROGRESS_PANEL_BOTTOM_EXTRUSION))); m_layout_surface->Resize(layout_size); m_vscroll->SizeScroll(0, layout_size.y - 1, std::max(50, std::min(layout_size.y / 10, client_sz.y)), client_sz.y); m_hscroll->SizeScroll(0, layout_size.x - 1, std::max(50, std::min(layout_size.x / 10, client_sz.x)), client_sz.x); |
From: <geo...@us...> - 2007-04-26 05:50:43
|
Revision: 2042 http://svn.sourceforge.net/freeorion/revision/?rev=2042&view=rev Author: geoffthemedio Date: 2007-04-25 22:50:44 -0700 (Wed, 25 Apr 2007) Log Message: ----------- -Tweaked how TechTreeControls layout works -Rearranged TechDetailPanel contents, removing buttons and separating layout from initial construction so that it will be easier to make this panel resizable at runtime Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-04-24 01:48:55 UTC (rev 2041) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2007-04-26 05:50:44 UTC (rev 2042) @@ -58,6 +58,8 @@ const double MIN_SCALE = 0.1073741824; // = 1.0/(1.25)^10 const double MAX_SCALE = 1.0; + const int TECH_DETAIL_PANEL_ICON_SIZE = 128; + pointf Bezier(pointf* patch, double t) { pointf temp[6][6]; @@ -366,13 +368,14 @@ GG::Pt m_drag_offset; //!< offset from the lower-right corner of the point being used to drag-resize - unsigned int m_buttons_per_row; - unsigned int m_col_offset; //!< horizontal distance between each column of buttons - unsigned int m_row_offset; //!< vertical distance between each row of buttons - unsigned int m_category_button_rows; - unsigned int m_status_or_type_button_rows; + int m_buttons_per_row; + int m_col_offset; //!< horizontal distance between each column of buttons + int m_row_offset; //!< vertical distance between each row of buttons + int m_category_button_rows; + int m_status_or_type_button_rows; - static const unsigned int BUTTON_SEPARATION = 3; // vertical or horizontal sepration between adjacent buttons + static const int BUTTON_SEPARATION = 3; // vertical or horizontal sepration between adjacent buttons + static const int UPPER_LEFT_PAD = 2; // offset of buttons' position from top left of controls box static const int BORDER_LEFT = 4; static const int BORDER_TOP = 4; @@ -427,32 +430,31 @@ void TechTreeWnd::TechTreeControls::DoButtonLayout() { - const unsigned int RIGHT_EDGE_PAD = 12; - const unsigned int ONE = 1; // unless I use this, I ge complaints from std::max that the type is ambiguous, and "unsigned int(1)" is apparently rejected by gcc - const unsigned int USABLE_WIDTH = std::max(ClientWidth() - RIGHT_EDGE_PAD, ONE); // space in which to do layout - const unsigned int PTS = ClientUI::Pts(); - const unsigned int PTS_WIDE = PTS/2; // how wide per character the font needs... not sure how better to get this - const unsigned int MIN_BUTTON_WIDTH = PTS_WIDE*18; // rough guesstimate... - const unsigned int MAX_BUTTONS_PER_ROW = std::max(USABLE_WIDTH / (MIN_BUTTON_WIDTH + BUTTON_SEPARATION), ONE); + const int RIGHT_EDGE_PAD = 12; + const int USABLE_WIDTH = std::max(ClientWidth() - RIGHT_EDGE_PAD, 1); // space in which to do layout + const int PTS = ClientUI::Pts(); + const int PTS_WIDE = PTS/2; // how wide per character the font needs... not sure how better to get this + const int MIN_BUTTON_WIDTH = PTS_WIDE*18; // rough guesstimate... + const int MAX_BUTTONS_PER_ROW = std::max(USABLE_WIDTH / (MIN_BUTTON_WIDTH + BUTTON_SEPARATION), 1); const float NUM_CATEGORY_BUTTONS = static_cast<float>(m_category_buttons.size()); - const unsigned int ROWS = static_cast<unsigned int>(std::ceil(NUM_CATEGORY_BUTTONS / MAX_BUTTONS_PER_ROW)); - m_buttons_per_row = static_cast<unsigned int>(std::ceil(NUM_CATEGORY_BUTTONS / ROWS)); // number of buttons in a typical row + const int ROWS = static_cast<int>(std::ceil(NUM_CATEGORY_BUTTONS / MAX_BUTTONS_PER_ROW)); + m_buttons_per_row = static_cast<int>(std::ceil(NUM_CATEGORY_BUTTONS / ROWS)); // number of buttons in a typical row - const unsigned int BUTTON_WIDTH = (USABLE_WIDTH - (m_buttons_per_row - 1)*BUTTON_SEPARATION) / m_buttons_per_row; - const unsigned int BUTTON_HEIGHT = m_category_buttons.back()->Height(); + const int BUTTON_WIDTH = (USABLE_WIDTH - (m_buttons_per_row - 1)*BUTTON_SEPARATION) / m_buttons_per_row; + const int BUTTON_HEIGHT = m_category_buttons.back()->Height(); m_col_offset = BUTTON_WIDTH + BUTTON_SEPARATION; // horizontal distance between each column of buttons m_row_offset = BUTTON_HEIGHT + BUTTON_SEPARATION; // vertical distance between each row of buttons - unsigned int row = 0, col = -1; + int row = 0, col = -1; for (std::vector<CUIButton*>::iterator it = m_category_buttons.begin(); it != m_category_buttons.end(); ++it) { ++col; if (col >= m_buttons_per_row) { ++row; col = 0; } - GG::Pt ul(col*m_col_offset, row*m_row_offset); + GG::Pt ul(UPPER_LEFT_PAD + col*m_col_offset, UPPER_LEFT_PAD+ row*m_row_offset); GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); (*it)->SizeMove(ul, lr); } @@ -465,7 +467,7 @@ ++row; col = 0; } - GG::Pt ul(col*m_col_offset, row*m_row_offset); + GG::Pt ul(UPPER_LEFT_PAD + col*m_col_offset, UPPER_LEFT_PAD + row*m_row_offset); GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); it->second->SizeMove(ul, lr); } @@ -481,7 +483,7 @@ ++row; col = 0; } - GG::Pt ul(col*m_col_offset, row*m_row_offset); + GG::Pt ul(UPPER_LEFT_PAD + col*m_col_offset, UPPER_LEFT_PAD + row*m_row_offset); GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); it->second->SizeMove(ul, lr); } @@ -493,14 +495,17 @@ else m_status_or_type_button_rows = 1; // only one row, three buttons per row - SetMinSize(GG::Pt(MIN_BUTTON_WIDTH + 3*RIGHT_EDGE_PAD, (++row)*m_row_offset)); + // prevent window from being shrunk less than one button width, or current number of rows of height + SetMinSize(GG::Pt(UPPER_LEFT_PAD + MIN_BUTTON_WIDTH + 3*RIGHT_EDGE_PAD, UPPER_LEFT_PAD + (++row)*m_row_offset)); } void TechTreeWnd::TechTreeControls::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { // maybe later do something interesting with docking - Wnd::SizeMove(ul, lr); - DoButtonLayout(); + + Wnd::SizeMove(ul, lr); // set width and upper left as user-requested + DoButtonLayout(); // given set width, position buttons and set appropriate minimum height + Wnd::SizeMove(ul, GG::Pt(lr.x, ul.y + MinSize().y)); // width and upper left unchanged. set height to minimum height } void TechTreeWnd::TechTreeControls::Render() @@ -552,14 +557,14 @@ // draw separator lines between types of buttons glColor(ClientUI::WndOuterBorderColor()); - int category_bottom = cl_ul.y + m_category_button_rows*m_row_offset - BUTTON_SEPARATION/2; + int category_bottom = cl_ul.y + m_category_button_rows*m_row_offset - BUTTON_SEPARATION/2 + UPPER_LEFT_PAD; glVertex2i(cl_ul.x, category_bottom); glVertex2i(cl_lr.x - 1, category_bottom); if (m_buttons_per_row >= 6) { // all six status and type buttons are on one row, and need a vertical separator between them - int middle = cl_ul.x + m_col_offset*3 - BUTTON_SEPARATION/2; + int middle = cl_ul.x + m_col_offset*3 - BUTTON_SEPARATION/2 + UPPER_LEFT_PAD; glVertex2i(middle, category_bottom); glVertex2i(middle, cl_lr.y - 1); @@ -612,24 +617,21 @@ { public: TechDetailPanel(int w, int h); + const Tech* CurrentTech() const {return m_tech;} + virtual void Render(); void SetTech(const Tech* tech) {m_tech = tech; Reset();} - mutable boost::signal<void (const Tech*)> CenterOnTechSignal; - mutable boost::signal<void (const Tech*)> QueueTechSignal; private: GG::Pt TechGraphicUpperLeft() const; - void CenterClickedSlot() {if (m_tech) CenterOnTechSignal(m_tech);} - void AddToQueueClickedSlot() {if (m_tech) QueueTechSignal(m_tech);} void Reset(); + void DoLayout(); const Tech* m_tech; GG::TextControl* m_tech_name_text; GG::TextControl* m_cost_text; GG::TextControl* m_summary_text; - CUIButton* m_recenter_button; - CUIButton* m_add_to_queue_button; CUIMultiEdit* m_description_box; GG::StaticGraphic* m_tech_graphic; }; @@ -638,37 +640,71 @@ GG::Wnd(0, 0, w, h, 0), m_tech(0) { - const int NAME_PTS = ClientUI::Pts() + 6; - const int SUMMARY_PTS = ClientUI::Pts() + 3; - const int COST_PTS = ClientUI::Pts(); - const int BUTTON_WIDTH = 150; - const int BUTTON_MARGIN = 5; - m_tech_name_text = new GG::TextControl(1, 0, w - 1 - BUTTON_WIDTH, NAME_PTS + 4, "", GG::GUI::GetGUI()->GetFont(ClientUI::FontBold(), NAME_PTS), ClientUI::TextColor()); - m_cost_text = new GG::TextControl(1, m_tech_name_text->LowerRight().y, w - 1 - BUTTON_WIDTH, COST_PTS + 4, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), COST_PTS), ClientUI::TextColor()); - m_summary_text = new GG::TextControl(1, m_cost_text->LowerRight().y, w - 1 - BUTTON_WIDTH, SUMMARY_PTS + 4, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), SUMMARY_PTS), ClientUI::TextColor()); - m_add_to_queue_button = new CUIButton(w - 1 - BUTTON_WIDTH, 1, BUTTON_WIDTH, UserString("TECH_DETAIL_ADD_TO_QUEUE")); - m_recenter_button = new CUIButton(w - 1 - BUTTON_WIDTH, m_add_to_queue_button->LowerRight().y + BUTTON_MARGIN, BUTTON_WIDTH, UserString("TECH_DETAIL_CENTER_ON_TECH")); - m_recenter_button->Hide(); - m_add_to_queue_button->Hide(); - m_recenter_button->Disable(); - m_add_to_queue_button->Disable(); - m_description_box = new CUIMultiEdit(1, m_summary_text->LowerRight().y, w - 2 - BUTTON_WIDTH, h - m_summary_text->LowerRight().y - 2, "", GG::TF_WORDBREAK | GG::MultiEdit::READ_ONLY); + const int PTS = ClientUI::Pts(); + const int NAME_PTS = PTS*3/2; + const int COST_PTS = PTS; + const int SUMMARY_PTS = PTS*4/3; + const int DESCRIPTION_PTS = PTS; + + m_tech_name_text = new GG::TextControl(0, 0, w, 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::FontBold(), NAME_PTS), ClientUI::TextColor()); + m_cost_text = new GG::TextControl(0, 0, w, 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), COST_PTS), ClientUI::TextColor()); + m_summary_text = new GG::TextControl(0, 0, w, 10, "", GG::GUI::GetGUI()->GetFont(ClientUI::Font(), SUMMARY_PTS), ClientUI::TextColor()); + m_description_box = new CUIMultiEdit(0, 0, w, 10, "", GG::TF_WORDBREAK | GG::MultiEdit::READ_ONLY); m_description_box->SetColor(GG::CLR_ZERO); m_description_box->SetInteriorColor(GG::CLR_ZERO); m_tech_graphic = 0; - GG::Connect(m_recenter_button->ClickedSignal, &TechTreeWnd::TechDetailPanel::CenterClickedSlot, this); - GG::Connect(m_add_to_queue_button->ClickedSignal, &TechTreeWnd::TechDetailPanel::AddToQueueClickedSlot, this); - AttachChild(m_tech_name_text); AttachChild(m_cost_text); AttachChild(m_summary_text); - AttachChild(m_recenter_button); - AttachChild(m_add_to_queue_button); AttachChild(m_description_box); + + DoLayout(); } +void TechTreeWnd::TechDetailPanel::DoLayout() +{ + const int USABLE_WIDTH = std::max(ClientWidth(), 1); + const int USABLE_HEIGHT = std::max(ClientHeight(), 1); + + const int PTS = ClientUI::Pts(); + const int NAME_PTS = PTS*3/2; + const int COST_PTS = PTS; + const int SUMMARY_PTS = PTS*4/3; + const int DESCRIPTION_PTS = PTS; + + const int ICON_SIZE = 12 + NAME_PTS + COST_PTS + SUMMARY_PTS; + + + // name + GG::Pt ul = GG::Pt(0, 0); + GG::Pt lr = ul + GG::Pt(USABLE_WIDTH, NAME_PTS + 4); + m_tech_name_text->SizeMove(ul, lr); + + // cost / turns + ul += GG::Pt(0, m_tech_name_text->Height()); + lr = ul + GG::Pt(USABLE_WIDTH, COST_PTS + 4); + m_cost_text->SizeMove(ul, lr); + + // one line summary + ul += GG::Pt(0, m_cost_text->Height()); + lr = ul + GG::Pt(USABLE_WIDTH, SUMMARY_PTS + 4); + m_summary_text->SizeMove(ul, lr); + + // main verbose description (fluff, effects, unlocks, ...) + ul = GG::Pt(0, ICON_SIZE); + lr = ul + GG::Pt(USABLE_WIDTH, USABLE_HEIGHT - ul.y); + m_description_box->SizeMove(ul, lr); + + // icon + if (m_tech_graphic) { + ul = GG::Pt(2, 2); + lr = ul + GG::Pt(ICON_SIZE, ICON_SIZE); + m_tech_graphic->SizeMove(ul, lr); + } +} + void TechTreeWnd::TechDetailPanel::Render() { GG::Pt ul = UpperLeft(); @@ -705,54 +741,54 @@ void TechTreeWnd::TechDetailPanel::Reset() { - m_tech_name_text->SetText(""); - m_summary_text->SetText(""); - m_cost_text->SetText(""); - m_description_box->SetText(""); - if (m_tech_graphic) { DeleteChild(m_tech_graphic); m_tech_graphic = 0; } if (!m_tech) { - m_recenter_button->Hide(); - m_add_to_queue_button->Hide(); - m_recenter_button->Disable(); - m_add_to_queue_button->Disable(); + m_tech_name_text->SetText(""); + m_summary_text->SetText(""); + m_cost_text->SetText(""); + m_description_box->SetText(""); return; } - m_recenter_button->Show(); - m_add_to_queue_button->Show(); - m_recenter_button->Disable(false); - m_add_to_queue_button->Disable(false); - - GG::Pt ul = TechGraphicUpperLeft(); - m_tech_graphic = new GG::StaticGraphic(ul.x, ul.y, 128, 128, + m_tech_graphic = new GG::StaticGraphic(0, 0, 10, 10, ClientUI::TechTexture(m_tech->Name()), GG::GR_FITGRAPHIC | GG::GR_PROPSCALE); m_tech_graphic->Show(); m_tech_graphic->SetColor(ClientUI::CategoryColor(m_tech->Category())); AttachChild(m_tech_graphic); + DoLayout(); + m_tech_name_text->SetText(UserString(m_tech->Name())); using boost::io::str; using boost::format; + m_summary_text->SetText("<i>" + str(format(UserString("TECH_DETAIL_TYPE_STR")) % UserString(m_tech->Category()) % UserString(boost::lexical_cast<std::string>(m_tech->Type()))) + " - " + str(format(UserString(m_tech->ShortDescription()))) + "</i>"); + m_summary_text->SetColor(ClientUI::CategoryColor(m_tech->Category())); + m_cost_text->SetText(str(format(UserString("TECH_TOTAL_COST_STR")) % static_cast<int>(m_tech->ResearchCost() + 0.5) % m_tech->ResearchTurns())); + + std::string description_str = str(format(UserString("TECH_DETAIL_DESCRIPTION_STR")) % UserString(m_tech->Description())); + + if (!m_tech->Effects().empty()) { description_str += str(format(UserString("TECH_DETAIL_EFFECTS_STR")) % EffectsDescription(m_tech->Effects())); } + + const std::vector<ItemSpec>& unlocked_items = m_tech->UnlockedItems(); if (!unlocked_items.empty()) description_str += UserString("TECH_DETAIL_UNLOCKS_SECTION_STR"); @@ -761,15 +797,11 @@ % UserString(boost::lexical_cast<std::string>(unlocked_items[i].type)) % UserString(unlocked_items[i].name)); } + + m_description_box->SetText(description_str); } -GG::Pt TechTreeWnd::TechDetailPanel::TechGraphicUpperLeft() const -{ - return GG::Pt(Width() - 2 - 150 + (150 - 128) / 2, m_recenter_button->LowerRight().y - UpperLeft().y + 5); -} - - ////////////////////////////////////////////////// // TechTreeWnd::TechNavigator // ////////////////////////////////////////////////// @@ -1873,8 +1905,6 @@ const int NAVIGATOR_WIDTH = 214; m_tech_detail_panel = new TechDetailPanel(w - NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); - GG::Connect(m_tech_detail_panel->CenterOnTechSignal, &TechTreeWnd::CenterOnTech, this); - GG::Connect(m_tech_detail_panel->QueueTechSignal, &TechTreeWnd::TechDoubleClickedSlot, this); AttachChild(m_tech_detail_panel); m_tech_navigator = new TechNavigator(NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); |
From: <tz...@us...> - 2008-06-29 20:09:13
|
Revision: 2615 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2615&view=rev Author: tzlaine Date: 2008-06-29 13:09:20 -0700 (Sun, 29 Jun 2008) Log Message: ----------- Fixed a crash bug in TechTreeWnd::TechListBox::Populate() due to incorrect use of GG::ListBox::reverse_iterators. Modified Paths: -------------- trunk/FreeOrion/UI/TechTreeWnd.cpp Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-29 19:27:05 UTC (rev 2614) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-29 20:09:20 UTC (rev 2615) @@ -2337,8 +2337,9 @@ } // remove techs in listbox, then reset the rest of its state - for (reverse_iterator it = rbegin(); it != rend(); ) { - Erase((++it).base()); + for (iterator it = begin(); it != end(); ) { + iterator temp_it = it++; + Erase(temp_it); } Clear(); |