Skip to content

Commit

Permalink
- scrollbar patch applied from cygal / quentin --> Thanks
Browse files Browse the repository at this point in the history
  • Loading branch information
softcoder committed Nov 2, 2012
1 parent 61c86c1 commit b168f45
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 10 deletions.
30 changes: 20 additions & 10 deletions source/glest_game/facilities/components.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions source/glest_game/facilities/components.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class GraphicScrollBar: public GraphicComponent {
static const int defThickness;

private:
bool activated;
bool lighted;
bool horizontal;
int elementCount;
Expand All @@ -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);


Expand Down
5 changes: 5 additions & 0 deletions source/glest_game/menu/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions source/glest_game/menu/main_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(){};
Expand Down
6 changes: 6 additions & 0 deletions source/glest_game/menu/menu_state_keysetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_keysetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions source/glest_game/menu/menu_state_load_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_load_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions source/glest_game/menu/menu_state_masterserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__));

Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_masterserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions source/glest_game/menu/menu_state_mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_mods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit b168f45

Please sign in to comment.