Game Development Reference
In-Depth Information
{
m_inputDelay.Update(deltaTime);
m_button->Update(deltaTime);
m_contents->Update(deltaTime);
}
Drawingthedropdownwillconsistofdrawingthefirstiteminthelist,alongsidethebutton
that will open the dropdown. If a selection has been made, instead of drawing the first item
in the dropdown we will draw the selected item. Finally, if the dropdown box is open, we
will draw the listbox that contains the list of items.
void dropdown::InternalDraw()
{
m_button->Draw();
auto& textureView = *m_core->GetWhiteTexture()->GetView();
m_spriteBatch->Draw(textureView, m_rectangle, m_backgroundColor);
listbox::listboxitemtext* selection = static_cast<listbox::listboxitemtext*>((*m_contents->Items().begin()));
if ( m_contents->SelectedItems().size() == 1 )
{
selection = static_cast<listbox::listboxitemtext*>((*m_contents->SelectedItems().begin()));
}
m_font->DrawString(m_spriteBatch.get(), selection->Text().c_str(), m_rectangle.Position());
if ( m_open )
{
m_contents->Draw();
}
}
This example shows how we are able to construct a control by using a combination of con-
trolswepreviouslydeveloped.Thebiggestadvantageofreusingcontrolsinthiswayisthat
we are using stable and tested code.
4.3.11 Slider
A slider is useful numeric input control that allows players to select between a fixed range
of values. The most common place where we see slider controls is in sound configurations
to control the volume of sound effects and music, but they are also used to control gamma
values to calibrate displays.
Figure 59 - A slider control.
Search WWH ::




Custom Search