void GUILABELLIST::UpdateElements(SCENENODE & scene) { unsigned num_new = m_values.size(); unsigned num_old = m_elements.size(); for (unsigned i = num_new; i < num_old; ++i) { static_cast<GUILABEL*>(m_elements[i])->Remove(scene); delete m_elements[i]; } m_elements.resize(num_new); for (unsigned i = num_old; i < num_new; ++i) { float x, y; GetElemPos(i, x, y); GUILABEL * element = new GUILABEL(); element->SetupDrawable( scene, *m_font, m_align, m_scalex, m_scaley, x, y, m_elemw, m_elemh, m_z); m_elements[i] = element; } for (unsigned i = 0; i < num_new; ++i) { static_cast<GUILABEL*>(m_elements[i])->SetText(m_values[i]); } }
void GUICONTROLLIST::Signal(EVENT ev) { if (ev == MOVEUP) { unsigned col, row; GetElemPos(m_active_element, col, row); int n = m_vertical ? m_active_element - 1 : m_active_element - m_cols; SetActiveElement(n); } else if (ev == MOVEDOWN) { unsigned col, row; GetElemPos(m_active_element, col, row); int n = m_vertical ? m_active_element + 1 : m_active_element + m_cols; SetActiveElement(n); } else if (ev == MOVELEFT) { unsigned col, row; GetElemPos(m_active_element, col, row); int n = m_vertical ? m_active_element - m_rows : m_active_element - 1; SetActiveElement(n); } else if (ev == MOVERIGHT) { unsigned col, row; GetElemPos(m_active_element, col, row); int n = m_vertical ? m_active_element + m_rows : m_active_element + 1; SetActiveElement(n); } else { m_signaln[ev](m_active_element + m_list_offset); GUICONTROL::Signal(ev); } }
void GuiLabelList::SetupDrawable( SceneNode & scene, const Font & font, int align, float scalex, float scaley, float z) { m_elements.resize(m_rows * m_cols); for (size_t i = 0; i < m_rows * m_cols; ++i) { float x, y; GetElemPos(i, x, y); float xywh[4] = {x + m_elemw * 0.5f, y + m_elemh * 0.5f, m_elemw, m_elemh}; GuiLabel * element = new GuiLabel(); element->SetupDrawable(scene, font, align, scalex, scaley, xywh, z); m_elements[i] = element; } }
void GUILABELLIST::SetupDrawable( SCENENODE & scene, const FONT & font, int align, float scalex, float scaley, float z) { m_elements.resize(m_rows * m_cols); for (size_t i = 0; i < m_rows * m_cols; ++i) { float x, y; GetElemPos(i, x, y); GUILABEL * element = new GUILABEL(); element->SetupDrawable( scene, font, align, scalex, scaley, x + m_elemw * 0.5f, y + m_elemh * 0.5f, m_elemw, m_elemh, z); m_elements[i] = element; } }
void GUIIMAGELIST::SetupDrawable( SCENENODE & scene, ContentManager & content, const std::string & path, const std::string & ext, float z) { m_elements.resize(m_rows * m_cols); for (size_t i = 0; i < m_elements.size(); ++i) { float x, y; GetElemPos(i, x, y); GUIIMAGE * element = new GUIIMAGE(); element->SetupDrawable( scene, content, path, ext, x + m_elemw * 0.5f, y + m_elemh * 0.5f, m_elemw, m_elemh, z); m_elements[i] = element; } }