Skip to content

Commit

Permalink
[SUTK] Consider x component of scroll delta while calculating cursor …
Browse files Browse the repository at this point in the history
…pos etc.
  • Loading branch information
ravi688 committed Aug 9, 2024
1 parent fdba7bc commit 0cfbd8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions sutk/include/sutk/IInputDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace SUTK
{
ModifierKeyBits bits;

constexpr ModifierKeys() noexcept : bits(com::ForceIntToEnumClass<ModifierKeyBits>(0)) { }
constexpr ModifierKeys(ModifierKeyBits _bits) noexcept : bits(_bits) { }

bool shift() const noexcept { return HAS_FLAG(bits, ModifierKeyBits::ShiftBit); }
Expand Down
4 changes: 2 additions & 2 deletions sutk/source/Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace SUTK
{
LineCountType line = cursor.getLine();
_assert((line >= 0) && (line < m_lines.size()));
return { m_lines[line]->getCoordFromColPos(cursor.getColumn()), m_baselineHeight * cursor.getLine() + m_scrollDelta.y };
return { m_lines[line]->getCoordFromColPos(cursor.getColumn()) + m_scrollDelta.x, m_baselineHeight * cursor.getLine() + m_scrollDelta.y };
}

std::pair<s32, s32> Text::getUnclippedLineRange() noexcept
Expand All @@ -161,7 +161,7 @@ namespace SUTK
lineNo = std::min(lineNo, static_cast<s32>(m_lines.size()) - 1);
lineNo = std::max(lineNo, 0);
_assert(lineNo >= 0);
LineCountType colNo = m_lines[lineNo]->getColPosFromCoord(coords.x);
LineCountType colNo = m_lines[lineNo]->getColPosFromCoord(coords.x - m_scrollDelta.x);
return { lineNo, colNo };
}

Expand Down

0 comments on commit 0cfbd8c

Please sign in to comment.