Ticket #5956: clear-buttons.diff

File clear-buttons.diff, 4.5 KB (added by eriktorbjorn, 12 years ago)

One possible patch against current git

  • gui/dialog.cpp

    diff --git a/gui/dialog.cpp b/gui/dialog.cpp
    index 0522b40..e8c82b3 100644
    a b void Dialog::removeWidget(Widget *del) {  
    334334        if (del == _dragWidget)
    335335                _dragWidget = NULL;
    336336
    337         Widget *w = _firstWidget;
    338 
    339         if (del == _firstWidget) {
    340                 Widget *del_next = del->_next;
    341                 del->_next = 0;
    342                 _firstWidget = del_next;
    343                 return;
    344         }
    345 
    346         w = _firstWidget;
    347         while (w) {
    348                 if (w->_next == del) {
    349                         Widget *del_next = del->_next;
    350                         del->_next = 0;
    351                         w->_next = del_next;
    352                         return;
    353                 }
    354                 w = w->_next;
    355         }
     337       GuiObject::removeWidget(del);
    356338}
    357339
    358340} // End of namespace GUI
  • gui/object.cpp

    diff --git a/gui/object.cpp b/gui/object.cpp
    index 2ec42df..73c4f74 100644
    a b void GuiObject::reflowLayout() {  
    5959        }
    6060}
    6161
     62void GuiObject::removeWidget(Widget *del) {
     63        if (del == _firstWidget) {
     64                Widget *del_next = del->next();
     65                del->setNext(0);
     66                _firstWidget = del_next;
     67                return;
     68        }
     69
     70        Widget *w = _firstWidget;
     71        while (w) {
     72                if (w->next() == del) {
     73                        Widget *del_next = del->next();
     74                        del->setNext(0);
     75                        w->setNext(del_next);
     76                        return;
     77                }
     78                w = w->next();
     79        }
     80}
     81
    6282} // End of namespace GUI
  • gui/object.h

    diff --git a/gui/object.h b/gui/object.h
    index 34ff0d4..bce3cd7 100644
    a b public:  
    8383
    8484        virtual void    reflowLayout();
    8585
     86        virtual void    removeWidget(Widget *widget);
     87
    8688protected:
    8789        virtual void    releaseFocus() = 0;
    8890};
  • gui/options.cpp

    diff --git a/gui/options.cpp b/gui/options.cpp
    index 4fa5a82..afa1b83 100644
    a b static const char *outputRateLabels[] = { _s("<default>"), _s("8 kHz"), _s("11kH  
    7979static const int outputRateValues[] = { 0, 8000, 11025, 22050, 44100, 48000, -1 };
    8080
    8181OptionsDialog::OptionsDialog(const Common::String &domain, int x, int y, int w, int h)
    82         : Dialog(x, y, w, h), _domain(domain), _graphicsTabId(-1), _tabWidget(0) {
     82        : Dialog(x, y, w, h), _domain(domain), _graphicsTabId(-1), _midiTabId(-1), _pathsTabId(-1), _tabWidget(0) {
    8383        init();
    8484}
    8585
    GlobalOptionsDialog::GlobalOptionsDialog()  
    10901090        //
    10911091        // 3) The MIDI tab
    10921092        //
    1093         tab->addTab(_("MIDI"));
     1093        _midiTabId = tab->addTab(_("MIDI"));
    10941094        addMIDIControls(tab, "GlobalOptions_MIDI.");
    10951095
    10961096        //
    GlobalOptionsDialog::GlobalOptionsDialog()  
    11031103        // 5) The Paths tab
    11041104        //
    11051105        if (g_system->getOverlayWidth() > 320)
    1106                 tab->addTab(_("Paths"));
     1106                _pathsTabId = tab->addTab(_("Paths"));
    11071107        else
    1108                 tab->addTab(_c("Paths", "lowres"));
     1108                _pathsTabId = tab->addTab(_c("Paths", "lowres"));
    11091109
    11101110#if !( defined(__DC__) || defined(__GP32__) )
    11111111        // These two buttons have to be extra wide, or the text will be
    void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3  
    14641464        }
    14651465}
    14661466
     1467void GlobalOptionsDialog::reflowLayout() {
     1468        int activeTab = _tabWidget->getActiveTab();
     1469
     1470        if (_midiTabId != -1) {
     1471                _tabWidget->setActiveTab(_midiTabId);
     1472
     1473                _tabWidget->removeWidget(_soundFontClearButton);
     1474                _soundFontClearButton->setNext(0);
     1475                delete _soundFontClearButton;
     1476                _soundFontClearButton = addClearButton(_tabWidget, "GlobalOptions_MIDI.mcFontClearButton", kClearSoundFontCmd);
     1477        }
     1478
     1479        if (_pathsTabId != -1) {
     1480                _tabWidget->setActiveTab(_pathsTabId);
     1481
     1482                _tabWidget->removeWidget(_savePathClearButton);
     1483                _savePathClearButton->setNext(0);
     1484                delete _savePathClearButton;
     1485                _savePathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.SavePathClearButton", kSavePathClearCmd);
     1486
     1487                _tabWidget->removeWidget(_themePathClearButton);
     1488                _themePathClearButton->setNext(0);
     1489                delete _themePathClearButton;
     1490                _themePathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.ThemePathClearButton", kThemePathClearCmd);
     1491
     1492                _tabWidget->removeWidget(_extraPathClearButton);
     1493                _extraPathClearButton->setNext(0);
     1494                delete _extraPathClearButton;
     1495                _extraPathClearButton = addClearButton(_tabWidget, "GlobalOptions_Paths.ExtraPathClearButton", kExtraPathClearCmd);
     1496        }
     1497
     1498        _tabWidget->setActiveTab(activeTab);
     1499        OptionsDialog::reflowLayout();
     1500}
     1501
    14671502} // End of namespace GUI
  • gui/options.h

    diff --git a/gui/options.h b/gui/options.h
    index 92ce3e5..05b3cac 100644
    a b protected:  
    8787
    8888        TabWidget *_tabWidget;
    8989        int _graphicsTabId;
     90        int _midiTabId;
     91        int _pathsTabId;
    9092
    9193private:
    9294        //
    public:  
    191193        void close();
    192194        void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
    193195
     196        virtual void reflowLayout();
     197
    194198protected:
    195199#ifdef SMALL_SCREEN_DEVICE
    196200        KeysDialog *_keysDialog;