Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
v0.2.3.1: N:00 bug fixed
Browse files Browse the repository at this point in the history
- name change: namespace text_overseer to gui
- the N:00 bug fixed: now time_duration_to_string doesn't return "just a moment ago" when time is exact minutes (such as 1:00, 2:00...)
- trivial change: _make_timer_tabbar_color_animation() sets bg_color as #ff8c00 dark orange (originally #eb6100)
  • Loading branch information
lazyahasil committed Mar 16, 2017
1 parent 9657f7e commit 2ce6be6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,4 @@ ModelManifest.xml

# FAKE - F# Make
.fake/
*.txt
31 changes: 16 additions & 15 deletions text_overseer/file_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ namespace file_system
)
{
enum class PeriodEnum { msecs, secs, mins, hours, days } base_period;
auto counted = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
const auto counted = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
auto remainder = counted;

if (counted == 0)
return periods.just_a_moment;
Expand All @@ -188,24 +189,24 @@ namespace file_system
else
base_period = PeriodEnum::msecs;

const auto msecs = counted % 1000;
counted /= 1000;
const auto secs = counted % 60;
counted /= 60;
const auto mins = counted % 60;
counted /= 60;
const auto hours = counted % 24;
counted /= 24;
const auto days = counted;
const auto msecs = remainder % 1000;
remainder /= 1000;
const auto secs = remainder % 60;
remainder /= 60;
const auto mins = remainder % 60;
remainder /= 60;
const auto hours = remainder % 24;
remainder /= 24;
const auto days = remainder;

// a pointer to the period string
const PeriodStringT* period = nullptr;
// check if the duration is smaller than a base period
if ((msecs == 0 && base_period == PeriodEnum::msecs)
|| (secs == 0 && base_period == PeriodEnum::secs)
|| (mins == 0 && base_period == PeriodEnum::mins)
|| (hours == 0 && base_period == PeriodEnum::hours)
|| (days == 0 && base_period == PeriodEnum::days))
if ((counted == 0 && base_period == PeriodEnum::msecs)
|| (counted < 1000 && base_period == PeriodEnum::secs)
|| (counted < 1000 * 60 && base_period == PeriodEnum::mins)
|| (counted < 1000 * 3600 && !hours && base_period == PeriodEnum::hours)
|| (counted < 1000 * 86400 && base_period == PeriodEnum::days))
return periods.just_a_moment;

StringT str;
Expand Down
20 changes: 3 additions & 17 deletions text_overseer/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using namespace nana;

namespace text_overseer
namespace gui
{
AbstractBoxUnit::AbstractBoxUnit(nana::window wd) : nana::panel<false>(wd)
{
Expand Down Expand Up @@ -42,7 +42,6 @@ namespace text_overseer

// widgets
btn_reload_.enabled(false);
API::window_icon(btn_folder_, paint::image(R"(%PATH%\shell32.dll,4)"));

// make event
_make_event_btn_reload();
Expand Down Expand Up @@ -124,17 +123,6 @@ namespace text_overseer

file_.close();
return true;

//#if _MSC_VER == 1900
// // Visual Studio bug: https://connect.microsoft.com/VisualStudio/feedback/details/1403302
// std::wstring_convert<std::codecvt_utf8_utf16<int16_t>, int16_t> converter;
// auto u16_ptr = reinterpret_cast<const int16_t*>(u16_str.data());
// textbox_.caption( converter.to_bytes(u16_ptr, u16_ptr + u16_str.size()) );
//
//#else
// std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
// textbox_.caption(converter.to_bytes(u16_str));
//#endif
}

bool AbstractIOFileBoxUnit::_check_last_write_time() noexcept
Expand Down Expand Up @@ -287,8 +275,6 @@ namespace text_overseer
}
}



try
{
if (locale == FileIO::encoding::utf16_le)
Expand Down Expand Up @@ -476,8 +462,8 @@ namespace text_overseer
auto factor = func_color_level(time);
this->tabbar_.tab_bgcolor(
index,
color(0xff - static_cast<int>(factor * 0x14),
0xff - static_cast<int>(factor * 0x9e),
color(0xff - static_cast<int>(factor * 0x00), // #ff8c00 dark orange
0xff - static_cast<int>(factor * 0x73),
0xff - static_cast<int>(factor * 0xff))
);
time += interval;
Expand Down
5 changes: 2 additions & 3 deletions text_overseer/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
#include <nana/gui/widgets/tabbar.hpp>
#include <nana/gui/widgets/textbox.hpp>

#define VERSION_STRING "0.2.3"
#define VERSION_STRING "0.2.3.1"

namespace text_overseer
namespace gui
{
constexpr int k_max_read_file_count = 3;
constexpr int k_max_check_count_last_file_write = 5;


class AbstractBoxUnit : public nana::panel<false>
{
public:
Expand Down
3 changes: 2 additions & 1 deletion text_overseer/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "gui.hpp"
#include "error_handler.hpp"

int main()
{
text_overseer::MainWindow window;
gui::MainWindow window;

window.show();

Expand Down

0 comments on commit 2ce6be6

Please sign in to comment.