Improved Vertical Scrolling

This commit is contained in:
techdragon.nguyen@gmail.com
2010-11-28 23:54:36 +00:00
parent 3205ebdc8b
commit 8fd35ac513
7 changed files with 70 additions and 47 deletions

View File

@@ -48,7 +48,7 @@ protected:
bool mClosed;
public:
TextScroller * mScroller;
VerticalTextScroller * mScroller;
bool mAutoTranslate;
float mSelectionTargetY;

View File

@@ -41,11 +41,11 @@ private:
size_t mNbItemsShown;
bool mScrollerInitialized;
float mHeight; // maximum height availble for display
int mMarginX;
int mMarginY; // margin used to allow text to scroll off screen without
float mMarginX;
float mMarginY; // margin used to allow text to scroll off screen without
// affecting look and feel. Should be enough
// for at least one line of text ( marginY)
float mVerticalScrollSpeed;
// for at least one line of text ( mY - line height of current font )
float mOriginalY; // mY initially, used to restore scroller to original position after update
protected:
string wordWrap(string sentence, float width);
@@ -54,6 +54,6 @@ public:
VerticalTextScroller(int fontId, float x, float y, float width, float height, float scrollSpeed = 30, size_t _minimumItems = 1);
void Render();
void Update(float dt);
void Add(string text);
};
#endif

View File

@@ -39,6 +39,8 @@ string& trim(string &str);
string& ltrim(string &str);
string& rtrim(string &str);
std::string join(vector<string> &v, string delim = " ");
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
std::vector<std::string> split(const std::string &s, char delim); //splits a string with "delim" and returns a vector of strings.
std::string wordWrap(std::string s, int width);