Dialogs can now be displayed without a border

This commit is contained in:
Markus Gans 2020-04-09 12:38:35 +02:00
parent 53d2f04e77
commit 20c3cf218e
7 changed files with 83 additions and 7 deletions

View File

@ -1,3 +1,7 @@
2020-04-09 Markus Gans <guru.mail@muenster.de>
* A dialog can now be displayed without a framing border.
Many thanks to basedtho for this tip
2020-03-22 Markus Gans <guru.mail@muenster.de> 2020-03-22 Markus Gans <guru.mail@muenster.de>
* A small benchmakt test was added to the Rotozoomer example * A small benchmakt test was added to the Rotozoomer example

View File

@ -72,7 +72,7 @@ class RotoZoomer : public finalcut::FDialog
int loops{0}; int loops{0};
int path{0}; int path{0};
wchar_t data[256]{}; wchar_t data[256]{};
finalcut::FString report; finalcut::FString report{};
time_point<system_clock> start{}; time_point<system_clock> start{};
time_point<system_clock> end{}; time_point<system_clock> end{};
}; };

View File

@ -116,6 +116,28 @@ bool FDialog::setScrollable (bool enable)
return (setFlags().scrollable = 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) bool FDialog::setResizeable (bool enable)
{ {
@ -906,6 +928,9 @@ void FDialog::initCloseMenuItem (FMenu* menu)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::drawBorder() void FDialog::drawBorder()
{ {
if ( ! hasBorder() )
return;
if ( (getMoveSizeWidget() == this || ! resize_click_pos.isOrigin() ) if ( (getMoveSizeWidget() == this || ! resize_click_pos.isOrigin() )
&& ! isZoomed() ) && ! isZoomed() )
{ {

View File

@ -75,6 +75,14 @@ void FToolTip::setText (const FString& txt)
calculateDimensions(); calculateDimensions();
} }
//----------------------------------------------------------------------
bool FToolTip::setBorder (bool enable)
{
setFlags().no_border = ! enable;
calculateDimensions();
return hasBorder();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToolTip::show() void FToolTip::show()
{ {
@ -116,14 +124,18 @@ void FToolTip::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToolTip::draw() void FToolTip::draw()
{ {
int y{0}; bool border = hasBorder();
int y{( border ) ? 2 : 1};
int x{( border ) ? 3 : 2};
setColor(); setColor();
clearArea(); clearArea();
drawBorder();
if ( border )
drawBorder();
for (auto&& line : text_components) for (auto&& line : text_components)
{ {
print() << FPoint(3, 2 + y) << line; print() << FPoint(x, y) << line;
y++; y++;
} }
} }
@ -147,8 +159,8 @@ void FToolTip::calculateDimensions()
} }
int x{}, y{}; int x{}, y{};
const std::size_t h = text_num_lines + 2; const std::size_t h = ( hasBorder() ) ? text_num_lines + 2 : text_num_lines;
const std::size_t w = max_line_width + 4; const std::size_t w = ( hasBorder() ) ? max_line_width + 4 : max_line_width + 2;
const auto& r = getRootWidget(); const auto& r = getRootWidget();
if ( r ) if ( r )

View File

@ -105,11 +105,15 @@ class FDialog : public FWindow
bool setScrollable (bool); bool setScrollable (bool);
bool setScrollable(); bool setScrollable();
bool unsetScrollable(); bool unsetScrollable();
bool setBorder (bool);
bool setBorder();
bool unsetBorder();
void setText (const FString&); void setText (const FString&);
// Inquiries // Inquiries
bool isModal() const; bool isModal() const;
bool isScrollable() const; bool isScrollable() const;
bool hasBorder() const;
// Methods // Methods
void show() override; void show() override;
@ -264,6 +268,14 @@ inline bool FDialog::setScrollable()
inline bool FDialog::unsetScrollable() inline bool FDialog::unsetScrollable()
{ return setScrollable(false); } { return setScrollable(false); }
//----------------------------------------------------------------------
inline bool FDialog::setBorder()
{ return setBorder(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetBorder()
{ return setBorder(false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FDialog::setText (const FString& txt) inline void FDialog::setText (const FString& txt)
{ tb_text.setString(txt); } { tb_text.setString(txt); }
@ -276,6 +288,10 @@ inline bool FDialog::isModal() const
inline bool FDialog::isScrollable() const inline bool FDialog::isScrollable() const
{ return getFlags().scrollable; } { return getFlags().scrollable; }
//----------------------------------------------------------------------
inline bool FDialog::hasBorder() const
{ return ! getFlags().no_border; }
} // namespace finalcut } // namespace finalcut
#endif // FDIALOG_H #endif // FDIALOG_H

View File

@ -85,6 +85,12 @@ class FToolTip : public FWindow
// Mutators // Mutators
void setText (const FString&); void setText (const FString&);
bool setBorder (bool);
bool setBorder();
bool unsetBorder();
// Inquiries
bool hasBorder() const;
// Methods // Methods
void show() override; void show() override;
@ -113,6 +119,18 @@ class FToolTip : public FWindow
inline const FString FToolTip::getClassName() const inline const FString FToolTip::getClassName() const
{ return "FToolTip"; } { 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 } // namespace finalcut
#endif // FTOOLTIP_H #endif // FTOOLTIP_H

View File

@ -166,8 +166,9 @@ class FWidget : public FVTerm, public FObject
uInt32 menu_widget : 1; uInt32 menu_widget : 1;
uInt32 always_on_top : 1; uInt32 always_on_top : 1;
uInt32 flat : 1; uInt32 flat : 1;
uInt32 no_border : 1;
uInt32 no_underline : 1; uInt32 no_underline : 1;
uInt32 : 14; // padding bits uInt32 : 13; // padding bits
}; };
// Constructor // Constructor