Added FApplication::setDarkTheme() and FApplication::setDefaultTheme()
This commit is contained in:
parent
6a20b728ba
commit
f76a9d2114
|
@ -1,3 +1,9 @@
|
|||
2020-05-30 Markus Gans <guru.mail@muenster.de>
|
||||
* With the two new methods FApplication::setDarkTheme() and
|
||||
FApplication::setDefaultTheme() you can now change the theme
|
||||
within an application. An example can be found in examples/ui
|
||||
via the menu items "View" -> "Dark mode".
|
||||
|
||||
2020-05-29 Markus Gans <guru.mail@muenster.de>
|
||||
* Adding a dark theme. Can be activated with the --dark-theme parameter.
|
||||
|
||||
|
|
|
@ -132,6 +132,40 @@ void move (int xold, int yold, int xnew, int ynew)
|
|||
<< std::right << std::setw(10) << byte << "\r\n";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
class DirectLogger : public finalcut::FLog
|
||||
{
|
||||
public:
|
||||
void info (const std::string& entry) override
|
||||
{
|
||||
output << entry << "\r" << std::endl;
|
||||
}
|
||||
|
||||
void warn (const std::string&) override
|
||||
{ }
|
||||
|
||||
void error (const std::string&) override
|
||||
{ }
|
||||
|
||||
void debug (const std::string&) override
|
||||
{ }
|
||||
|
||||
void setOutputStream (const std::ostream& os) override
|
||||
{ output.rdbuf(os.rdbuf()); }
|
||||
|
||||
void setLineEnding (LineEnding) override
|
||||
{ }
|
||||
|
||||
void enableTimestamp() override
|
||||
{ }
|
||||
|
||||
void disableTimestamp() override
|
||||
{ }
|
||||
|
||||
private:
|
||||
// Data member
|
||||
std::ostream output{std::cerr.rdbuf()};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
|
@ -189,7 +223,11 @@ int main (int argc, char* argv[])
|
|||
keyPressed();
|
||||
|
||||
// Show terminal speed and milliseconds for all cursor movement sequence
|
||||
std::cout << "\r" << line;
|
||||
std::cout << "\r" << line << std::flush;
|
||||
// Generation of a logger in a shared_ptr via a pointer
|
||||
finalcut::FApplication::setLog(std::make_shared<DirectLogger>());
|
||||
// Get the shared_ptr with the base class
|
||||
std::shared_ptr<finalcut::FLog> log = finalcut::FApplication::getLog();
|
||||
const finalcut::FOptiMove& opti_move = *finalcut::FTerm::getFOptiMove();
|
||||
finalcut::printDurations(opti_move);
|
||||
|
||||
|
|
|
@ -301,6 +301,7 @@ class MyDialog final : public finalcut::FDialog
|
|||
void cb_copyClipboard (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_pasteClipboard (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_clearInput (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_switchTheme (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_input2buttonText (finalcut::FWidget*, FDataPtr);
|
||||
void cb_setTitlebar (finalcut::FWidget*, const FDataPtr);
|
||||
void cb_showProgressBar (const finalcut::FWidget*, const FDataPtr);
|
||||
|
@ -339,6 +340,8 @@ class MyDialog final : public finalcut::FDialog
|
|||
// "View" menu items
|
||||
finalcut::FMenuItem Env{"&Terminal...", &View};
|
||||
finalcut::FMenuItem Drive{"&Drive symbols...", &View};
|
||||
finalcut::FMenuItem Line3{&View};
|
||||
finalcut::FCheckMenuItem Theme{"Dark &mode", &View};
|
||||
// Statusbar
|
||||
finalcut::FStatusBar Statusbar{this};
|
||||
finalcut::FStatusKey key_F1{fc::Fkey_f1, "About", &Statusbar};
|
||||
|
@ -422,6 +425,10 @@ void MyDialog::initMenu()
|
|||
// "View" menu items
|
||||
Env.setStatusbarMessage ("Informations about this terminal");
|
||||
Drive.setStatusbarMessage ("Show drive symbols");
|
||||
Line3.setSeparator();
|
||||
|
||||
if ( finalcut::FStartOptions::getFStartOptions().dark_theme )
|
||||
Theme.setChecked();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -517,6 +524,12 @@ void MyDialog::initViewMenuCallbacks()
|
|||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &MyDialog::cb_drives)
|
||||
);
|
||||
|
||||
Theme.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &MyDialog::cb_switchTheme)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -902,6 +915,21 @@ void MyDialog::cb_clearInput (const finalcut::FWidget*, const FDataPtr)
|
|||
myLineEdit.redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_switchTheme (const finalcut::FWidget* widget, const FDataPtr)
|
||||
{
|
||||
const auto& check_menu = *(static_cast<const finalcut::FCheckMenuItem*>(widget));
|
||||
|
||||
if ( check_menu.isChecked() )
|
||||
finalcut::FApplication::setDarkTheme();
|
||||
else
|
||||
finalcut::FApplication::setDefaultTheme();
|
||||
|
||||
auto root_widget = getRootWidget();
|
||||
root_widget->resetColors();
|
||||
root_widget->redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_input2buttonText (finalcut::FWidget* widget, FDataPtr data)
|
||||
{
|
||||
|
|
|
@ -282,6 +282,37 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setDefaultTheme()
|
||||
{
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
{
|
||||
if ( getStartOptions().color_change )
|
||||
FTerm::setColorPaletteTheme<default8ColorPalette>(&FTerm::setPalette);
|
||||
|
||||
setColorTheme<default8ColorTheme>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( getStartOptions().color_change )
|
||||
FTerm::setColorPaletteTheme<default16ColorPalette>(&FTerm::setPalette);
|
||||
|
||||
setColorTheme<default16ColorTheme>();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setDarkTheme()
|
||||
{
|
||||
if ( getStartOptions().color_change )
|
||||
FTerm::setColorPaletteTheme<default16DarkColorPalette>(&FTerm::setPalette);
|
||||
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
setColorTheme<default8ColorDarkTheme>();
|
||||
else
|
||||
setColorTheme<default16ColorDarkTheme>();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::showParameterUsage()
|
||||
{
|
||||
|
|
|
@ -127,6 +127,20 @@ void FButton::setInactiveBackgroundColor (FColor color)
|
|||
updateButtonColor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->button_active_fg);
|
||||
setBackgroundColor (wc->button_active_bg);
|
||||
setHotkeyForegroundColor (wc->button_hotkey_fg);
|
||||
setFocusForegroundColor (wc->button_active_focus_fg);
|
||||
setFocusBackgroundColor (wc->button_active_focus_bg);
|
||||
setInactiveForegroundColor (wc->button_inactive_fg);
|
||||
setInactiveBackgroundColor (wc->button_inactive_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FButton::setNoUnderline (bool enable)
|
||||
{
|
||||
|
|
|
@ -383,7 +383,7 @@ void FButtonGroup::draw()
|
|||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
clearArea();
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
|
@ -427,9 +427,6 @@ bool FButtonGroup::isRadioButton (const FToggleButton* button) const
|
|||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::init()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->label_fg);
|
||||
setBackgroundColor (wc->label_bg);
|
||||
setMinimumSize (FSize{7, 3});
|
||||
buttonlist.clear(); // no buttons yet
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ void FCheckBox::draw()
|
|||
void FCheckBox::drawCheckButton()
|
||||
{
|
||||
print() << FPoint{1, 1};
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
|
|
|
@ -177,7 +177,7 @@ void default16DarkColorPalette::setColorPalette()
|
|||
setPalette (fc::Blue, 0x41, 0x58, 0xb3);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0x4e, 0x66, 0x72);
|
||||
setPalette (fc::Red, 0xba, 0x49, 0x49);
|
||||
setPalette (fc::Red, 0xa5, 0x40, 0x40);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xd2, 0xd2, 0xd2);
|
||||
|
|
|
@ -136,6 +136,15 @@ bool FDialog::setBorder (bool enable)
|
|||
return (setFlags().no_border = ! enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FDialog::setResizeable (bool enable)
|
||||
{
|
||||
|
@ -800,9 +809,7 @@ void FDialog::init()
|
|||
addDialog(this);
|
||||
setActiveWindow(this);
|
||||
setTransparentShadow();
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
resetColors();
|
||||
auto old_focus = FWidget::getFocusWidget();
|
||||
|
||||
if ( old_focus )
|
||||
|
|
|
@ -246,20 +246,7 @@ void FLabel::cb_accelWidgetDestroyed (const FWidget*, const FDataPtr)
|
|||
//----------------------------------------------------------------------
|
||||
void FLabel::init()
|
||||
{
|
||||
const auto& parent_widget = getParentWidget();
|
||||
unsetFocusable();
|
||||
|
||||
if ( parent_widget )
|
||||
{
|
||||
setForegroundColor (parent_widget->getForegroundColor());
|
||||
setBackgroundColor (parent_widget->getBackgroundColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -303,6 +290,8 @@ void FLabel::draw()
|
|||
if ( text.isEmpty() )
|
||||
return;
|
||||
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
setReverse(true);
|
||||
|
|
|
@ -99,28 +99,8 @@ const FLineEdit& FLineEdit::operator >> (FString& s)
|
|||
//----------------------------------------------------------------------
|
||||
bool FLineEdit::setEnable (bool enable)
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
FWidget::setEnable(enable);
|
||||
|
||||
if ( enable )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc->inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_fg);
|
||||
setBackgroundColor (wc->inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->inputfield_inactive_fg);
|
||||
setBackgroundColor (wc->inputfield_inactive_bg);
|
||||
}
|
||||
|
||||
resetColors();
|
||||
return enable;
|
||||
}
|
||||
|
||||
|
@ -128,23 +108,7 @@ bool FLineEdit::setEnable (bool enable)
|
|||
bool FLineEdit::setFocus (bool enable)
|
||||
{
|
||||
FWidget::setFocus(enable);
|
||||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( enable )
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc->inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_fg);
|
||||
setBackgroundColor (wc->inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
|
||||
resetColors();
|
||||
return enable;
|
||||
}
|
||||
|
||||
|
@ -255,6 +219,34 @@ void FLineEdit::setLabelOrientation (const label_o o)
|
|||
adjustLabel();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() ) // active
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc->inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_fg);
|
||||
setBackgroundColor (wc->inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc->inputfield_inactive_fg);
|
||||
setBackgroundColor (wc->inputfield_inactive_bg);
|
||||
}
|
||||
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setSize (const FSize& size, bool adjust)
|
||||
{
|
||||
|
@ -655,34 +647,14 @@ void FLineEdit::adjustSize()
|
|||
//----------------------------------------------------------------------
|
||||
void FLineEdit::init()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
label->setAccelWidget(this);
|
||||
setShadow();
|
||||
resetColors();
|
||||
|
||||
if ( isReadOnly() )
|
||||
unsetVisibleCursor();
|
||||
else
|
||||
setVisibleCursor();
|
||||
|
||||
setShadow();
|
||||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc->inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_fg);
|
||||
setBackgroundColor (wc->inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc->inputfield_inactive_fg);
|
||||
setBackgroundColor (wc->inputfield_inactive_bg);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -655,9 +655,6 @@ void FListBox::init()
|
|||
initScrollbar (vbar, fc::vertical, this, &FListBox::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_hbarChange);
|
||||
setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding(1);
|
||||
setLeftPadding(1);
|
||||
|
@ -722,7 +719,8 @@ void FListBox::draw()
|
|||
if ( current < 1 )
|
||||
current = 1;
|
||||
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
|
|
@ -1523,9 +1523,6 @@ void FListView::init()
|
|||
root = selflist.begin();
|
||||
getNullIterator() = selflist.end();
|
||||
setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding(1);
|
||||
setLeftPadding(1);
|
||||
|
@ -1637,7 +1634,7 @@ void FListView::draw()
|
|||
if ( current_iter.getPosition() < 1 )
|
||||
current_iter = itemlist.begin();
|
||||
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
|
|
@ -83,6 +83,15 @@ void FMenu::setStatusbarMessage (const FString& msg)
|
|||
menuitem.setStatusbarMessage(msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::show()
|
||||
{
|
||||
|
@ -458,10 +467,7 @@ void FMenu::init(FWidget* parent)
|
|||
setTransparentShadow();
|
||||
setMenuWidget();
|
||||
hide();
|
||||
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
resetColors();
|
||||
menuitem.setMenu(this);
|
||||
|
||||
if ( parent )
|
||||
|
|
|
@ -55,6 +55,15 @@ FMenuBar::~FMenuBar() // destructor
|
|||
|
||||
|
||||
// public methods of FMenuBar
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::resetMenu()
|
||||
{
|
||||
|
@ -249,9 +258,7 @@ void FMenuBar::init()
|
|||
|
||||
addAccelerator (fc::Fkey_f10);
|
||||
addAccelerator (fc::Fckey_space);
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
resetColors();
|
||||
unsetFocusable();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/foptimove.h"
|
||||
#include "final/ftermcap.h"
|
||||
|
||||
|
@ -1105,42 +1107,43 @@ void FOptiMove::moveByMethod ( int method
|
|||
//----------------------------------------------------------------------
|
||||
void printDurations (const FOptiMove& om)
|
||||
{
|
||||
std::cout << " speed: "
|
||||
<< om.baudrate << " baud\r\n";
|
||||
std::cout << " char_duration: "
|
||||
<< om.char_duration << " ms\r\n";
|
||||
std::cout << " cursor_home: "
|
||||
<< om.F_cursor_home.duration << " ms\r\n";
|
||||
std::cout << " cursor_to_ll: "
|
||||
<< om.F_cursor_to_ll.duration << " ms\r\n";
|
||||
std::cout << " carriage_return: "
|
||||
<< om.F_carriage_return.duration << " ms\r\n";
|
||||
std::cout << " tab: "
|
||||
<< om.F_tab.duration << " ms\r\n";
|
||||
std::cout << " back_tab: "
|
||||
<< om.F_back_tab.duration << " ms\r\n";
|
||||
std::cout << " cursor_up: "
|
||||
<< om.F_cursor_up.duration << " ms\r\n";
|
||||
std::cout << " cursor_down: "
|
||||
<< om.F_cursor_down.duration << " ms\r\n";
|
||||
std::cout << " cursor_left: "
|
||||
<< om.F_cursor_left.duration << " ms\r\n";
|
||||
std::cout << " cursor_right: "
|
||||
<< om.F_cursor_right.duration << " ms\r\n";
|
||||
std::cout << " cursor_address: "
|
||||
<< om.F_cursor_address.duration << " ms\r\n";
|
||||
std::cout << " column_address: "
|
||||
<< om.F_column_address.duration << " ms\r\n";
|
||||
std::cout << " row_address: "
|
||||
<< om.F_row_address.duration << " ms\r\n";
|
||||
std::cout << " parm_up_cursor: "
|
||||
<< om.F_parm_up_cursor.duration << " ms\r\n";
|
||||
std::cout << " parm_down_cursor: "
|
||||
<< om.F_parm_down_cursor.duration << " ms\r\n";
|
||||
std::cout << " parm_left_cursor: "
|
||||
<< om.F_parm_left_cursor.duration << " ms\r\n";
|
||||
std::cout << "parm_right_cursor: "
|
||||
<< om.F_parm_right_cursor.duration << " ms\r\n";
|
||||
finalcut::FLog& log = *FApplication::getLog();
|
||||
log << " speed: "
|
||||
<< om.baudrate << " baud" << std::flush;
|
||||
log << " char_duration: "
|
||||
<< om.char_duration << " ms" << std::flush;
|
||||
log << " cursor_home: "
|
||||
<< om.F_cursor_home.duration << " ms" << std::flush;
|
||||
log << " cursor_to_ll: "
|
||||
<< om.F_cursor_to_ll.duration << " ms" << std::flush;
|
||||
log << " carriage_return: "
|
||||
<< om.F_carriage_return.duration << " ms" << std::flush;
|
||||
log << " tab: "
|
||||
<< om.F_tab.duration << " ms" << std::flush;
|
||||
log << " back_tab: "
|
||||
<< om.F_back_tab.duration << " ms" << std::flush;
|
||||
log << " cursor_up: "
|
||||
<< om.F_cursor_up.duration << " ms" << std::flush;
|
||||
log << " cursor_down: "
|
||||
<< om.F_cursor_down.duration << " ms" << std::flush;
|
||||
log << " cursor_left: "
|
||||
<< om.F_cursor_left.duration << " ms" << std::flush;
|
||||
log << " cursor_right: "
|
||||
<< om.F_cursor_right.duration << " ms" << std::flush;
|
||||
log << " cursor_address: "
|
||||
<< om.F_cursor_address.duration << " ms" << std::flush;
|
||||
log << " column_address: "
|
||||
<< om.F_column_address.duration << " ms" << std::flush;
|
||||
log << " row_address: "
|
||||
<< om.F_row_address.duration << " ms" << std::flush;
|
||||
log << " parm_up_cursor: "
|
||||
<< om.F_parm_up_cursor.duration << " ms" << std::flush;
|
||||
log << " parm_down_cursor: "
|
||||
<< om.F_parm_down_cursor.duration << " ms" << std::flush;
|
||||
log << " parm_left_cursor: "
|
||||
<< om.F_parm_left_cursor.duration << " ms" << std::flush;
|
||||
log << "parm_right_cursor: "
|
||||
<< om.F_parm_right_cursor.duration << " ms" << std::flush;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
|
@ -148,20 +148,10 @@ void FProgressbar::draw()
|
|||
//----------------------------------------------------------------------
|
||||
void FProgressbar::drawProgressLabel()
|
||||
{
|
||||
const auto& parent_widget = getParentWidget();
|
||||
|
||||
if ( parent_widget )
|
||||
setColor ( parent_widget->getForegroundColor()
|
||||
, parent_widget->getBackgroundColor() );
|
||||
else
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->dialog_fg, wc->dialog_bg);
|
||||
}
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
useParentWidgetColor();
|
||||
print() << FPoint{int(getWidth()) - 3, 0};
|
||||
|
||||
if ( percentage > 100 )
|
||||
|
|
|
@ -74,7 +74,7 @@ void FRadioButton::draw()
|
|||
void FRadioButton::drawRadioButton()
|
||||
{
|
||||
print() << FPoint{1, 1};
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
|
|
|
@ -293,6 +293,15 @@ bool FScrollView::setViewportPrint (bool enable)
|
|||
return (use_own_print_area = ! enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FScrollView::setBorder (bool enable)
|
||||
{
|
||||
|
@ -712,9 +721,7 @@ void FScrollView::init (const FWidget* parent)
|
|||
initScrollbar (vbar, fc::vertical, &FScrollView::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_hbarChange);
|
||||
mapKeyFunctions();
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
resetColors();
|
||||
setGeometry (FPoint{1, 1}, FSize{4, 4});
|
||||
setMinimumSize (FSize{4, 4});
|
||||
const int xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||
|
|
|
@ -158,6 +158,15 @@ void FStatusBar::setMessage (const FString& mgs)
|
|||
text.setString(mgs);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStatusBar::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->statusbar_fg);
|
||||
setBackgroundColor (wc->statusbar_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FStatusBar::hasActivatedKey() const
|
||||
{
|
||||
|
@ -513,9 +522,7 @@ void FStatusBar::init()
|
|||
if ( getRootWidget() )
|
||||
getRootWidget()->setBottomPadding(1, true);
|
||||
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->statusbar_fg);
|
||||
setBackgroundColor (wc->statusbar_bg);
|
||||
resetColors();
|
||||
unsetFocusable();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ FStringStream::~FStringStream() // destructor
|
|||
|
||||
// public methods of FStringStream
|
||||
//----------------------------------------------------------------------
|
||||
FStringStream& FStringStream::operator = (FStringStream&& sstream)
|
||||
FStringStream& FStringStream::operator = (FStringStream&& sstream) noexcept
|
||||
{
|
||||
std::wiostream::operator = (std::move(sstream));
|
||||
buffer = std::move(sstream.buffer);
|
||||
|
|
|
@ -1882,13 +1882,13 @@ void FTerm::redefineColorPalette()
|
|||
{
|
||||
// Redefine the color palette
|
||||
|
||||
if ( ! canChangeColorPalette() )
|
||||
if ( ! (canChangeColorPalette() && getStartOptions().color_change) )
|
||||
return;
|
||||
|
||||
resetColorMap();
|
||||
saveColorMap();
|
||||
|
||||
if ( FStartOptions::getFStartOptions().dark_theme )
|
||||
if ( getStartOptions().dark_theme )
|
||||
{
|
||||
setColorPaletteTheme<default16DarkColorPalette>(&FTerm::setPalette);
|
||||
}
|
||||
|
@ -1899,14 +1899,12 @@ void FTerm::redefineColorPalette()
|
|||
else // 8 colors
|
||||
setColorPaletteTheme<default8ColorPalette>(&FTerm::setPalette);
|
||||
}
|
||||
|
||||
getColorPaletteTheme()->setColorPalette();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::restoreColorPalette()
|
||||
{
|
||||
if ( ! canChangeColorPalette() )
|
||||
if ( ! (canChangeColorPalette() && getStartOptions().color_change) )
|
||||
return;
|
||||
|
||||
// Reset screen settings
|
||||
|
@ -2283,7 +2281,6 @@ void FTerm::init (bool disable_alt_screen)
|
|||
initTermspecifics();
|
||||
|
||||
// Redefine the color palette
|
||||
if ( getStartOptions().color_change )
|
||||
redefineColorPalette();
|
||||
|
||||
// Set 220 Hz beep (100 ms)
|
||||
|
@ -2447,7 +2444,6 @@ void FTerm::finish()
|
|||
getFTermXTerminal()->setCursorStyle (fc::steady_block);
|
||||
|
||||
// Restore the color palette
|
||||
if ( getStartOptions().color_change )
|
||||
restoreColorPalette();
|
||||
|
||||
// Switch to normal escape key mode
|
||||
|
|
|
@ -104,6 +104,15 @@ void FTextView::setGeometry ( const FPoint& pos, const FSize& size
|
|||
changeOnResize();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::setText (const FString& str)
|
||||
{
|
||||
|
@ -569,9 +578,7 @@ void FTextView::init()
|
|||
{
|
||||
initScrollbar (vbar, fc::vertical, this, &FTextView::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_hbarChange);
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
resetColors();
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding(1);
|
||||
setLeftPadding(1);
|
||||
|
|
|
@ -111,6 +111,33 @@ void FToggleButton::setGeometry ( const FPoint& pos, const FSize& s
|
|||
FWidget::setGeometry (pos, size, adjust);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToggleButton::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() ) // active
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc->toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->toggle_button_active_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc->label_inactive_fg);
|
||||
setBackgroundColor (wc->label_inactive_bg);
|
||||
}
|
||||
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FToggleButton::setNoUnderline (bool enable)
|
||||
{
|
||||
|
@ -497,26 +524,7 @@ void FToggleButton::setGroup (FButtonGroup* btngroup)
|
|||
void FToggleButton::init()
|
||||
{
|
||||
setGeometry (FPoint{1, 1}, FSize{4, 1}, false); // initialize geometry values
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc->toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->toggle_button_active_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc->label_inactive_fg);
|
||||
setBackgroundColor (wc->label_inactive_bg);
|
||||
}
|
||||
resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -73,6 +73,15 @@ void FToolTip::setText (const FString& txt)
|
|||
calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToolTip::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->tooltip_fg);
|
||||
setBackgroundColor (wc->tooltip_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FToolTip::setBorder (bool enable)
|
||||
{
|
||||
|
@ -107,9 +116,7 @@ void FToolTip::init()
|
|||
// initialize geometry values
|
||||
setGeometry (FPoint{1, 1}, FSize{3, 3}, false);
|
||||
setMinimumSize (FSize{3, 3});
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->tooltip_fg);
|
||||
setBackgroundColor (wc->tooltip_bg);
|
||||
resetColors();
|
||||
calculateDimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -305,6 +305,42 @@ bool FWidget::setFocus (bool enable)
|
|||
return (flags.focus = enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::resetColors()
|
||||
{
|
||||
if ( ! hasChildren() )
|
||||
return;
|
||||
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( child->isWidget() )
|
||||
{
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
widget->resetColors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::useParentWidgetColor()
|
||||
{
|
||||
const auto& parent_widget = getParentWidget();
|
||||
|
||||
if ( parent_widget )
|
||||
{
|
||||
setForegroundColor (parent_widget->getForegroundColor());
|
||||
setBackgroundColor (parent_widget->getBackgroundColor());
|
||||
}
|
||||
else // Fallback
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
}
|
||||
|
||||
setColor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::setColor()
|
||||
{
|
||||
|
|
|
@ -442,9 +442,9 @@ void default16ColorDarkTheme::setColorTheme()
|
|||
titlebar_active_fg = fc::White;
|
||||
titlebar_active_bg = fc::DarkGray;
|
||||
titlebar_inactive_fg = fc::DarkGray;
|
||||
titlebar_inactive_bg = fc::LightGray;
|
||||
titlebar_inactive_bg = fc::LightBlue;
|
||||
titlebar_button_fg = fc::DarkGray;
|
||||
titlebar_button_bg = fc::LightGray;
|
||||
titlebar_button_bg = fc::LightBlue;
|
||||
titlebar_button_focus_fg = fc::LightGray;
|
||||
titlebar_button_focus_bg = fc::Black;
|
||||
menu_active_focus_fg = fc::White;
|
||||
|
|
|
@ -131,6 +131,8 @@ class FApplication : public FWidget
|
|||
bool removeQueuedEvent (const FObject*);
|
||||
virtual void processExternalUserEvent();
|
||||
static FWidget* processParameters (const int&, char*[]);
|
||||
static void setDefaultTheme();
|
||||
static void setDarkTheme();
|
||||
static void showParameterUsage ()
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
__attribute__((noreturn))
|
||||
|
|
|
@ -88,6 +88,7 @@ class FButton : public FWidget
|
|||
void setFocusBackgroundColor (FColor);
|
||||
void setInactiveForegroundColor (FColor);
|
||||
void setInactiveBackgroundColor (FColor);
|
||||
void resetColors();
|
||||
bool setNoUnderline(bool);
|
||||
bool setNoUnderline();
|
||||
bool unsetNoUnderline();
|
||||
|
|
|
@ -108,6 +108,7 @@ class FDialog : public FWindow
|
|||
bool setBorder (bool);
|
||||
bool setBorder();
|
||||
bool unsetBorder();
|
||||
void resetColors();
|
||||
virtual void setText (const FString&);
|
||||
|
||||
// Inquiries
|
||||
|
|
|
@ -120,6 +120,7 @@ class FLineEdit : public FWidget
|
|||
void setInputType (const inputType);
|
||||
void setLabelOrientation (const label_o);
|
||||
void setLabelAssociatedWidget (FWidget*);
|
||||
void resetColors();
|
||||
void setSize (const FSize&, bool = true) override;
|
||||
void setGeometry ( const FPoint&, const FSize&
|
||||
, bool = true ) override;
|
||||
|
|
|
@ -106,6 +106,7 @@ class FMenu : public FWindow, public FMenuList
|
|||
void setStatusbarMessage (const FString&) override;
|
||||
void setMenu (FMenu*);
|
||||
void setText (const FString&);
|
||||
void resetColors();
|
||||
|
||||
// Inquiries
|
||||
bool isSelected() const;
|
||||
|
|
|
@ -86,6 +86,7 @@ class FMenuBar : public FWindow, public FMenuList
|
|||
const FString getClassName() const override;
|
||||
|
||||
// Methods
|
||||
void resetColors();
|
||||
void resetMenu();
|
||||
void hide() override;
|
||||
void adjustSize() override;
|
||||
|
|
|
@ -108,6 +108,7 @@ class FScrollView : public FWidget
|
|||
bool setViewportPrint (bool);
|
||||
bool setViewportPrint();
|
||||
bool unsetViewportPrint();
|
||||
void resetColors();
|
||||
bool setBorder (bool);
|
||||
bool setBorder();
|
||||
bool unsetBorder();
|
||||
|
|
|
@ -205,6 +205,7 @@ class FStatusBar : public FWindow
|
|||
void activateKey (int);
|
||||
void deactivateKey (int);
|
||||
void setMessage (const FString&);
|
||||
void resetColors();
|
||||
|
||||
// Inquiries
|
||||
bool isActivated (int) const;
|
||||
|
|
|
@ -78,7 +78,7 @@ class FStringStream : public std::wiostream
|
|||
FStringStream& operator = (const FStringStream&) = delete;
|
||||
|
||||
// Move assignment operator (=)
|
||||
FStringStream& operator = (FStringStream&& sstream);
|
||||
FStringStream& operator = (FStringStream&& sstream) noexcept;
|
||||
|
||||
virtual const FString getClassName() const;
|
||||
void swap (FStringStream&) noexcept;
|
||||
|
|
|
@ -444,6 +444,7 @@ template<typename ClassT>
|
|||
inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
|
||||
{
|
||||
getColorPaletteTheme() = std::make_shared<ClassT>(f);
|
||||
getColorPaletteTheme()->setColorPalette();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -100,6 +100,7 @@ class FTextView : public FWidget
|
|||
void setSize (const FSize&, bool = true) override;
|
||||
void setGeometry ( const FPoint&, const FSize&
|
||||
, bool = true ) override;
|
||||
void resetColors();
|
||||
void setText (const FString&);
|
||||
void scrollToX (int);
|
||||
void scrollToY (int);
|
||||
|
|
|
@ -86,6 +86,7 @@ class FToggleButton : public FWidget
|
|||
void setSize (const FSize&, bool = true) override;
|
||||
void setGeometry ( const FPoint&, const FSize&
|
||||
, bool = true ) override;
|
||||
void resetColors();
|
||||
bool setNoUnderline (bool);
|
||||
bool setNoUnderline();
|
||||
bool unsetNoUnderline();
|
||||
|
|
|
@ -85,6 +85,7 @@ class FToolTip : public FWindow
|
|||
|
||||
// Mutators
|
||||
void setText (const FString&);
|
||||
void resetColors();
|
||||
bool setBorder (bool);
|
||||
bool setBorder();
|
||||
bool unsetBorder();
|
||||
|
|
|
@ -266,6 +266,8 @@ class FWidget : public FVTerm, public FObject
|
|||
bool acceptPadding();
|
||||
virtual void setForegroundColor (FColor);
|
||||
virtual void setBackgroundColor (FColor);
|
||||
virtual void resetColors();
|
||||
void useParentWidgetColor();
|
||||
void setColor();
|
||||
FWidgetFlags& setFlags();
|
||||
// Positioning and sizes mutators...
|
||||
|
|
Loading…
Reference in New Issue