diff options
author | Erihel <erihel@gmail.com> | 2013-04-26 04:56:58 -0700 |
---|---|---|
committer | Erihel <erihel@gmail.com> | 2013-04-26 04:56:58 -0700 |
commit | eb37da86cee79e024998ab39d52183ce4528466b (patch) | |
tree | 7f98ab20082bdb9a0bef14828df6822027d6c70e | |
parent | 837a97b65ecfc150d0aa9ab7ae4ba14ed42a0f5e (diff) | |
parent | 02cb9a699352d4cc4cbb0e396d40c0571301fd64 (diff) | |
download | colobot-eb37da86cee79e024998ab39d52183ce4528466b.tar.gz colobot-eb37da86cee79e024998ab39d52183ce4528466b.tar.bz2 colobot-eb37da86cee79e024998ab39d52183ce4528466b.zip |
Merge pull request #187 from xiendev/Programs-list-size
Fixes size of a programs list control
-rw-r--r-- | src/object/brain.cpp | 5 | ||||
-rw-r--r-- | src/ui/interface.cpp | 3 | ||||
-rw-r--r-- | src/ui/list.cpp | 17 | ||||
-rw-r--r-- | src/ui/window.cpp | 3 |
4 files changed, 23 insertions, 5 deletions
diff --git a/src/object/brain.cpp b/src/object/brain.cpp index 951a763..f42ea7e 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -1313,10 +1313,11 @@ bool CBrain::CreateInterface(bool bSelect) { if (!(m_main->GetRetroMode())) { ddim.x = dim.x*5.1f; - ddim.y = dim.y*2.0f; + ddim.y = dim.y*2.0f; // default => 2 pos.x = ox+sx*0.0f; pos.y = oy+sy*0.0f; - pw->CreateList(pos, ddim, -1, EVENT_OBJECT_PROGLIST, 1.10f); + + pw->CreateList(pos, ddim, -1, EVENT_OBJECT_PROGLIST, -1.10f); UpdateScript(pw); pos.x = ox+sx*5.2f; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 24d2626..893cd05 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -197,6 +197,9 @@ CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, Ev } // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { diff --git a/src/ui/list.cpp b/src/ui/list.cpp index 84aa8ca..fae7af9 100644 --- a/src/ui/list.cpp +++ b/src/ui/list.cpp @@ -68,6 +68,9 @@ CList::~CList() // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) { @@ -109,14 +112,22 @@ bool CList::MoveAdjust() idim.x = m_dim.x - marging * 2.0f / 640.f; idim.y = m_dim.y - marging * 2.0f / 480.f; - h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * m_expand; - + //If m_expand is less then zero, then try to apply it's absolute value + h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * ((m_expand < 0) ? -m_expand : m_expand); m_displayLine = static_cast<int>(idim.y / h); + if (m_displayLine == 0) return false; if (m_displayLine > LISTMAXDISPLAY) m_displayLine = LISTMAXDISPLAY; - idim.y = h * m_displayLine; + + // Stretch lines to fill whole area of a list, if needed + if (m_expand < 0 && (idim.y - (h * m_displayLine) < h)) + { + h = idim.y / m_displayLine; + } + + idim.y = h * m_displayLine; //Here cuts list size if height of shown elements is less then designed height m_dim.y = idim.y + marging * 2.0f / 480.f; ppos.x = ipos.x; diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 6013d37..69ef857 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -355,6 +355,9 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event } // Creates a new list. +// if expand is less then zero, then the list would try to use expand's absolute value, +// and try to scale items to some size, so that dim of the list would not change after +// adjusting CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand) |