Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added --file-extensions to show filename extensions only.

  • Loading branch information...
commit 61e710d92cebbbe68fbdeff2840eb4b881dabb2a 1 parent 1c8a9f4
@acaudwell authored
View
1  ChangeLog
@@ -16,6 +16,7 @@
* Added --stop-at-time option to stop Gource after a number of seconds.
* Added --hide 'mouse' option.
* Added --highlight-dirs option.
+ * Added --file-extensions to show filename extensions only.
* Allow --file-idle-time 0 (files will never expire).
* Allow --start-position 'random' to set a random start position.
* --log-command VCS replaces multiple --log-command-VCS options.
View
3  README
@@ -133,6 +133,9 @@ options:
--file-filter REGEX
Filter out any files matching a specified regular expression.
+ --file-extensions
+ Show filename extensions only.
+
--user-image-dir DIRECTORY
Directory containing .jpg or .png images of users
(eg 'Full Name.png') to use as avatars.
View
3  data/gource.1
@@ -106,6 +106,9 @@ Highlight the names of all directories.
\fB\-\-file\-filter REGEX\fR
Filter out any files matching a specified regular expression.
.TP
+\fB\-\-file\-extensions\fR
+Show filename extensions only.
+.TP
\fB\-\-user\-image\-dir DIRECTORY\fR
Directory containing .jpg or .png images of users (eg 'Full Name.png') to use as avatars.
.TP
View
19 src/dirnode.cpp
@@ -878,18 +878,17 @@ void RDirNode::drawDirName(const FXFont& dirfont) const{
// project positions of files and directories on the display in 2d
void RDirNode::calcScreenPos() {
- if(!gGourceSettings.hide_dirnames) {
- screenpos = display.project(vec3f(pos.x, pos.y, 0.0));
- }
-
- if(!gGourceSettings.hide_filenames) {
+ screenpos = display.project(vec3f(pos.x, pos.y, 0.0));
- //first pass - calculate positions of names
- for(std::list<RFile*>::const_iterator it = files.begin(); it!=files.end(); it++) {
- RFile* f = *it;
- f->calcScreenPos(pos);
- }
+ //first pass - calculate positions of names
+ for(std::list<RFile*>::const_iterator it = files.begin(); it!=files.end(); it++) {
+ RFile* f = *it;
+ // TODO: different offsets for selected/not selected
+ if(f->isSelected())
+ f->calcScreenPos(pos + vec2f(5.5f, -2.0f));
+ else
+ f->calcScreenPos(pos + vec2f(5.5f, -1.0f));
}
for(std::list<RDirNode*>::const_iterator it = children.begin(); it != children.end(); it++) {
View
36 src/file.cpp
@@ -44,12 +44,14 @@ RFile::RFile(const std::string & name, const vec3f & colour, const vec2f & pos,
this->fullpath = name;
this->name = name;
+
path_hash = 0;
setPath();
namelist = glGenLists(1);
+ font = 0;
setSelected(false);
dir = 0;
@@ -93,30 +95,40 @@ void RFile::setPath() {
if(pos != std::string::npos) {
path = name.substr(0,pos+1);
name = name.substr(pos+1, std::string::npos);
- return;
+ } else {
+ path = std::string("");
}
- path = std::string("");
+ //trim name to just extension
+ if(gGourceSettings.file_extensions) {
+ int dotsep=0;
+ if((dotsep=name.rfind(".")) != std::string::npos && dotsep != name.size()-1 && dotsep != 0) {
+ shortname = name.substr(dotsep+1);
+ }
+ }
}
+int call_count = 0;
+
+
void RFile::setSelected(bool selected) {
+ if(font.getFTFont()!=0 && this->selected==selected) return;
if(selected) {
font = fontmanager.grab("FreeSans.ttf", 18);
} else {
font = fontmanager.grab("FreeSans.ttf", 11);
}
+
font.dropShadow(false);
font.roundCoordinates(true);
- namewidth = font.getWidth(name.c_str());
-
Pawn::setSelected(selected);
//pre-compile name display list
- glNewList(namelist, GL_COMPILE);
- font.draw(0.0f, 0.0f, name);
- glEndList();
+ //glNewList(namelist, GL_COMPILE);
+ // font.draw(0.0f, 0.0f, (selected || shortname.size()==0) ? name : shortname);
+ //glEndList();
}
const vec3f& RFile::getNameColour() const{
@@ -243,8 +255,8 @@ void RFile::drawNameText(float alpha) const {
vec3f drawpos = screenpos;
- drawpos.x += 10.0;
- drawpos.y -= 10.0;
+ //drawpos.x += 10.0;
+ //drawpos.y -= 10.0;
glPushMatrix();
@@ -254,12 +266,14 @@ void RFile::drawNameText(float alpha) const {
glPushMatrix();
glTranslatef(1.0, 1.0, 0.0);
glColor4f(0.0, 0.0, 0.0, name_alpha * 0.7f);
- glCallList(namelist);
+ //glCallList(namelist);
+ font.draw(0.0f, 0.0f, (selected || shortname.size()==0) ? name : shortname);
glPopMatrix();
//draw name
glColor4f(nameCol.x, nameCol.y, nameCol.z, name_alpha);
- glCallList(namelist);
+ //glCallList(namelist);
+ font.draw(0.0f, 0.0f, (selected || shortname.size()==0) ? name : shortname);
glPopMatrix();
}
View
2  src/file.h
@@ -45,6 +45,8 @@ class RFile : public Pawn {
GLuint namelist;
+ std::string shortname;
+
void setPath();
const vec3f& getNameColour() const;
void drawNameText(float alpha) const;
View
4 src/gource.cpp
@@ -1659,8 +1659,6 @@ void Gource::drawBloom(Frustum &frustum, float dt) {
glBlendFunc (GL_ONE, GL_ONE);
root->drawBloom(frustum, dt);
-
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void Gource::setMessage(const char* str, ...) {
@@ -1767,6 +1765,8 @@ void Gource::draw(float t, float dt) {
//draw bloom
drawBloom(frustum, dt);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
name_calc_time = SDL_GetTicks();
root->calcScreenPos();
View
9 src/gource_settings.cpp
@@ -58,7 +58,8 @@ void GourceSettings::help(bool extended_help) {
printf(" --colour-images Colourize user images\n\n");
printf(" -i, --file-idle-time SECONDS Time files remain idle (default: 60)\n");
- printf(" --file-filter REGEX Ignore files matching this regexe\n\n");
+ printf(" --file-filter REGEX Ignore files matching this regexe\n");
+ printf(" --file-extensions Show filename extensions only\n\n");
printf(" --max-files NUMBER Max number of active files (default: 1000)\n");
printf(" --max-file-lag SECONDS Max time files of a commit can take to appear\n\n");
@@ -184,6 +185,7 @@ GourceSettings::GourceSettings() {
arg_types["hide-mouse"] = "bool";
arg_types["highlight-all-users"] = "bool";
arg_types["highlight-dirs"] = "bool";
+ arg_types["file-extensions"] = "bool";
arg_types["disable-auto-rotate"] = "bool";
arg_types["disable-auto-skip"] = "bool";
@@ -314,6 +316,7 @@ void GourceSettings::setGourceDefaults() {
delete (*it);
}
file_filters.clear();
+ file_extensions = false;
}
void GourceSettings::commandLineOption(const std::string& name, const std::string& value) {
@@ -901,6 +904,10 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
}
}
+ if(gource_settings->getBool("file-extensions")) {
+ file_extensions=true;
+ }
+
if((entry = gource_settings->getEntry("file-filter")) != 0) {
ConfEntryList* filters = gource_settings->getEntries("file-filter");
View
1  src/gource_settings.h
@@ -111,6 +111,7 @@ class GourceSettings : public SDLAppSettings {
std::vector<std::string> highlight_users;
std::vector<std::string> follow_users;
std::vector<Regex*> file_filters;
+ bool file_extensions;
GourceSettings();
View
4 src/pawn.cpp
@@ -31,8 +31,9 @@ Pawn::Pawn(std::string name, vec2f pos, int tagid) {
shadow = false;
- this->shadowOffset = vec2f(2.0, 2.0);
+ namewidth = 0;
+ this->shadowOffset = vec2f(2.0, 2.0);
this->elapsed = 0.0;
this->fadetime = 1.0;
this->nametime = 5.0;
@@ -109,7 +110,6 @@ void Pawn::drawNameText(float alpha) const {
glColor4f(nameCol.x, nameCol.y, nameCol.z, alpha);
- float namewidth = font.getWidth(name);
font.draw(pos.x - ((float)namewidth/2.0), pos.y - size*1.2, name.c_str()); // above player
}
}
View
1  src/pawn.h
@@ -84,6 +84,7 @@ class Pawn : public QuadItem {
std::string getName();
virtual void setSelected(bool selected);
+ bool isSelected() { return selected; };
void setHidden(bool hidden){ this->hidden = hidden; }
bool isHidden() const { return hidden; }
Please sign in to comment.
Something went wrong with that request. Please try again.