Skip to content
Permalink
Browse files
- scrollbar patch applied from cygal / quentin --> Thanks
  • Loading branch information
softcoder committed Nov 2, 2012
1 parent 61c86c1 commit b168f450b5c7fa443b8bd17635a00eac58e45192
Showing 12 changed files with 61 additions and 10 deletions.
@@ -723,6 +723,7 @@ const int GraphicScrollBar::defLength= 200;
GraphicScrollBar::GraphicScrollBar(std::string containerName, std::string objName)
: GraphicComponent(containerName, objName) {
lighted = false;
activated = false;
horizontal = false;
elementCount = 0;
visibleSize = 0;
@@ -741,13 +742,14 @@ void GraphicScrollBar::init(int x, int y, bool horizontal,int length, int thickn
this->visibleStart=0;
this->visibleCompPosStart=0;
this->visibleCompPosEnd=length;
lighted= false;
activated = false;
lighted = false;
}

bool GraphicScrollBar::mouseDown(int x, int y) {
if(getVisible() && getEnabled() && getEditable())
{
if(mouseMove(x,y))
if(activated)
{
if( elementCount>visibleSize) {
int pos;
@@ -771,6 +773,11 @@ bool GraphicScrollBar::mouseDown(int x, int y) {
return false;
}

void GraphicScrollBar::mouseUp(int x, int y) {
activated = false;
lighted = false;
}

void GraphicScrollBar::setVisibleStart(int vs){
visibleStart=vs;

@@ -806,20 +813,23 @@ void GraphicScrollBar::setVisibleSize(int visibleSize){

bool GraphicScrollBar::mouseClick(int x, int y){
bool result=GraphicComponent::mouseClick( x, y);
if(result)
if(result) {
activated = true;
lighted = true;
mouseDown( x, y);
return result;
}
return result;
}


bool GraphicScrollBar::mouseMove(int x, int y){
if(this->getVisible() == false) {
return false;
bool inScrollBar = GraphicComponent::mouseMove(x, y);
if (activated) {
lighted = true;
} else {
lighted = inScrollBar;
}

bool b= GraphicComponent::mouseMove(x, y);
lighted= b;
return b;
return inScrollBar;
}

int GraphicScrollBar::getLength() const {
@@ -355,6 +355,7 @@ class GraphicScrollBar: public GraphicComponent {
static const int defThickness;

private:
bool activated;
bool lighted;
bool horizontal;
int elementCount;
@@ -370,6 +371,7 @@ class GraphicScrollBar: public GraphicComponent {
void init(int x, int y, bool horizontal,int length=defLength, int thickness=defThickness);
virtual bool mouseDown(int x, int y);
virtual bool mouseMove(int x, int y);
virtual void mouseUp(int x, int y);
virtual bool mouseClick(int x, int y);


@@ -222,6 +222,11 @@ void MainMenu::mouseDownRight(int x, int y){
state->mouseClick(x, y, mbRight);
}

void MainMenu::mouseUpLeft(int x, int y){
if(GraphicComponent::getFade()<0.2f) return;
state->mouseUp(x, y, mbLeft);
}

void MainMenu::keyDown(SDL_KeyboardEvent key) {
state->keyDown(key);
}
@@ -74,6 +74,7 @@ class MainMenu: public ProgramState {
virtual void mouseMove(int x, int y, const MouseState *mouseState);
virtual void mouseDownLeft(int x, int y);
virtual void mouseDownRight(int x, int y);
virtual void mouseUpLeft(int x, int y);
virtual void keyDown(SDL_KeyboardEvent key);
virtual void keyUp(SDL_KeyboardEvent key);
virtual void keyPress(SDL_KeyboardEvent key);
@@ -115,6 +116,7 @@ class MenuState {
MenuState(Program *program, MainMenu *mainMenu, const string &stateName);
virtual ~MenuState();
virtual void mouseClick(int x, int y, MouseButton mouseButton)=0;
virtual void mouseUp(int x, int y, const MouseButton mouseButton){};
virtual void mouseMove(int x, int y, const MouseState *mouseState)=0;
virtual void render()=0;
virtual void update(){};
@@ -304,6 +304,12 @@ void MenuStateKeysetup::mouseClick(int x, int y, MouseButton mouseButton){
}
}

void MenuStateKeysetup::mouseUp(int x, int y, const MouseButton mouseButton){
if (mouseButton == mbLeft) {
keyScrollBar.mouseUp(x, y);
}
}

void MenuStateKeysetup::mouseMove(int x, int y, const MouseState *ms){
buttonReturn.mouseMove(x, y);
buttonOk.mouseMove(x, y);
@@ -64,6 +64,7 @@ class MenuStateKeysetup: public MenuState {
virtual ~MenuStateKeysetup();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void update();
void render();
@@ -324,6 +324,12 @@ void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){
}
}

void MenuStateLoadGame::mouseUp(int x, int y, const MouseButton mouseButton){
if (mouseButton == mbLeft) {
slotsScrollBar.mouseUp(x, y);
}
}

void MenuStateLoadGame::deleteSlot(int i){
if(selectedButton==slots[i]){
selectedButton=NULL;
@@ -54,6 +54,7 @@ class MenuStateLoadGame: public MenuState{
~MenuStateLoadGame();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void update();
void render();
@@ -588,6 +588,13 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
}
}

void MenuStateMasterserver::mouseUp(int x, int y, const MouseButton mouseButton){
if (mouseButton == mbLeft) {
userScrollBar.mouseUp(x, y);
serverScrollBar.mouseUp(x, y);
}
}

void MenuStateMasterserver::mouseMove(int x, int y, const MouseState *ms){
MutexSafeWrapper safeMutex((updateFromMasterserverThread != NULL ? updateFromMasterserverThread->getMutexThreadObjectAccessor() : NULL),string(extractFileFromDirectoryPath(__FILE__).c_str()) + "_" + intToStr(__LINE__));

@@ -117,6 +117,7 @@ class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterfa
~MenuStateMasterserver();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void update();
void render();
@@ -2005,6 +2005,15 @@ void MenuStateMods::showRemoteDesription(ModInfo *modInfo) {
}
}

void MenuStateMods::mouseUp(int x, int y, const MouseButton mouseButton){
if (mouseButton == mbLeft) {
keyTechScrollBar.mouseUp(x, y);
keyTilesetScrollBar.mouseUp(x, y);
keyMapScrollBar.mouseUp(x, y);
keyScenarioScrollBar.mouseUp(x, y);
}
}

void MenuStateMods::mouseMove(int x, int y, const MouseState *ms) {
buttonReturn.mouseMove(x, y);

@@ -184,6 +184,7 @@ class MenuStateMods: public MenuState, public FTPClientCallbackInterface, public
virtual ~MenuStateMods();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
void update();

0 comments on commit b168f45

Please sign in to comment.