diff --git a/src/tged/TGEdMain.h b/src/tged/TGEdMain.h index 7f3c5db0..93ad4295 100644 --- a/src/tged/TGEdMain.h +++ b/src/tged/TGEdMain.h @@ -35,6 +35,44 @@ // Externs // --------------------------------------------------------------------------- +/** + * bryanb: This is some low-down, dirty, C++ hack-o-ramma. + */ + +/** + * @brief Implements RTTI type defining. + * @typedef Tag + */ +template +struct RTTIResult { + typedef typename Tag::type type; + static type ptr; +}; + +template +typename RTTIResult::type RTTIResult::ptr; + +/** + * @brief Implements nasty hack to access private members of a class. + * @typedef Tag + * @typedef TypePtr + */ +template +struct HackTheGibson : RTTIResult { + /* fill it ... */ + struct filler { + filler() { RTTIResult::ptr = TypePtr; } + }; + static filler fillerObj; +}; + +template +typename HackTheGibson::filler HackTheGibson::fillerObj; + +// --------------------------------------------------------------------------- +// Externs +// --------------------------------------------------------------------------- + /** @brief */ extern std::string g_progExe; /** @brief */ diff --git a/src/tged/TGListWnd.h b/src/tged/TGListWnd.h index 3a315cdc..00670fc8 100644 --- a/src/tged/TGListWnd.h +++ b/src/tged/TGListWnd.h @@ -23,6 +23,11 @@ #include using namespace finalcut; +struct PrivateFListViewScrollToY { typedef void(FListView::*type)(int); }; +template class HackTheGibson; +struct PrivateFListViewIteratorFirst { typedef FListViewIterator FListView::*type; }; +template class HackTheGibson; + // --------------------------------------------------------------------------- // Constants // --------------------------------------------------------------------------- @@ -94,6 +99,15 @@ public: auto entry = g_tidLookups->groupVoice()[0U]; m_selected = entry; + // bryanb: HACK -- use HackTheGibson to access the private current listview iterator to get the scroll position + /* + * This uses the RTTI hack to access private members on FListView; and this code *could* break as a consequence. + */ + int firstScrollLinePos = 0; + if (m_listView.getCount() > 0) { + firstScrollLinePos = (m_listView.*RTTIResult::ptr).getPosition(); + } + m_listView.clear(); for (auto entry : g_tidLookups->groupVoice()) { // pad TGs properly @@ -114,6 +128,16 @@ public: m_listView.insert(line); } + // bryanb: HACK -- use HackTheGibson to access the private set scroll Y to set the scroll position + /* + * This uses the RTTI hack to access private members on FListView; and this code *could* break as a consequence. + */ + if (firstScrollLinePos > m_listView.getCount()) + firstScrollLinePos = 0; + if (firstScrollLinePos > 0 && m_listView.getCount() > 0) { + (m_listView.*RTTIResult::ptr)(firstScrollLinePos); + } + // generate dialog title uint32_t len = g_tidLookups->groupVoice().size(); std::stringstream ss;