~ubuntu-branches/debian/stretch/gource/stretch

« back to all changes in this revision

Viewing changes to src/file.cpp

  • Committer: Package Import Robot
  • Author(s): Andrew Caudwell
  • Date: 2014-04-15 16:30:17 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20140415163017-ucdr2josj1spzrga
Tags: 0.41-1
* New upstream release
* Made VCS URIs canonical
* Changed watch file to look at Github for releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    namecol     = vec3(1.0, 1.0, 1.0);
39
39
    file_colour = colour;
40
40
 
41
 
    last_action = 0.0;
42
 
    expiring=false;
43
 
    removing=false;
 
41
    last_action    = 0.0f;
 
42
    fade_start     = -1.0f;
 
43
    expired        = false;
 
44
    forced_removal = false;
44
45
 
45
46
    shadow = true;
46
47
 
74
75
}
75
76
 
76
77
void RFile::remove(bool force) {
77
 
    last_action = elapsed - gGourceSettings.file_idle_time;
78
 
    if(force) removing = true;
 
78
    last_action = elapsed;
 
79
    fade_start  = elapsed;
 
80
    if(force) forced_removal = true;
79
81
}
80
82
 
81
83
void RFile::setDir(RDirNode* dir) {
185
187
    float alpha = Pawn::getAlpha();
186
188
 
187
189
    //user fades out if not doing anything
188
 
    if(elapsed - last_action > gGourceSettings.file_idle_time) {
189
 
        alpha = 1.0 - std::min(elapsed - last_action - gGourceSettings.file_idle_time, 1.0f);
 
190
    if(fade_start > 0.0f) {
 
191
        alpha = 1.0 - glm::clamp(elapsed - fade_start, 0.0f, 1.0f);
190
192
    }
191
193
 
192
194
    return alpha;
218
220
    //files have no momentum
219
221
    accel = vec2(0.0f, 0.0f);
220
222
 
 
223
    if(fade_start < 0.0f && gGourceSettings.file_idle_time > 0.0f && (elapsed - last_action) > gGourceSettings.file_idle_time) {
 
224
        fade_start = elapsed;
 
225
    }
 
226
    
221
227
    // has completely faded out
222
 
    if(!expiring && elapsed - last_action >= gGourceSettings.file_idle_time + 1.0) {
223
 
        expiring=true;
 
228
    if(fade_start > 0.0f && !expired && (elapsed - fade_start) >= 1.0) {
 
229
 
 
230
        expired = true;
224
231
 
225
232
        bool found = false;
226
 
 
227
233
        for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) {
228
234
            if((*it) == this) {
229
235
                found = true;
230
236
                break;
231
237
            }
232
 
 
233
238
        }
234
239
 
235
240
        if(!found) {
238
243
        }
239
244
    }
240
245
 
241
 
    if(isHidden() && !removing) elapsed = 0.0;
 
246
    if(isHidden() && !forced_removal) elapsed = 0.0;
242
247
}
243
248
 
244
249
void RFile::touch(const vec3 & colour) {
245
 
    if(removing) return;
 
250
    if(forced_removal) return;
246
251
 
 
252
    fade_start = -1.0f;
 
253
    
247
254
    //fprintf(stderr, "touch %s\n", fullpath.c_str());
248
255
 
249
256
    last_action = elapsed;
250
257
    touch_colour = colour;
251
258
 
252
259
    //un expire file
253
 
    if(expiring) {
 
260
    if(expired) {
254
261
        for(std::vector<RFile*>::iterator it = gGourceRemovedFiles.begin(); it != gGourceRemovedFiles.end(); it++) {
255
262
            if((*it) == this) {
256
263
                gGourceRemovedFiles.erase(it);
257
264
                break;
258
265
            }
259
266
        }
260
 
 
261
 
        expiring=false;
 
267
        expired=false;
262
268
    }
263
269
 
264
270
    showName();