mirror of https://github.com/YGGverse/Yoda.git
yggverse
3 months ago
10 changed files with 68 additions and 103 deletions
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
#include "progress.hpp" |
||||
|
||||
using namespace app::browser::main::tab::page; |
||||
|
||||
Progress::Progress() |
||||
{ |
||||
set_margin_top( |
||||
MARGIN |
||||
); |
||||
|
||||
set_margin_bottom( |
||||
MARGIN |
||||
); |
||||
|
||||
set_pulse_step( |
||||
PULSE_STEP |
||||
); |
||||
|
||||
set_opacity(0); // fixed height, not hide()
|
||||
} |
||||
|
||||
// Public actions
|
||||
void Progress::refresh( |
||||
double fraction |
||||
) { |
||||
// Toggle transparency
|
||||
set_opacity( |
||||
fraction < 1 ? 1 : 0 |
||||
); |
||||
|
||||
// Reset initial progress
|
||||
progress = fraction; |
||||
|
||||
// Animate progress function
|
||||
Glib::signal_timeout().connect( |
||||
[this]() -> bool |
||||
{ |
||||
double current = get_fraction(); |
||||
|
||||
if (current < progress) |
||||
{ |
||||
set_fraction( |
||||
current + PULSE_STEP |
||||
); |
||||
} |
||||
|
||||
return current < 1; |
||||
}, |
||||
ANIMATION_TIME |
||||
); |
||||
} |
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
#ifndef APP_BROWSER_MAIN_TAB_PAGE_PROGRESS_HPP |
||||
#define APP_BROWSER_MAIN_TAB_PAGE_PROGRESS_HPP |
||||
|
||||
#include <glibmm/main.h> |
||||
#include <gtkmm/progressbar.h> |
||||
|
||||
namespace app::browser::main::tab::page |
||||
{ |
||||
class Progress : public Gtk::ProgressBar |
||||
{ |
||||
const int MARGIN = 2; |
||||
const double PULSE_STEP = .1; |
||||
const int ANIMATION_TIME = 10; |
||||
|
||||
double progress = 0; |
||||
|
||||
public: |
||||
|
||||
Progress(); |
||||
|
||||
void refresh( |
||||
double fraction |
||||
); |
||||
}; |
||||
} |
||||
|
||||
#endif // APP_BROWSER_MAIN_TAB_PAGE_PROGRESS_HPP
|
Loading…
Reference in new issue