Adding horizontal and vertical scrollability checks in FTextView
This commit is contained in:
parent
250c04cefd
commit
bd3b2b31bb
|
@ -1,3 +1,6 @@
|
||||||
|
2018-12-28 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Text scrolling in FTextView was broken since February 17th!
|
||||||
|
|
||||||
2018-12-28 Markus Gans <guru.mail@muenster.de>
|
2018-12-28 Markus Gans <guru.mail@muenster.de>
|
||||||
* Add the assignment operator (=) for FButton to set the button text
|
* Add the assignment operator (=) for FButton to set the button text
|
||||||
* Corrected shortening of overlong texts in the title bar of FDialog
|
* Corrected shortening of overlong texts in the title bar of FDialog
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
using namespace finalcut;
|
using namespace finalcut;
|
||||||
|
|
||||||
// Global application object
|
// Global application object
|
||||||
static std::shared_ptr<FString> temp_str { nullptr };
|
static std::weak_ptr<FString> temp_str;
|
||||||
|
|
||||||
|
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
|
@ -57,13 +57,15 @@ void doubleToItem ( FListBoxItem& item
|
||||||
// Import converter functions
|
// Import converter functions
|
||||||
FString& doubleToString (std::list<double>::const_iterator iter)
|
FString& doubleToString (std::list<double>::const_iterator iter)
|
||||||
{
|
{
|
||||||
return temp_str->setNumber(*iter);
|
auto temp = temp_str.lock();
|
||||||
|
return temp->setNumber(*iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
FString& mapToString ( std::map<FString
|
FString& mapToString ( std::map<FString
|
||||||
, FString>::const_iterator iter )
|
, FString>::const_iterator iter )
|
||||||
{
|
{
|
||||||
return *temp_str = iter->first + ": " + iter->second;
|
auto temp = temp_str.lock();
|
||||||
|
return *temp = iter->first + ": " + iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,7 +108,8 @@ class Listbox : public FDialog
|
||||||
Listbox::Listbox (FWidget* parent)
|
Listbox::Listbox (FWidget* parent)
|
||||||
: FDialog(parent)
|
: FDialog(parent)
|
||||||
{
|
{
|
||||||
temp_str = std::make_shared<FString>();
|
auto temp = std::make_shared<FString>();
|
||||||
|
temp_str = temp;
|
||||||
|
|
||||||
// listbox 1
|
// listbox 1
|
||||||
//----------
|
//----------
|
||||||
|
|
|
@ -143,7 +143,7 @@ void FTextView::scrollTo (int x, int y)
|
||||||
if ( ! isVisible() || ! (changeX || changeY) )
|
if ( ! isVisible() || ! (changeX || changeY) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( xoffset != x )
|
if ( changeX && isHorizontallyScrollable() )
|
||||||
{
|
{
|
||||||
int xoffset_end = int(maxLineWidth - getTextWidth());
|
int xoffset_end = int(maxLineWidth - getTextWidth());
|
||||||
xoffset = x;
|
xoffset = x;
|
||||||
|
@ -151,7 +151,7 @@ void FTextView::scrollTo (int x, int y)
|
||||||
if ( xoffset < 0 )
|
if ( xoffset < 0 )
|
||||||
xoffset = 0;
|
xoffset = 0;
|
||||||
|
|
||||||
if ( xoffset > xoffset_end )
|
if ( xoffset > xoffset_end && xoffset_end >= 0 )
|
||||||
xoffset = xoffset_end;
|
xoffset = xoffset_end;
|
||||||
|
|
||||||
if ( update_scrollbar )
|
if ( update_scrollbar )
|
||||||
|
@ -161,7 +161,7 @@ void FTextView::scrollTo (int x, int y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( yoffset != y )
|
if ( changeY && isVerticallyScrollable() )
|
||||||
{
|
{
|
||||||
int yoffset_end = int(getRows() - getTextHeight());
|
int yoffset_end = int(getRows() - getTextHeight());
|
||||||
yoffset = y;
|
yoffset = y;
|
||||||
|
|
|
@ -137,6 +137,10 @@ class FTextView : public FWidget
|
||||||
std::size_t getTextHeight();
|
std::size_t getTextHeight();
|
||||||
std::size_t getTextWidth();
|
std::size_t getTextWidth();
|
||||||
|
|
||||||
|
// Inquiry
|
||||||
|
bool isHorizontallyScrollable();
|
||||||
|
bool isVerticallyScrollable();
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void init();
|
void init();
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
|
@ -191,6 +195,14 @@ inline void FTextView::deleteRange (int from, int to)
|
||||||
inline void FTextView::deleteLine (int pos)
|
inline void FTextView::deleteLine (int pos)
|
||||||
{ deleteRange (pos, pos); }
|
{ deleteRange (pos, pos); }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline bool FTextView::isHorizontallyScrollable()
|
||||||
|
{ return bool( maxLineWidth > getTextWidth() ); }
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
inline bool FTextView::isVerticallyScrollable()
|
||||||
|
{ return bool( getRows() > getTextHeight() ); }
|
||||||
|
|
||||||
} // namespace finalcut
|
} // namespace finalcut
|
||||||
|
|
||||||
#endif // FTEXTVIEW_H
|
#endif // FTEXTVIEW_H
|
||||||
|
|
Loading…
Reference in New Issue