Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F126280
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/util/gui/scroll-list.cpp b/util/gui/scroll-list.cpp
index edc65ccc..6efd5df6 100644
--- a/util/gui/scroll-list.cpp
+++ b/util/gui/scroll-list.cpp
@@ -1,65 +1,99 @@
#include "../bitmap.h"
#include "scroll-list.h"
#include "../font.h"
using namespace Gui;
static const int GradientMax = 50;
static int selectedGradientStart(){
static int color = Graphics::makeColor(19, 167, 168);
return color;
}
static int selectedGradientEnd(){
static int color = Graphics::makeColor(27, 237, 239);
return color;
}
ScrollList::ScrollList():
currentIndex(0),
fontSpacingX(0),
fontSpacingY(0),
currentPosition(0),
scrollWait(0),
selectedGradient(GradientMax, selectedGradientStart(), selectedGradientEnd()),
useGradient(false),
-useHighlight(false){}
+useHighlight(false),
+allowWrap(true){}
ScrollList::ScrollList(const ScrollList & copy):
currentIndex(copy.currentIndex),
fontSpacingX(copy.fontSpacingX),
fontSpacingY(copy.fontSpacingY),
currentPosition(copy.currentPosition),
scrollWait(copy.scrollWait),
selectedGradient(GradientMax, selectedGradientStart(), selectedGradientEnd()),
useGradient(copy.useGradient),
-useHighlight(copy.useHighlight){}
+useHighlight(copy.useHighlight),
+allowWrap(true){}
ScrollList::~ScrollList(){}
ScrollList & ScrollList::operator=(const ScrollList & copy){
return *this;
}
void ScrollList::act(){
}
void ScrollList::render(const Graphics::Bitmap &, const Font & font){
}
void ScrollList::addText(const std::string & text){
this->text.push_back(text);
}
void ScrollList::addText(const std::vector<std::string> & texts){
this->text.insert(text.end(), texts.begin(), texts.end());
}
+void ScrollList::setPosition(const Gui::Coordinate & location){
+ this->position = location;
+}
+
bool ScrollList::next(){
+ currentIndex++;
+ if (currentIndex >= text.size()){
+ if (allowWrap){
+ currentIndex = 0;
+ return true;
+ } else {
+ currentIndex = text.size()-1;
+ return false;
+ }
+ }
return true;
}
bool ScrollList::previous(){
+ if (currentIndex > 0){
+ currentIndex--;
+ } else if (currentIndex == 0){
+ if (allowWrap){
+ currentIndex = text.size()-1;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ScrollList::setCurrentIndex(unsigned int index){
+ if (index >= text.size()){
+ return false;
+ }
+ currentIndex = index;
return true;
}
diff --git a/util/gui/scroll-list.h b/util/gui/scroll-list.h
index c7264ee0..e8823ae6 100644
--- a/util/gui/scroll-list.h
+++ b/util/gui/scroll-list.h
@@ -1,81 +1,136 @@
#ifndef _gui_scroll_list_h
#define _gui_scroll_list_h
#include <string>
#include <vector>
#include "coordinate.h"
#include "../gradient.h"
class Font;
namespace Gui{
class ScrollList {
public:
ScrollList();
ScrollList(const ScrollList &);
virtual ~ScrollList();
//! copy
ScrollList & operator=(const ScrollList &);
//! Logic
virtual void act();
//! Render
virtual void render(const Graphics::Bitmap &, const Font & font);
//! Add text
virtual void addText(const std::string &);
- //! Add vector of text (replaces current text in the text vector)
+ //! Add vector of text
virtual void addText(const std::vector< std::string > &);
+
+ //! Set Position
+ virtual void setPosition(const Gui::Coordinate &);
+
+ //! Set font spacing
+ inline virtual void setFontSpacing(int x, int y){
+ this->fontSpacingX = x;
+ this->fontSpacingY = y;
+ }
+
+ //! Set font spacing X
+ inline virtual void setFontSpacingX(int x){
+ this->fontSpacingX = x;
+ }
+
+ //! Set font spacing X
+ inline virtual void setFontSpacingY(int y){
+ this->fontSpacingY = y;
+ }
//! Next
virtual bool next();
//! Previous
virtual bool previous();
+ //! Set current index
+ virtual bool setCurrentIndex(unsigned int index);
+
//! Get current index
- virtual inline unsigned int getCurrentIndex(){
+ virtual inline unsigned int getCurrentIndex() const{
return this->currentIndex;
}
+ //! Set gradient
+ virtual inline void setGradient(bool use){
+ this->useGradient = use;
+ }
+
+ //! Get gradient
+ virtual inline bool gradientActive() const {
+ return this->useGradient;
+ }
+
+ //! Set highlight
+ virtual inline void setHighlight(bool use){
+ this->useHighlight = use;
+ }
+
+ //! Get highlight
+ virtual inline bool highlightActive() const {
+ return this->useHighlight;
+ }
+
+ //! Set wrap
+ virtual inline void setWrap(bool wrap){
+ this->allowWrap = wrap;
+ }
+
+ //! Get wrap
+ virtual inline bool getWrap() const {
+ return this->allowWrap;
+ }
+
private:
//! Text
std::vector<std::string> text;
//! Current index
unsigned int currentIndex;
//! Coordinates (size of)
Gui::Coordinate position;
//! Font Spacing
int fontSpacingX, fontSpacingY;
//! Current position for smooth scrolling
int currentPosition;
//! Scroll wait
int scrollWait;
//! Gradient for selected cursor
Effects::Gradient selectedGradient;
//! Use gradient
bool useGradient;
//! Use highlight
bool useHighlight;
+
+ //! Is wrappable
+ bool allowWrap;
};
}
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:09 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68650
Default Alt Text
(5 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline