FButton now uses the widget flags directly

This commit is contained in:
Markus Gans 2018-11-05 23:19:03 +01:00
parent f7a75247ef
commit baabf9546e
12 changed files with 101 additions and 120 deletions

View File

@ -1,3 +1,6 @@
2018-11-05 Markus Gans <guru.mail@muenster.de>
* FButton now uses the widget flags directly
2018-11-04 Markus Gans <guru.mail@muenster.de> 2018-11-04 Markus Gans <guru.mail@muenster.de>
* Widget flags are now stored in a bit field * Widget flags are now stored in a bit field

View File

@ -285,7 +285,7 @@ Window::Window (finalcut::FWidget* parent)
for (int n = 1; n <= 6; n++) for (int n = 1; n <= 6; n++)
{ {
win_data* win_dat = new win_data; win_data* win_dat = new win_data;
win_dat->title.sprintf("Window %d", n); win_dat->title.sprintf("Window %1d", n);
windows.push_back(win_dat); windows.push_back(win_dat);
} }
} }

View File

@ -37,6 +37,7 @@ FButton::FButton(FWidget* parent)
: FWidget(parent) : FWidget(parent)
, text() , text()
, button_down(false) , button_down(false)
, active_focus(false)
, click_animation(true) , click_animation(true)
, click_time(150) , click_time(150)
, space_char(int(' ')) , space_char(int(' '))
@ -52,7 +53,6 @@ FButton::FButton(FWidget* parent)
, button_focus_bg(wc.button_active_focus_bg) , button_focus_bg(wc.button_active_focus_bg)
, button_inactive_fg(wc.button_inactive_fg) , button_inactive_fg(wc.button_inactive_fg)
, button_inactive_bg(wc.button_inactive_bg) , button_inactive_bg(wc.button_inactive_bg)
, is()
{ {
init(); init();
} }
@ -62,6 +62,7 @@ FButton::FButton (const FString& txt, FWidget* parent)
: FWidget(parent) : FWidget(parent)
, text(txt) , text(txt)
, button_down(false) , button_down(false)
, active_focus(false)
, click_animation(true) , click_animation(true)
, click_time(150) , click_time(150)
, space_char(int(' ')) , space_char(int(' '))
@ -77,7 +78,6 @@ FButton::FButton (const FString& txt, FWidget* parent)
, button_focus_bg(wc.button_active_focus_bg) , button_focus_bg(wc.button_active_focus_bg)
, button_inactive_fg(wc.button_inactive_fg) , button_inactive_fg(wc.button_inactive_fg)
, button_inactive_bg(wc.button_inactive_bg) , button_inactive_bg(wc.button_inactive_bg)
, is()
{ {
init(); init();
detectHotkey(); detectHotkey();
@ -453,17 +453,6 @@ void FButton::init()
setShadow(); setShadow();
} }
//----------------------------------------------------------------------
void FButton::getButtonState()
{
is.active_focus = flags.active && flags.focus;
is.active = flags.active;
is.focus = flags.focus;
is.flat = isFlat();
is.non_flat_shadow = ! flags.flat && flags.shadow;
is.no_underline = flags.no_underline;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uChar FButton::getHotkey() uChar FButton::getHotkey()
{ {
@ -551,7 +540,7 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
return 0; return 0;
// noshadow + indent one character to the right // noshadow + indent one character to the right
if ( is.flat ) if ( flags.flat )
clearFlatBorder(); clearFlatBorder();
else if ( hasShadow() ) else if ( hasShadow() )
clearShadow(); clearShadow();
@ -588,7 +577,7 @@ inline void FButton::clearRightMargin (FWidget* parent_widget)
setPrintPos (1 + int(getWidth()), y); setPrintPos (1 + int(getWidth()), y);
print (' '); // clear right print (' '); // clear right
if ( is.active && isMonochron() ) if ( flags.active && isMonochron() )
setReverse(false); // Dark background setReverse(false); // Dark background
} }
} }
@ -604,7 +593,7 @@ inline void FButton::drawMarginLeft()
{ {
setPrintPos (1 + int(indent), 1 + int(y)); setPrintPos (1 + int(indent), 1 + int(y));
if ( isMonochron() && is.active_focus && y == vcenter_offset ) if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackRightPointingPointer); // ► print (fc::BlackRightPointingPointer); // ►
else else
print (space_char); // full block █ print (space_char); // full block █
@ -620,7 +609,7 @@ inline void FButton::drawMarginRight()
{ {
setPrintPos (int(getWidth() + indent), 1 + int(y)); setPrintPos (int(getWidth() + indent), 1 + int(y));
if ( isMonochron() && is.active_focus && y == vcenter_offset ) if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackLeftPointingPointer); // ◄ print (fc::BlackLeftPointingPointer); // ◄
else else
print (space_char); // full block █ print (space_char); // full block █
@ -675,32 +664,32 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
setCursorPos ( 2 + int(center_offset + hotkeypos) setCursorPos ( 2 + int(center_offset + hotkeypos)
, 1 + int(vcenter_offset) ); // hotkey , 1 + int(vcenter_offset) ); // hotkey
if ( ! is.active && isMonochron() ) if ( ! flags.active && isMonochron() )
setReverse(true); // Light background setReverse(true); // Light background
if ( is.active_focus && (isMonochron() || getMaxColor() < 16) ) if ( active_focus && (isMonochron() || getMaxColor() < 16) )
setBold(); setBold();
for ( std::size_t z = 0 for ( std::size_t z = 0
; pos < center_offset + txtlength && z < getWidth() - 2 ; pos < center_offset + txtlength && z < getWidth() - 2
; z++, pos++) ; z++, pos++)
{ {
if ( z == hotkeypos && is.active ) if ( z == hotkeypos && flags.active )
{ {
setColor (button_hotkey_fg, button_bg); setColor (button_hotkey_fg, button_bg);
if ( ! is.active_focus && getMaxColor() < 16 ) if ( ! active_focus && getMaxColor() < 16 )
setBold(); setBold();
if ( ! is.no_underline ) if ( ! flags.no_underline )
setUnderline(); setUnderline();
print (button_text[z]); print (button_text[z]);
if ( ! is.active_focus && getMaxColor() < 16 ) if ( ! active_focus && getMaxColor() < 16 )
unsetBold(); unsetBold();
if ( ! is.no_underline ) if ( ! flags.no_underline )
unsetUnderline(); unsetUnderline();
setColor (button_fg, button_bg); setColor (button_fg, button_bg);
@ -718,7 +707,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
print (L".."); print (L"..");
} }
if ( is.active_focus && (isMonochron() || getMaxColor() < 16) ) if ( active_focus && (isMonochron() || getMaxColor() < 16) )
unsetBold(); unsetBold();
for (pos = center_offset + txtlength; pos < getWidth() - 2; pos++) for (pos = center_offset + txtlength; pos < getWidth() - 2; pos++)
@ -732,7 +721,7 @@ void FButton::draw()
FWidget* parent_widget = getParentWidget(); FWidget* parent_widget = getParentWidget();
txtlength = text.getLength(); txtlength = text.getLength();
space_char = int(' '); space_char = int(' ');
getButtonState(); active_focus = flags.active && flags.focus;
try try
{ {
@ -753,13 +742,13 @@ void FButton::draw()
// Clear right margin after animation // Clear right margin after animation
clearRightMargin (parent_widget); clearRightMargin (parent_widget);
if ( ! is.active && isMonochron() ) if ( ! flags.active && isMonochron() )
space_char = fc::MediumShade; // ▒ simulates greyed out at Monochron space_char = fc::MediumShade; // ▒ simulates greyed out at Monochron
if ( isMonochron() && (is.active || is.focus) ) if ( isMonochron() && (flags.active || flags.focus) )
setReverse(false); // Dark background setReverse(false); // Dark background
if ( is.flat && ! button_down ) if ( flags.flat && ! button_down )
drawFlatBorder(); drawFlatBorder();
hotkeypos = getHotkeyPos(text.wc_str(), button_text, uInt(txtlength)); hotkeypos = getHotkeyPos(text.wc_str(), button_text, uInt(txtlength));
@ -785,7 +774,7 @@ void FButton::draw()
drawTopBottomBackground(); drawTopBottomBackground();
// Draw button shadow // Draw button shadow
if ( is.non_flat_shadow && ! button_down ) if ( ! flags.flat && flags.shadow && ! button_down )
drawShadow(); drawShadow();
if ( isMonochron() ) if ( isMonochron() )
@ -798,7 +787,7 @@ void FButton::draw()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::updateStatusBar() void FButton::updateStatusBar()
{ {
if ( ! is.focus || ! getStatusBar() ) if ( ! flags.focus || ! getStatusBar() )
return; return;
const FString& msg = getStatusbarMessage(); const FString& msg = getStatusbarMessage();

View File

@ -288,13 +288,13 @@ void FScrollView::setPrintPos (int x, int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FScrollView::setViewportPrint (bool on) bool FScrollView::setViewportPrint (bool on)
{ {
return use_own_print_area = ! on; return (use_own_print_area = ! on);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FScrollView::setBorder (bool on) bool FScrollView::setBorder (bool on)
{ {
return border = on; return (border = on);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -99,7 +99,7 @@ bool FStatusKey::setMouseFocus(bool on)
if ( on == mouse_focus ) if ( on == mouse_focus )
return true; return true;
return mouse_focus = on; return (mouse_focus = on);
} }

View File

@ -858,7 +858,7 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
int xpos = x + tx; int xpos = x + tx;
tc = &vterm->text[ypos * vterm->width + xpos]; tc = &vterm->text[ypos * vterm->width + xpos];
sc = generateCharacter(xpos, ypos); sc = generateCharacter(xpos, ypos);
std::memcpy (tc, &sc, sizeof(charData)); std::memcpy (tc, &sc, sizeof(sc));
} }
if ( short(vterm->changes[ypos].xmin) > x ) if ( short(vterm->changes[ypos].xmin) > x )
@ -959,7 +959,7 @@ void FVTerm::updateOverlappedColor ( term_area* area
charData* tc = &vterm->text[ty * vterm->width + tx]; charData* tc = &vterm->text[ty * vterm->width + tx];
// New character // New character
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(charData)); std::memcpy (&nc, ac, sizeof(*ac));
// Overlapped character // Overlapped character
charData oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget); charData oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget);
nc.fg_color = oc.fg_color; nc.fg_color = oc.fg_color;
@ -976,7 +976,7 @@ void FVTerm::updateOverlappedColor ( term_area* area
nc.code = ' '; nc.code = ' ';
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc); nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(charData)); std::memcpy (tc, &nc, sizeof(nc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -989,7 +989,7 @@ void FVTerm::updateOverlappedCharacter (term_area* area, int tx, int ty)
// Overlapped character // Overlapped character
charData oc = getCoveredCharacter (tx + 1, ty + 1, area->widget); charData oc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc); oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(charData)); std::memcpy (tc, &oc, sizeof(oc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1021,7 +1021,7 @@ void FVTerm::updateShadedCharacter ( term_area* area
oc.code = ' '; oc.code = ' ';
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc); oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(charData)); std::memcpy (tc, &oc, sizeof(oc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1039,12 +1039,12 @@ void FVTerm::updateInheritBackground ( term_area* area
charData* tc = &vterm->text[ty * vterm->width + tx]; charData* tc = &vterm->text[ty * vterm->width + tx];
// New character // New character
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(charData)); std::memcpy (&nc, ac, sizeof(*ac));
// Covered character // Covered character
charData cc = getCoveredCharacter (tx + 1, ty + 1, area->widget); charData cc = getCoveredCharacter (tx + 1, ty + 1, area->widget);
nc.bg_color = cc.bg_color; nc.bg_color = cc.bg_color;
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc); nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(charData)); std::memcpy (tc, &nc, sizeof(nc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1060,7 +1060,7 @@ void FVTerm::updateCharacter ( term_area* area
charData* ac = &area->text[y * line_len + x]; charData* ac = &area->text[y * line_len + x];
// Terminal character // Terminal character
charData* tc = &vterm->text[ty * vterm->width + tx]; charData* tc = &vterm->text[ty * vterm->width + tx];
std::memcpy (tc, ac, sizeof(charData)); std::memcpy (tc, ac, sizeof(*ac));
if ( tc->attr.bit.printed && *tc == *ac ) if ( tc->attr.bit.printed && *tc == *ac )
tc->attr.bit.no_changes = true; tc->attr.bit.no_changes = true;
@ -1388,7 +1388,7 @@ void FVTerm::getArea (int ax, int ay, term_area* area)
charData* ac; // area character charData* ac; // area character
tc = &vterm->text[(ay + y) * vterm->width + ax]; tc = &vterm->text[(ay + y) * vterm->width + ax];
ac = &area->text[y * area->width]; ac = &area->text[y * area->width];
std::memcpy (ac, tc, sizeof(charData) * unsigned(length)); std::memcpy (ac, tc, sizeof(*tc) * unsigned(length));
if ( short(area->changes[y].xmin) > 0 ) if ( short(area->changes[y].xmin) > 0 )
area->changes[y].xmin = 0; area->changes[y].xmin = 0;
@ -1444,7 +1444,7 @@ void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
tc = &vterm->text[(y + _y - 1) * vterm->width + x - 1]; tc = &vterm->text[(y + _y - 1) * vterm->width + x - 1];
ac = &area->text[(dy + _y) * line_len + dx]; ac = &area->text[(dy + _y) * line_len + dx];
std::memcpy (ac, tc, sizeof(charData) * unsigned(length)); std::memcpy (ac, tc, sizeof(*tc) * unsigned(length));
if ( short(area->changes[dy + _y].xmin) > dx ) if ( short(area->changes[dy + _y].xmin) > dx )
area->changes[dy + _y].xmin = uInt(dx); area->changes[dy + _y].xmin = uInt(dx);
@ -1572,14 +1572,14 @@ void FVTerm::scrollAreaForward (term_area* area)
int pos2 = (y + 1) * total_width; int pos2 = (y + 1) * total_width;
sc = &area->text[pos2]; sc = &area->text[pos2];
dc = &area->text[pos1]; dc = &area->text[pos1];
std::memcpy (dc, sc, sizeof(charData) * unsigned(length)); std::memcpy (dc, sc, sizeof(*sc) * unsigned(length));
area->changes[y].xmin = 0; area->changes[y].xmin = 0;
area->changes[y].xmax = uInt(area->width - 1); area->changes[y].xmax = uInt(area->width - 1);
} }
// insert a new line below // insert a new line below
lc = &area->text[(y_max * total_width) - area->right_shadow - 1]; lc = &area->text[(y_max * total_width) - area->right_shadow - 1];
std::memcpy (&nc, lc, sizeof(charData)); std::memcpy (&nc, lc, sizeof(*lc));
nc.code = ' '; nc.code = ' ';
dc = &area->text[y_max * total_width]; dc = &area->text[y_max * total_width];
std::fill_n (dc, area->width, nc); std::fill_n (dc, area->width, nc);
@ -1633,14 +1633,14 @@ void FVTerm::scrollAreaReverse (term_area* area)
int pos2 = y * total_width; int pos2 = y * total_width;
sc = &area->text[pos1]; sc = &area->text[pos1];
dc = &area->text[pos2]; dc = &area->text[pos2];
std::memcpy (dc, sc, sizeof(charData) * unsigned(length)); std::memcpy (dc, sc, sizeof(*sc) * unsigned(length));
area->changes[y].xmin = 0; area->changes[y].xmin = 0;
area->changes[y].xmax = uInt(area->width - 1); area->changes[y].xmax = uInt(area->width - 1);
} }
// insert a new line above // insert a new line above
lc = &area->text[total_width]; lc = &area->text[total_width];
std::memcpy (&nc, lc, sizeof(charData)); std::memcpy (&nc, lc, sizeof(*lc));
nc.code = ' '; nc.code = ' ';
dc = &area->text[0]; dc = &area->text[0];
std::fill_n (dc, area->width, nc); std::fill_n (dc, area->width, nc);
@ -1675,7 +1675,7 @@ void FVTerm::clearArea (term_area* area, int fillchar)
uInt w; uInt w;
// Current attributes with a space character // Current attributes with a space character
std::memcpy (&nc, &next_attribute, sizeof(charData)); std::memcpy (&nc, &next_attribute, sizeof(next_attribute));
nc.code = fillchar; nc.code = fillchar;
if ( ! (area && area->text) ) if ( ! (area && area->text) )
@ -1770,7 +1770,7 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
if ( tmp->attr.bit.trans_shadow ) // Transparent shadow if ( tmp->attr.bit.trans_shadow ) // Transparent shadow
{ {
// Keep the current vterm character // Keep the current vterm character
std::memcpy (&s_ch, sc, sizeof(charData)); std::memcpy (&s_ch, sc, sizeof(*sc));
s_ch.fg_color = tmp->fg_color; s_ch.fg_color = tmp->fg_color;
s_ch.bg_color = tmp->bg_color; s_ch.bg_color = tmp->bg_color;
s_ch.attr.bit.reverse = false; s_ch.attr.bit.reverse = false;
@ -1789,7 +1789,7 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
else if ( tmp->attr.bit.inherit_bg ) else if ( tmp->attr.bit.inherit_bg )
{ {
// Add the covered background to this character // Add the covered background to this character
std::memcpy (&i_ch, tmp, sizeof(charData)); std::memcpy (&i_ch, tmp, sizeof(*tmp));
i_ch.bg_color = sc->bg_color; // Last background color i_ch.bg_color = sc->bg_color; // Last background color
sc = &i_ch; sc = &i_ch;
} }
@ -2007,7 +2007,7 @@ void FVTerm::init (bool disable_alt_screen)
term_attribute.attr.byte[0] = 0; term_attribute.attr.byte[0] = 0;
// next_attribute contains the state of the next printed character // next_attribute contains the state of the next printed character
std::memcpy (&next_attribute, &term_attribute, sizeof(charData)); std::memcpy (&next_attribute, &term_attribute, sizeof(term_attribute));
// Receive the terminal capabilities // Receive the terminal capabilities
tcap = FTermcap::getTermcapMap(); tcap = FTermcap::getTermcapMap();
@ -2086,7 +2086,7 @@ void FVTerm::putAreaLine (charData* ac, charData* tc, int length)
{ {
// copy "length" characters from area to terminal // copy "length" characters from area to terminal
std::memcpy (tc, ac, sizeof(charData) * unsigned(length)); std::memcpy (tc, ac, sizeof(*ac) * unsigned(length));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2099,7 +2099,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
// Restore one character on vterm // Restore one character on vterm
charData ch; charData ch;
ch = getCoveredCharacter (x, y, obj); ch = getCoveredCharacter (x, y, obj);
std::memcpy (tc, &ch, sizeof(charData)); std::memcpy (tc, &ch, sizeof(ch));
} }
else // Mot transparent else // Mot transparent
{ {
@ -2121,19 +2121,19 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
|| ch.code == fc::FullBlock ) || ch.code == fc::FullBlock )
ch.code = ' '; ch.code = ' ';
std::memcpy (tc, &ch, sizeof(charData)); std::memcpy (tc, &ch, sizeof(ch));
} }
else if ( ac->attr.bit.inherit_bg ) else if ( ac->attr.bit.inherit_bg )
{ {
// Add the covered background to this character // Add the covered background to this character
charData ch, cc; charData ch, cc;
std::memcpy (&ch, ac, sizeof(charData)); std::memcpy (&ch, ac, sizeof(*ac));
cc = getCoveredCharacter (x, y, obj); cc = getCoveredCharacter (x, y, obj);
ch.bg_color = cc.bg_color; ch.bg_color = cc.bg_color;
std::memcpy (tc, &ch, sizeof(charData)); std::memcpy (tc, &ch, sizeof(ch));
} }
else // Default else // Default
std::memcpy (tc, ac, sizeof(charData)); std::memcpy (tc, ac, sizeof(*ac));
} }
} }
@ -2153,7 +2153,7 @@ void FVTerm::getAreaCharacter ( int x, int y, term_area* area
if ( tmp->attr.bit.trans_shadow ) // transparent shadow if ( tmp->attr.bit.trans_shadow ) // transparent shadow
{ {
// Keep the current vterm character // Keep the current vterm character
std::memcpy (&s_ch, cc, sizeof(charData)); std::memcpy (&s_ch, cc, sizeof(*cc));
s_ch.fg_color = tmp->fg_color; s_ch.fg_color = tmp->fg_color;
s_ch.bg_color = tmp->bg_color; s_ch.bg_color = tmp->bg_color;
s_ch.attr.bit.reverse = false; s_ch.attr.bit.reverse = false;
@ -2163,7 +2163,7 @@ void FVTerm::getAreaCharacter ( int x, int y, term_area* area
else if ( tmp->attr.bit.inherit_bg ) else if ( tmp->attr.bit.inherit_bg )
{ {
// Add the covered background to this character // Add the covered background to this character
std::memcpy (&i_ch, tmp, sizeof(charData)); std::memcpy (&i_ch, tmp, sizeof(*tmp));
i_ch.bg_color = cc->bg_color; // last background color i_ch.bg_color = cc->bg_color; // last background color
cc = &i_ch; cc = &i_ch;
} }

View File

@ -61,10 +61,6 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
, flags() , flags()
, callback_objects() , callback_objects()
, member_callback_objects() , member_callback_objects()
, visible(true)
, shown(false)
, focusable(true)
, visible_cursor(true)
, widget_cursor_position(-1, -1) , widget_cursor_position(-1, -1)
, size_hints() , size_hints()
, double_flatline_mask() , double_flatline_mask()
@ -85,10 +81,11 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
// init bit field with 0 // init bit field with 0
memset (&flags, 0, sizeof(flags)); memset (&flags, 0, sizeof(flags));
// Enable widget by default flags.active = true; // Enable widget by default
flags.active = true; flags.visible = true; // A widget is visible by default
flags.focusable = true; // A widget is focusable by default
widget_object = true; flags.visible_cursor = true; // A widget has a visible cursor by default
widget_object = true; // This FObject is a widget
if ( ! parent ) if ( ! parent )
{ {
@ -104,7 +101,7 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
} }
else else
{ {
visible_cursor = ! hideable; flags.visible_cursor = ! hideable;
offset = parent->client_offset; offset = parent->client_offset;
double_flatline_mask.top.resize (getWidth(), false); double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false); double_flatline_mask.right.resize (getHeight(), false);
@ -671,7 +668,7 @@ bool FWidget::setCursorPos (int x, int y)
setAreaCursor ( widget_offsetX + x setAreaCursor ( widget_offsetX + x
, widget_offsetY + y , widget_offsetY + y
, visible_cursor , flags.visible_cursor
, area ); , area );
return true; return true;
} }
@ -1092,7 +1089,7 @@ void FWidget::show()
} }
draw(); draw();
shown = true; flags.shown = true;
if ( hasChildren() ) if ( hasChildren() )
{ {
@ -1129,8 +1126,8 @@ void FWidget::hide()
{ {
if ( isVisible() ) if ( isVisible() )
{ {
visible = false; flags.visible = false;
shown = false; flags.shown = false;
if ( ! isDialogWidget() if ( ! isDialogWidget()
&& FWidget::getFocusWidget() == this && FWidget::getFocusWidget() == this
@ -1966,7 +1963,7 @@ void FWidget::init()
} }
hideable = isCursorHideable(); hideable = isCursorHideable();
visible_cursor = ! hideable; flags.visible_cursor = ! hideable;
// Determine width and height of the terminal // Determine width and height of the terminal
detectTermSize(); detectTermSize();

View File

@ -162,7 +162,7 @@ bool FWindow::activateWindow (bool on)
active_area = getVWin(); active_area = getVWin();
} }
return window_active = on; return (window_active = on);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -141,7 +141,6 @@ class FButton : public FWidget
// Methods // Methods
void init(); void init();
void getButtonState();
uChar getHotkey(); uChar getHotkey();
void setHotkeyAccelerator(); void setHotkeyAccelerator();
void detectHotkey(); void detectHotkey();
@ -160,6 +159,7 @@ class FButton : public FWidget
// Data Members // Data Members
FString text; FString text;
bool button_down; bool button_down;
bool active_focus;
bool click_animation; bool click_animation;
int click_time; int click_time;
int space_char; int space_char;
@ -175,17 +175,6 @@ class FButton : public FWidget
short button_focus_bg; short button_focus_bg;
short button_inactive_fg; short button_inactive_fg;
short button_inactive_bg; short button_inactive_bg;
struct state
{
uChar focus : 1;
uChar active_focus : 1;
uChar active : 1;
uChar flat : 1;
uChar non_flat_shadow : 1;
uChar no_underline : 1;
uChar : 2; // padding bits
} is;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -253,7 +242,7 @@ inline bool FButton::setUp()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FButton::setClickAnimation(bool on) inline bool FButton::setClickAnimation(bool on)
{ return click_animation = on; } { return (click_animation = on); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FButton::setClickAnimation() inline bool FButton::setClickAnimation()

View File

@ -479,7 +479,7 @@ inline void FListView::setUserDescendingCompare (Compare cmp)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListView::setTreeView (bool on) inline bool FListView::setTreeView (bool on)
{ return tree_view = on; } { return (tree_view = on); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FListView::setTreeView() inline bool FListView::setTreeView()

View File

@ -197,7 +197,7 @@ inline void FMessageBox::setTitlebarText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMessageBox::setCenterText(bool on) inline bool FMessageBox::setCenterText(bool on)
{ return center_text = on; } { return (center_text = on); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMessageBox::setCenterText() inline bool FMessageBox::setCenterText()

View File

@ -144,20 +144,24 @@ class FWidget : public FVTerm, public FObject
struct widget_flags // Properties of a widget ⚑ struct widget_flags // Properties of a widget ⚑
{ {
uInt32 shadow : 1; uInt32 shadow : 1;
uInt32 trans_shadow : 1; uInt32 trans_shadow : 1;
uInt32 active : 1; uInt32 active : 1;
uInt32 focus : 1; uInt32 visible : 1;
uInt32 scrollable : 1; uInt32 shown : 1;
uInt32 resizeable : 1; uInt32 focus : 1;
uInt32 modal : 1; uInt32 focusable : 1;
uInt32 window_widget : 1; uInt32 scrollable : 1;
uInt32 dialog_widget : 1; uInt32 resizeable : 1;
uInt32 menu_widget : 1; uInt32 modal : 1;
uInt32 always_on_top : 1; uInt32 visible_cursor : 1;
uInt32 flat : 1; uInt32 window_widget : 1;
uInt32 no_underline : 1; uInt32 dialog_widget : 1;
uInt32 : 19; // padding bits uInt32 menu_widget : 1;
uInt32 always_on_top : 1;
uInt32 flat : 1;
uInt32 no_underline : 1;
uInt32 : 15; // padding bits
}; };
// Constructor // Constructor
@ -425,10 +429,6 @@ class FWidget : public FVTerm, public FObject
static void setColorTheme(); static void setColorTheme();
// Data Members // Data Members
bool visible;
bool shown;
bool focusable;
bool visible_cursor;
FPoint widget_cursor_position; FPoint widget_cursor_position;
struct widget_size_hints struct widget_size_hints
@ -734,7 +734,7 @@ inline void FWidget::setStatusbarMessage (const FString& msg)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setVisible() inline bool FWidget::setVisible()
{ return visible = true; } { return (flags.visible = true); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setEnable() inline bool FWidget::setEnable()
@ -750,7 +750,10 @@ inline bool FWidget::setDisable()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setVisibleCursor (bool on) inline bool FWidget::setVisibleCursor (bool on)
{ return visible_cursor = ( on ) ? true : (( hideable ) ? false : true); } {
flags.visible_cursor = ( on ) ? true : (( hideable ) ? false : true);
return flags.visible_cursor;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setVisibleCursor() inline bool FWidget::setVisibleCursor()
@ -770,23 +773,23 @@ inline bool FWidget::unsetFocus()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setFocusable() inline void FWidget::setFocusable()
{ focusable = true; } { flags.focusable = true; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::unsetFocusable() inline void FWidget::unsetFocusable()
{ focusable = false; } { flags.focusable = false; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::ignorePadding (bool on) inline bool FWidget::ignorePadding (bool on)
{ return ignore_padding = on; } { return (ignore_padding = on); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::ignorePadding() inline bool FWidget::ignorePadding()
{ return ignore_padding = true; } { return (ignore_padding = true); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::acceptPadding() inline bool FWidget::acceptPadding()
{ return ignore_padding = false; } { return (ignore_padding = false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FWidget::setForegroundColor (short color) inline void FWidget::setForegroundColor (short color)
@ -881,11 +884,11 @@ inline bool FWidget::isRootWidget() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::isVisible() const inline bool FWidget::isVisible() const
{ return visible; } { return flags.visible; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::isShown() const inline bool FWidget::isShown() const
{ return shown; } { return flags.shown; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::isWindowWidget() const inline bool FWidget::isWindowWidget() const
@ -905,7 +908,7 @@ inline bool FWidget::isEnabled() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::hasVisibleCursor() const inline bool FWidget::hasVisibleCursor() const
{ return visible_cursor; } { return flags.visible_cursor; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::hasFocus() const inline bool FWidget::hasFocus() const
@ -913,7 +916,7 @@ inline bool FWidget::hasFocus() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::acceptFocus() const // is focusable inline bool FWidget::acceptFocus() const // is focusable
{ return focusable; } { return flags.focusable; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::isPaddingIgnored() inline bool FWidget::isPaddingIgnored()