From ea71455f81e201f60bca1a46fb70a3b6764cc12a Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 29 Dec 2016 10:22:39 -0300 Subject: [PATCH] Fix ZoomEntry slider range After f8874f4f7b41a73db16c647aeaa7f95306c360ec, we fixed the zoom text entry but we broke the zoom slider. We weren't able to select zoom factors with the slider correctly (as the scale from 0 to 6400 was too big). Now we revert the change and make the maximum text length in entry bigger so the user can enter zoom levels like 6400 in the text entry and use the zoom slider. --- src/app/ui/zoom_entry.cpp | 4 ++-- src/ui/entry.cpp | 7 ++++++- src/ui/entry.h | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/ui/zoom_entry.cpp b/src/app/ui/zoom_entry.cpp index 8f82cc37b..8f5ec53db 100644 --- a/src/app/ui/zoom_entry.cpp +++ b/src/app/ui/zoom_entry.cpp @@ -31,11 +31,11 @@ using namespace gfx; using namespace ui; ZoomEntry::ZoomEntry() - : IntEntry( - 0, render::Zoom::fromLinearScale(render::Zoom::linearValues()-1).scale()*100, this) + : IntEntry(0, render::Zoom::linearValues()-1, this) , m_locked(false) { setSuffix("%"); + setMaxTextLength(6); // strlen("6400.0") == 6 setup_mini_look(this); setZoom(render::Zoom(1, 1)); diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index f8f2a138a..9f9cebee6 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -29,7 +29,7 @@ namespace ui { -Entry::Entry(std::size_t maxsize, const char* format, ...) +Entry::Entry(const std::size_t maxsize, const char* format, ...) : Widget(kEntryWidget) , m_timer(500, this) , m_maxsize(maxsize) @@ -71,6 +71,11 @@ Entry::~Entry() { } +void Entry::setMaxTextLength(const std::size_t maxsize) +{ + m_maxsize = maxsize; +} + bool Entry::isReadOnly() const { return m_readonly; diff --git a/src/ui/entry.h b/src/ui/entry.h index 52c3adcf0..4d77dbf46 100644 --- a/src/ui/entry.h +++ b/src/ui/entry.h @@ -18,9 +18,11 @@ namespace ui { class Entry : public Widget { public: - Entry(std::size_t maxsize, const char *format, ...); + Entry(const std::size_t maxsize, const char *format, ...); ~Entry(); + void setMaxTextLength(const std::size_t maxsize); + bool isPassword() const; bool isReadOnly() const; void setReadOnly(bool state);