Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Document caption options, fixed height offset, added caption-offset o…

…ption (0 to centre).
  • Loading branch information...
commit 45c5d475bbbdb937158ce83e44f0bc3da2ac2e7e 1 parent 2263126
@acaudwell authored
View
1  ChangeLog
@@ -1,4 +1,5 @@
0.40:
+ * Added caption support.
* Fixed directory deletion short circuiting processing the rest of a commit.
* Fix to boost macros for Macs and non-GNU systems (mistydemeo).
* Autotools improvements (flameeyes).
View
23 README
@@ -229,6 +229,21 @@ options:
--hash-seed SEED
Change the seed of hash function.
+ --caption-file FILE
+ Caption file (see Caption Log Format).
+
+ --caption-size SIZE
+ Caption size.
+
+ --caption-colour FFFFFF
+ Caption colour in hex.
+
+ --caption-duration SECONDS
+ Caption duration.
+
+ --caption-offset X
+ Caption horizontal offset (0 to centre captions).
+
-o, --output-ppm-stream FILE
Output a PPM image stream to a file ('-' for STDOUT).
@@ -301,6 +316,14 @@ there is a pipe ('|') delimited custom log format:
file - Path of the file updated.
colour - A colour for the file in hex (FFFFFF) format. Optional.
+Caption Log Format:
+
+Gource can display captions along the timeline by specifying a caption file
+(using --caption-file) in the pipe ('|') delimited format below:
+
+ timestamp - A unix timestamp of when to display the caption.
+ caption - The caption
+
Recording Videos:
See the guide on the homepage for examples of recording videos with Gource:
View
34 data/gource.1
@@ -196,6 +196,21 @@ Separate multiple elements with commas (eg 'mouse,progress')
\fB\-\-hash\-seed SEED\fR
Change the seed of hash function.
.TP
+\fB\-\-caption-file FILE
+Caption file (see Caption Log Format).
+.TP
+\fB\-\-caption-size SIZE
+Caption size.
+.TP
+\fB\-\-caption-colour FFFFFF
+Caption colour in hex.
+.TP
+\fB\-\-caption-duration SECONDS
+Caption duration.
+.TP
+\fB\-\-caption-offset X
+Caption horizontal offset (0 to centre captions).
+.TP
\fB\-o, \-\-output\-ppm\-stream FILE\fR
Output a PPM image stream to a file ('\-' for STDOUT).
@@ -221,7 +236,7 @@ Either a supported version control directory, a pre-generated log file (see log
If path is omitted, gource will attempt to read a log from the current directory.
-.SH GIT, BAZAAR, MERCURIAL AND SVN EXAMPLES
+.SS Git, Bazaar, Mercurial and SVN Examples
View the log of the repository in the current path:
@@ -251,7 +266,7 @@ You can also have Gource write a copy of the log file in its own format:
.ti 10
\fIgource\fR \-\-output\-custom\-log my\-project\-custom.log
-.SH CVS SUPPORT
+.SS CVS Support
Use 'cvs2cl' to generate the log and then pass it to Gource:
@@ -260,7 +275,7 @@ cvs2cl \-\-chrono \-\-stdout \-\-xml \-g\-q > my\-cvs\-project.log
.ti 10
gource my\-cvs\-project.log
-.SH CUSTOM LOG FORMAT
+.SS Custom Log Format
If you want to use Gource with something other than the supported systems, there is a pipe ('|') delimited custom log format:
@@ -275,14 +290,23 @@ file - Path of the file updated.
.ti 10
colour - A colour for the file in hex (FFFFFF) format. Optional.
-.SH RECORDING VIDEOS
+.SS Caption Log Format
+
+Gource can display captions along the timeline by specifying a caption file (using \-\-caption\-file) in the pipe ('|') delimited format below:
+
+.ti 10
+timestamp - A unix timestamp of when to display the caption.
+.ti 10
+caption - The caption
+
+.SS Recording Videos
See the guide on the homepage for examples of recording videos with Gource:
.ti 10
http://code.google.com/p/gource/wiki/Videos
-.SH MORE INFORMATION
+.SS More Information
Visit the Gource homepage for guides and examples of using Gource with various version control systems:
View
29 src/caption.cpp
@@ -18,32 +18,39 @@
#include "caption.h"
RCaption::RCaption(const std::string& caption, time_t timestamp, const FXFont& font) {
- this->caption = caption;
+
+ this->caption = caption;
this->timestamp = timestamp;
this->font = font;
- alpha = 1.0f;
- colour = gGourceSettings.caption_colour;
- decay = 1.0f / gGourceSettings.caption_duration;
+ alpha = 0.0;
+ elapsed = 0.0;
+ colour = gGourceSettings.caption_colour;
}
-const vec2& RCaption::getPos() {
+void RCaption::setPos(const vec2& pos) {
+ this->pos = pos;
+}
+
+const vec2& RCaption::getPos() const {
return pos;
}
-void RCaption::setPos(const vec2& pos) {
- this->pos = pos;
+const std::string& RCaption::getCaption() const {
+ return caption;
}
-bool RCaption::isFinished() {
- return alpha <= 0.0f;
+bool RCaption::isFinished() const {
+ return elapsed >= gGourceSettings.caption_duration;
}
void RCaption::logic(float dt) {
- alpha = std::max(0.0f, alpha - dt * decay);
+ float fade_in = glm::min(2.0f, gGourceSettings.caption_duration / 3.0f);
+ elapsed += dt;
+ alpha = glm::min(1.0f, glm::min(elapsed,glm::max(0.0f,gGourceSettings.caption_duration-elapsed)) / fade_in);
}
void RCaption::draw() {
- font.setColour(vec4(colour.x, colour.y, colour.z, 1.0f - fabs(alpha - 0.5) * 2.0f));
+ font.setColour(vec4(colour.x, colour.y, colour.z, alpha));
font.draw(pos.x, pos.y, caption);
}
View
12 src/caption.h
@@ -24,24 +24,26 @@
class RCaption {
float alpha;
- float decay;
-
+ float elapsed;
+
vec2 pos;
vec3 colour;
FXFont font;
+ std::string caption;
public:
- std::string caption;
time_t timestamp;
RCaption(const std::string& caption, time_t timestamp, const FXFont& font);
void setPos(const vec2& pos);
- const vec2& getPos();
+
+ const vec2& getPos() const;
+ const std::string& getCaption() const;
- bool isFinished();
+ bool isFinished() const;
void logic(float dt);
View
24 src/gource.cpp
@@ -1085,7 +1085,7 @@ void Gource::readLog() {
//debugLog("readLog()\n");
// read commits until either we are ahead of currtime
- while(!commitlog->isFinished() && (commitqueue.empty() || commitqueue.back().timestamp <= currtime && commitqueue.size() < commitqueue_max_size)) {
+ while(!commitlog->isFinished() && (commitqueue.empty() || (commitqueue.back().timestamp <= currtime && commitqueue.size() < commitqueue_max_size)) ) {
RCommit commit;
@@ -1112,8 +1112,8 @@ void Gource::readLog() {
bool is_finished = commitlog->isFinished();
- if( gGourceSettings.stop_at_end && is_finished
- || gGourceSettings.stop_position > 0.0 && commitlog->isSeekable() && (is_finished || last_percent >= gGourceSettings.stop_position)) {
+ if( (gGourceSettings.stop_at_end && is_finished)
+ || (gGourceSettings.stop_position > 0.0 && commitlog->isSeekable() && (is_finished || last_percent >= gGourceSettings.stop_position)) ) {
stop_position_reached = true;
}
@@ -1694,7 +1694,7 @@ void Gource::logic(float t, float dt) {
if(caption->timestamp > currtime) break;
float cap_height = fontcaption.getMaxHeight();
-
+
float y = display.height - 10;
// add extra space if title is enabled
@@ -1706,8 +1706,9 @@ void Gource::logic(float t, float dt) {
bool found = false;
- for(std::list<RCaption*>::iterator it = active_captions.begin(); it!=active_captions.end();it++) {
+ for(std::list<RCaption*>::iterator it = active_captions.begin(); it!=active_captions.end(); it++) {
RCaption* actcap = *it;
+
vec2 cappos = actcap->getPos();
if(cappos.y == y) {
@@ -1721,7 +1722,16 @@ void Gource::logic(float t, float dt) {
y -= cap_height;
}
- caption->setPos(vec2(10.0f, y));
+ int offset_x = gGourceSettings.caption_offset;
+
+ // centre
+ if(offset_x == 0) {
+ offset_x = (display.width / 2) - (fontcaption.getWidth(caption->getCaption()) / 2);
+ } else if(offset_x < 0) {
+ offset_x = display.width - offset_x;
+ }
+
+ caption->setPos(vec2(offset_x, y));
captions.pop_front();
active_captions.push_back(caption);
@@ -1880,7 +1890,7 @@ void Gource::loadingScreen() {
glColor4f(1.0, 1.0, 1.0, 1.0);
- const char* progress;
+ const char* progress = "";
switch(int(runtime*3.0f)%4) {
case 0:
View
26 src/gource_settings.cpp
@@ -16,6 +16,7 @@
*/
#include "gource_settings.h"
+#include "core/sdlapp.h"
GourceSettings gGourceSettings;
@@ -128,7 +129,8 @@ if(extended_help) {
printf(" --caption-file FILE Caption file\n");
printf(" --caption-size SIZE Caption font size\n");
printf(" --caption-colour FFFFFF Caption colour in hex\n");
- printf(" --caption-duration SECONDS Caption duration (default: 10.0)\n\n");
+ printf(" --caption-duration SECONDS Caption duration (default: 10.0)\n");
+ printf(" --caption-offset X Caption horizontal offset\n\n");
printf(" --hash-seed SEED Change the seed of hash function.\n\n");
@@ -257,7 +259,6 @@ GourceSettings::GourceSettings() {
arg_types["load-config"] = "string";
arg_types["save-config"] = "string";
arg_types["output-custom-log"] = "string";
- arg_types["caption-file"] = "string";
arg_types["path"] = "string";
arg_types["log-command"] = "string";
arg_types["background-colour"] = "string";
@@ -280,6 +281,13 @@ GourceSettings::GourceSettings() {
arg_types["selection-colour"] = "string";
arg_types["dir-colour"] = "string";
+ arg_types["caption-file"] = "string";
+ arg_types["caption-size"] = "int";
+ arg_types["caption-duration"] = "float";
+ arg_types["caption-colour"] = "string";
+ arg_types["caption-offset"] = "int";
+
+
}
void GourceSettings::setGourceDefaults() {
@@ -373,6 +381,7 @@ void GourceSettings::setGourceDefaults() {
caption_file = "";
caption_duration = 10.0f;
caption_size = 24;
+ caption_offset = 10;
caption_colour = vec3(1.0f, 1.0f, 1.0f);
gStringHashSeed = 31;
@@ -688,7 +697,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
name = data;
#endif
- debugLog("%s => %s\n", name.c_str(), image_path.c_str());
+ debugLog("%s => %s", name.c_str(), image_path.c_str());
user_image_map[name] = image_path;
}
@@ -726,6 +735,13 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
}
}
+ if((entry = gource_settings->getEntry("caption-offset")) != 0) {
+
+ if(!entry->hasValue()) conffile.entryException(entry, "specify caption offset");
+
+ caption_offset = entry->getInt();
+ }
+
if((entry = gource_settings->getEntry("caption-colour")) != 0) {
if(!entry->hasValue()) conffile.entryException(entry, "specify caption colour (FFFFFF)");
@@ -956,7 +972,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
file_idle_time = (float) atoi(file_idle_str.c_str());
- if(file_idle_time<0.0f || file_idle_time == 0.0f && file_idle_str[0] != '0' ) {
+ if(file_idle_time<0.0f || (file_idle_time == 0.0f && file_idle_str[0] != '0') ) {
conffile.invalidValueException(entry);
}
if(file_idle_time==0.0f) {
@@ -1056,7 +1072,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
max_files = entry->getInt();
- if(max_files<0 || max_files == 0 && entry->getString() != "0") {
+ if( max_files<0 || (max_files == 0 && entry->getString() != "0") ) {
conffile.invalidValueException(entry);
}
}
View
1  src/gource_settings.h
@@ -136,6 +136,7 @@ class GourceSettings : public SDLAppSettings {
vec3 caption_colour;
float caption_duration;
int caption_size;
+ int caption_offset;
std::string output_custom_filename;
Please sign in to comment.
Something went wrong with that request. Please try again.