added a separate flag for mouse focus

This commit is contained in:
thrust26 2020-11-16 18:59:01 +01:00
parent aa51e29b38
commit e288350fdf
23 changed files with 24 additions and 192 deletions

View File

@ -240,20 +240,6 @@ void DataGridWidget::setRange(int lower, int upper)
_upperBound = std::min(1 << _bits, upper);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DataGridWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{

View File

@ -101,8 +101,6 @@ class DataGridWidget : public EditableWidget
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
bool handleText(char text) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override;
bool handleKeyUp(StellaKey key, StellaMod mod) override;

View File

@ -284,20 +284,6 @@ void RomListWidget::handleMouseWheel(int x, int y, int direction)
myScrollBar->handleMouseWheel(x, y, direction);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomListWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RomListWidget::handleText(char text)
{

View File

@ -60,8 +60,6 @@ class RomListWidget : public EditableWidget
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
bool handleText(char text) override;
bool handleKeyDown(StellaKey key, StellaMod mod) override;
bool handleKeyUp(StellaKey key, StellaMod mod) override;

View File

@ -178,19 +178,11 @@ void TiaZoomWidget::handleMouseMoved(int x, int y)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
myMouseMoving = false;
Widget::handleMouseLeft();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,9 +34,6 @@ class TiaZoomWidget : public Widget, public CommandSender
void loadConfig() override;
void setPos(int x, int y);
protected:
void handleMouseEntered() override;
private:
void zoom(int level);
void recalc();

View File

@ -40,20 +40,6 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font,
Widget::FLAG_WANTS_RAWDATA;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ToggleWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ToggleWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ToggleWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{

View File

@ -68,8 +68,6 @@ class ToggleWidget : public Widget, public CommandSender
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
bool handleKeyDown(StellaKey key, StellaMod mod) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -46,20 +46,6 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckListWidget::handleMouseEntered()
{
setFlags(Widget::FLAG_HILITED);
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckListWidget::handleMouseLeft()
{
clearFlags(Widget::FLAG_HILITED);
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckListWidget::setList(const StringList& list, const BoolArray& state)
{

View File

@ -42,10 +42,6 @@ class CheckListWidget : public ListWidget
bool getState(int line);
bool getSelectedState() { return getState(_selectedItem); }
protected:
void handleMouseEntered() override;
void handleMouseLeft() override;
private:
bool handleEvent(Event::Type e) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -49,20 +49,6 @@ void EditTextWidget::setText(const string& str, bool changed)
_changed = changed;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditTextWidget::handleMouseEntered()
{
if(isEnabled() && isEditable())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditTextWidget::handleMouseLeft()
{
if(isEnabled() && isEditable())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EditTextWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
{

View File

@ -54,8 +54,6 @@ class EditTextWidget : public EditableWidget
Common::Rect getEditRect() const override;
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
protected:
string _backupString;

View File

@ -52,7 +52,8 @@ class GuiObject : public CommandReceiver
FLAG_RETAIN_FOCUS = 1 << 6,
FLAG_WANTS_TAB = 1 << 7,
FLAG_WANTS_RAWDATA = 1 << 8,
FLAG_NOBG = 1 << 9
FLAG_NOBG = 1 << 9,
FLAG_MOUSE_FOCUS = 1 << 10
};
public:

View File

@ -158,20 +158,6 @@ void PopUpWidget::handleMouseWheel(int x, int y, int direction)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PopUpWidget::handleEvent(Event::Type e)
{

View File

@ -70,8 +70,6 @@ class PopUpWidget : public EditableWidget
protected:
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseWheel(int x, int y, int direction) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
bool handleEvent(Event::Type e) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;

View File

@ -240,19 +240,11 @@ void ScrollBarWidget::checkBounds(int old_pos)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ScrollBarWidget::handleMouseLeft()
{
_part = Part::None;
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
Widget::handleMouseLeft();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -49,7 +49,6 @@ class ScrollBarWidget : public Widget, public CommandSender
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseMoved(int x, int y) override;
bool handleMouseClicks(int x, int y, MouseButton b) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
void setArrows();

View File

@ -50,20 +50,6 @@ void StringListWidget::setList(const StringList& list)
ListWidget::recalc();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StringListWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StringListWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StringListWidget::drawWidget(bool hilite)
{

View File

@ -33,8 +33,6 @@ class StringListWidget : public ListWidget
bool wantsFocus() const override { return true; }
protected:
void handleMouseEntered() override;
void handleMouseLeft() override;
// display depends on _hasFocus so we have to redraw when focus changes
void receivedFocusWidget() override { setDirty(); }
void lostFocusWidget() override { setDirty(); }

View File

@ -213,20 +213,6 @@ void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::handleMouseEntered()
{
//if(isEnabled())
// setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::handleMouseLeft()
{
//if(isEnabled())
// clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{

View File

@ -63,8 +63,8 @@ class TabWidget : public Widget, public CommandSender
protected:
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
void handleMouseEntered() override {}
void handleMouseLeft() override {}
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
bool handleEvent(Event::Type event) override;

View File

@ -75,12 +75,8 @@ void Widget::tick()
{
if(isEnabled())
{
if(isHighlighted() && hasToolTip())
if(hasMouseFocus() && hasToolTip())
dialog().tooltip().request(this);
//{
// if(dialog().enableToolTip())
// dialog().showToolTip(10, 10);
//}
// Recursively tick widget and all child dialogs and widgets
Widget* w = _firstWidget;
@ -181,6 +177,20 @@ void Widget::drawChain()
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED | Widget::FLAG_MOUSE_FOCUS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED | Widget::FLAG_MOUSE_FOCUS);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Widget::receivedFocus()
{
@ -465,20 +475,6 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
_bmh = bmh;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool ButtonWidget::handleEvent(Event::Type e)
{
@ -576,20 +572,6 @@ CheckboxWidget::CheckboxWidget(GuiObject* boss, const GUI::Font& font,
setFill(CheckboxWidget::FillType::Normal);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseEntered()
{
if(isEnabled())
setFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseLeft()
{
if(isEnabled())
clearFlags(Widget::FLAG_HILITED);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckboxWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
{

View File

@ -58,8 +58,8 @@ class Widget : public GuiObject
virtual bool handleKeyUp(StellaKey key, StellaMod mod) { return false; }
virtual void handleMouseDown(int x, int y, MouseButton b, int clickCount) { }
virtual void handleMouseUp(int x, int y, MouseButton b, int clickCount) { }
virtual void handleMouseEntered() { }
virtual void handleMouseLeft() { }
virtual void handleMouseEntered();
virtual void handleMouseLeft();
virtual void handleMouseMoved(int x, int y) { }
virtual void handleMouseWheel(int x, int y, int direction) { }
virtual bool handleMouseClicks(int x, int y, MouseButton b) { return false; }
@ -88,6 +88,7 @@ class Widget : public GuiObject
bool isEnabled() const { return _flags & FLAG_ENABLED; }
bool isVisible() const override { return !(_flags & FLAG_INVISIBLE); }
bool isHighlighted() const { return _flags & FLAG_HILITED; }
bool hasMouseFocus() const { return _flags & FLAG_MOUSE_FOCUS; }
virtual bool wantsFocus() const { return _flags & FLAG_RETAIN_FOCUS; }
bool wantsTab() const { return _flags & FLAG_WANTS_TAB; }
bool wantsRaw() const { return _flags & FLAG_WANTS_RAWDATA; }
@ -231,8 +232,6 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
bool handleMouseClicks(int x, int y, MouseButton b) override;
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
bool handleEvent(Event::Type event) override;
void drawWidget(bool hilite) override;
@ -273,8 +272,6 @@ class CheckboxWidget : public ButtonWidget
bool getState() const { return _state; }
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;
void handleMouseEntered() override;
void handleMouseLeft() override;
static int boxSize(const GUI::Font& font)
{