diff --git a/ChangeLog b/ChangeLog index 3145a379..fcf772ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-04-09 Markus Gans + * A dialog can now be displayed without a framing border. + Many thanks to basedtho for this tip + 2020-03-22 Markus Gans * A small benchmakt test was added to the Rotozoomer example diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index 1cbda478..0323a3c8 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -72,7 +72,7 @@ class RotoZoomer : public finalcut::FDialog int loops{0}; int path{0}; wchar_t data[256]{}; - finalcut::FString report; + finalcut::FString report{}; time_point start{}; time_point end{}; }; diff --git a/src/fdialog.cpp b/src/fdialog.cpp index fd3c4bae..5c182f02 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -116,6 +116,28 @@ bool FDialog::setScrollable (bool enable) return (setFlags().scrollable = enable); } + +//---------------------------------------------------------------------- +bool FDialog::setBorder (bool enable) +{ + if ( enable ) + { + setTopPadding(2); + setLeftPadding(1); + setBottomPadding(1); + setRightPadding(1); + } + else + { + setTopPadding(1); + setLeftPadding(0); + setBottomPadding(0); + setRightPadding(0); + } + + return (setFlags().no_border = ! enable); +} + //---------------------------------------------------------------------- bool FDialog::setResizeable (bool enable) { @@ -906,6 +928,9 @@ void FDialog::initCloseMenuItem (FMenu* menu) //---------------------------------------------------------------------- void FDialog::drawBorder() { + if ( ! hasBorder() ) + return; + if ( (getMoveSizeWidget() == this || ! resize_click_pos.isOrigin() ) && ! isZoomed() ) { diff --git a/src/ftooltip.cpp b/src/ftooltip.cpp index e609b6f2..99136173 100644 --- a/src/ftooltip.cpp +++ b/src/ftooltip.cpp @@ -75,6 +75,14 @@ void FToolTip::setText (const FString& txt) calculateDimensions(); } +//---------------------------------------------------------------------- +bool FToolTip::setBorder (bool enable) +{ + setFlags().no_border = ! enable; + calculateDimensions(); + return hasBorder(); +} + //---------------------------------------------------------------------- void FToolTip::show() { @@ -116,14 +124,18 @@ void FToolTip::init() //---------------------------------------------------------------------- void FToolTip::draw() { - int y{0}; + bool border = hasBorder(); + int y{( border ) ? 2 : 1}; + int x{( border ) ? 3 : 2}; setColor(); clearArea(); - drawBorder(); + + if ( border ) + drawBorder(); for (auto&& line : text_components) { - print() << FPoint(3, 2 + y) << line; + print() << FPoint(x, y) << line; y++; } } @@ -147,8 +159,8 @@ void FToolTip::calculateDimensions() } int x{}, y{}; - const std::size_t h = text_num_lines + 2; - const std::size_t w = max_line_width + 4; + const std::size_t h = ( hasBorder() ) ? text_num_lines + 2 : text_num_lines; + const std::size_t w = ( hasBorder() ) ? max_line_width + 4 : max_line_width + 2; const auto& r = getRootWidget(); if ( r ) diff --git a/src/include/final/fdialog.h b/src/include/final/fdialog.h index 329c6d7a..73ab07e8 100644 --- a/src/include/final/fdialog.h +++ b/src/include/final/fdialog.h @@ -105,11 +105,15 @@ class FDialog : public FWindow bool setScrollable (bool); bool setScrollable(); bool unsetScrollable(); + bool setBorder (bool); + bool setBorder(); + bool unsetBorder(); void setText (const FString&); // Inquiries bool isModal() const; bool isScrollable() const; + bool hasBorder() const; // Methods void show() override; @@ -264,6 +268,14 @@ inline bool FDialog::setScrollable() inline bool FDialog::unsetScrollable() { return setScrollable(false); } +//---------------------------------------------------------------------- +inline bool FDialog::setBorder() +{ return setBorder(true); } + +//---------------------------------------------------------------------- +inline bool FDialog::unsetBorder() +{ return setBorder(false); } + //---------------------------------------------------------------------- inline void FDialog::setText (const FString& txt) { tb_text.setString(txt); } @@ -276,6 +288,10 @@ inline bool FDialog::isModal() const inline bool FDialog::isScrollable() const { return getFlags().scrollable; } +//---------------------------------------------------------------------- +inline bool FDialog::hasBorder() const +{ return ! getFlags().no_border; } + } // namespace finalcut #endif // FDIALOG_H diff --git a/src/include/final/ftooltip.h b/src/include/final/ftooltip.h index 49bf55e0..c88029bc 100644 --- a/src/include/final/ftooltip.h +++ b/src/include/final/ftooltip.h @@ -85,6 +85,12 @@ class FToolTip : public FWindow // Mutators void setText (const FString&); + bool setBorder (bool); + bool setBorder(); + bool unsetBorder(); + + // Inquiries + bool hasBorder() const; // Methods void show() override; @@ -113,6 +119,18 @@ class FToolTip : public FWindow inline const FString FToolTip::getClassName() const { return "FToolTip"; } +//---------------------------------------------------------------------- +inline bool FToolTip::setBorder() +{ return setBorder(true); } + +//---------------------------------------------------------------------- +inline bool FToolTip::unsetBorder() +{ return setBorder(false); } + +//---------------------------------------------------------------------- +inline bool FToolTip::hasBorder() const +{ return ! getFlags().no_border; } + } // namespace finalcut #endif // FTOOLTIP_H diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index ae9252f2..2b7369ee 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -166,8 +166,9 @@ class FWidget : public FVTerm, public FObject uInt32 menu_widget : 1; uInt32 always_on_top : 1; uInt32 flat : 1; + uInt32 no_border : 1; uInt32 no_underline : 1; - uInt32 : 14; // padding bits + uInt32 : 13; // padding bits }; // Constructor