diff options
author | Raphael Langella <raphael.langella@gmail.com> | 2010-12-20 01:09:08 +0100 |
---|---|---|
committer | Raphael Langella <raphael.langella@gmail.com> | 2010-12-22 21:53:59 +0100 |
commit | 6b358a346df4fa1687b6a44d8ba6aa4d0996882c (patch) | |
tree | d92f3a90dffdd49115364642fa69edc883d216cc /crawl-ref/source/tilereg-tab.cc | |
parent | 1002d3413621b9d123c5b352b49a6a083469c8ca (diff) | |
download | crawl-ref-6b358a346df4fa1687b6a44d8ba6aa4d0996882c.tar.gz crawl-ref-6b358a346df4fa1687b6a44d8ba6aa4d0996882c.zip |
Add methods to disable tabs in TabbedRegion.
Diffstat (limited to 'crawl-ref/source/tilereg-tab.cc')
-rw-r--r-- | crawl-ref/source/tilereg-tab.cc | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/crawl-ref/source/tilereg-tab.cc b/crawl-ref/source/tilereg-tab.cc index 6ea0d35ce0..ed469ccafd 100644 --- a/crawl-ref/source/tilereg-tab.cc +++ b/crawl-ref/source/tilereg-tab.cc @@ -42,6 +42,7 @@ void TabbedRegion::set_tab_region(int idx, GridRegion *reg, tileidx_t tile_tab) inf.ofs_y = 0; inf.min_y = 0; inf.max_y = 0; + inf.enabled = true; m_tabs.push_back(inf); } @@ -87,6 +88,9 @@ void TabbedRegion::activate_tab(int idx) if (invalid_index(idx)) return; + if (!m_tabs[idx].enabled) + return; + if (m_active == idx) return; @@ -116,10 +120,30 @@ bool TabbedRegion::invalid_index(int idx) const return (idx < 0 || (int)m_tabs.size() <= idx); } +void TabbedRegion::enable_tab(int idx) +{ + if (invalid_index(idx)) + return; + + m_tabs[idx].enabled = true; + m_dirty = true; +} + +void TabbedRegion::disable_tab(int idx) +{ + if (invalid_index(idx)) + return; + + m_tabs[idx].enabled = false; + m_dirty = true; +} + bool TabbedRegion::active_is_valid() const { if (invalid_index(m_active)) return (false); + if (!m_tabs[m_active].enabled) + return (false); if (!m_tabs[m_active].reg) return (false); @@ -150,7 +174,9 @@ void TabbedRegion::pack_buffers() for (int i = 0; i < (int)m_tabs.size(); ++i) { int ofs; - if (m_active == i) + if (!m_tabs[i].enabled) + continue; + else if (m_active == i) ofs = TAB_OFS_SELECTED; else if (m_mouse_tab == i) ofs = TAB_OFS_MOUSEOVER; @@ -208,7 +234,7 @@ void TabbedRegion::on_resize() for (size_t i = 0; i < m_tabs.size(); ++i) { - if (!m_tabs[i].reg) + if (!m_tabs[i].reg || !m_tabs[i].enabled) continue; m_tabs[i].reg->place(reg_sx, reg_sy); |