mirror of https://github.com/stella-emu/stella.git
each tab can now have a defined width (see DeveloperDialog)
This commit is contained in:
parent
532b629a93
commit
c3671ac095
|
@ -88,7 +88,7 @@ void DeveloperDialog::addEmulationTab(const GUI::Font& font)
|
||||||
int lineHeight = font.getLineHeight();
|
int lineHeight = font.getLineHeight();
|
||||||
WidgetArray wid;
|
WidgetArray wid;
|
||||||
VariantList items;
|
VariantList items;
|
||||||
int tabID = myTab->addTab("Emulation");
|
int tabID = myTab->addTab(" Emulation ", TabWidget::AUTO_WIDTH);
|
||||||
|
|
||||||
// settings set
|
// settings set
|
||||||
mySettingsGroupEmulation = new RadioButtonGroup();
|
mySettingsGroupEmulation = new RadioButtonGroup();
|
||||||
|
@ -188,7 +188,7 @@ void DeveloperDialog::addTiaTab(const GUI::Font& font)
|
||||||
int pwidth = font.getStringWidth("Faulty Cosmic Ark stars");
|
int pwidth = font.getStringWidth("Faulty Cosmic Ark stars");
|
||||||
WidgetArray wid;
|
WidgetArray wid;
|
||||||
VariantList items;
|
VariantList items;
|
||||||
int tabID = myTab->addTab("TIA");
|
int tabID = myTab->addTab(" TIA ", TabWidget::AUTO_WIDTH);
|
||||||
|
|
||||||
wid.clear();
|
wid.clear();
|
||||||
|
|
||||||
|
@ -222,15 +222,15 @@ void DeveloperDialog::addTiaTab(const GUI::Font& font)
|
||||||
ypos += lineHeight + VGAP * 1;
|
ypos += lineHeight + VGAP * 1;
|
||||||
|
|
||||||
myPlInvPhaseWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 3, ypos + 1,
|
myPlInvPhaseWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 3, ypos + 1,
|
||||||
"players");
|
"Players");
|
||||||
wid.push_back(myPlInvPhaseWidget);
|
wid.push_back(myPlInvPhaseWidget);
|
||||||
|
|
||||||
myMsInvPhaseWidget = new CheckboxWidget(myTab, font, myPlInvPhaseWidget->getRight() + 20, ypos + 1,
|
myMsInvPhaseWidget = new CheckboxWidget(myTab, font, myPlInvPhaseWidget->getRight() + 20, ypos + 1,
|
||||||
"missiles");
|
"Missiles");
|
||||||
wid.push_back(myMsInvPhaseWidget);
|
wid.push_back(myMsInvPhaseWidget);
|
||||||
|
|
||||||
myBlInvPhaseWidget = new CheckboxWidget(myTab, font, myMsInvPhaseWidget->getRight() + 20, ypos + 1,
|
myBlInvPhaseWidget = new CheckboxWidget(myTab, font, myMsInvPhaseWidget->getRight() + 20, ypos + 1,
|
||||||
"ball");
|
"Ball");
|
||||||
wid.push_back(myBlInvPhaseWidget);
|
wid.push_back(myBlInvPhaseWidget);
|
||||||
ypos += lineHeight + VGAP * 1;
|
ypos += lineHeight + VGAP * 1;
|
||||||
|
|
||||||
|
@ -239,11 +239,11 @@ void DeveloperDialog::addTiaTab(const GUI::Font& font)
|
||||||
wid.push_back(myPlayfieldLabel);
|
wid.push_back(myPlayfieldLabel);
|
||||||
ypos += lineHeight + VGAP * 1;
|
ypos += lineHeight + VGAP * 1;
|
||||||
|
|
||||||
myPFBitsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 3, ypos + 1, "bits");
|
myPFBitsWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 3, ypos + 1, "Bits");
|
||||||
wid.push_back(myPFBitsWidget);
|
wid.push_back(myPFBitsWidget);
|
||||||
//ypos += lineHeight + VGAP * 1;
|
//ypos += lineHeight + VGAP * 1;
|
||||||
|
|
||||||
myPFColorWidget = new CheckboxWidget(myTab, font, myPFBitsWidget->getRight() + 20, ypos + 1, "color");
|
myPFColorWidget = new CheckboxWidget(myTab, font, myPFBitsWidget->getRight() + 20, ypos + 1, "Color");
|
||||||
wid.push_back(myPFColorWidget);
|
wid.push_back(myPFColorWidget);
|
||||||
ypos += lineHeight + VGAP * 1;
|
ypos += lineHeight + VGAP * 1;
|
||||||
|
|
||||||
|
@ -252,10 +252,10 @@ void DeveloperDialog::addTiaTab(const GUI::Font& font)
|
||||||
wid.push_back(mySwapLabel);
|
wid.push_back(mySwapLabel);
|
||||||
ypos += lineHeight + VGAP * 1;
|
ypos += lineHeight + VGAP * 1;
|
||||||
|
|
||||||
myPlSwapWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 3, ypos + 1, "players");
|
myPlSwapWidget = new CheckboxWidget(myTab, font, HBORDER + INDENT * 3, ypos + 1, "Players");
|
||||||
wid.push_back(myPlSwapWidget);
|
wid.push_back(myPlSwapWidget);
|
||||||
|
|
||||||
myBlSwapWidget = new CheckboxWidget(myTab, font, myPlSwapWidget->getRight() + 20, ypos + 1, "ball");
|
myBlSwapWidget = new CheckboxWidget(myTab, font, myPlSwapWidget->getRight() + 20, ypos + 1, "Ball");
|
||||||
wid.push_back(myBlSwapWidget);
|
wid.push_back(myBlSwapWidget);
|
||||||
|
|
||||||
// Add items for tab 2
|
// Add items for tab 2
|
||||||
|
@ -276,7 +276,7 @@ void DeveloperDialog::addVideoTab(const GUI::Font& font)
|
||||||
int pwidth = font.getMaxCharWidth() * 6;
|
int pwidth = font.getMaxCharWidth() * 6;
|
||||||
WidgetArray wid;
|
WidgetArray wid;
|
||||||
VariantList items;
|
VariantList items;
|
||||||
int tabID = myTab->addTab("Video");
|
int tabID = myTab->addTab(" Video ", TabWidget::AUTO_WIDTH);
|
||||||
|
|
||||||
wid.clear();
|
wid.clear();
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font)
|
||||||
lwidth = fontWidth * 11;
|
lwidth = fontWidth * 11;
|
||||||
WidgetArray wid;
|
WidgetArray wid;
|
||||||
VariantList items;
|
VariantList items;
|
||||||
int tabID = myTab->addTab("Time Mach.");
|
int tabID = myTab->addTab(" Time Machine ", TabWidget::AUTO_WIDTH);
|
||||||
|
|
||||||
// settings set
|
// settings set
|
||||||
mySettingsGroupTM = new RadioButtonGroup();
|
mySettingsGroupTM = new RadioButtonGroup();
|
||||||
|
@ -475,7 +475,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void DeveloperDialog::addDebuggerTab(const GUI::Font& font)
|
void DeveloperDialog::addDebuggerTab(const GUI::Font& font)
|
||||||
{
|
{
|
||||||
int tabID = myTab->addTab("Debugger");
|
int tabID = myTab->addTab(" Debugger ", TabWidget::AUTO_WIDTH);
|
||||||
WidgetArray wid;
|
WidgetArray wid;
|
||||||
|
|
||||||
#ifdef DEBUGGER_SUPPORT
|
#ifdef DEBUGGER_SUPPORT
|
||||||
|
|
|
@ -63,20 +63,38 @@ int TabWidget::getChildY() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
int TabWidget::addTab(const string& title)
|
int TabWidget::addTab(const string& title, int tabWidth)
|
||||||
{
|
{
|
||||||
// Add a new tab page
|
// Add a new tab page
|
||||||
_tabs.push_back(Tab(title));
|
int newWidth = _font.getStringWidth(title) + 2 * kTabPadding;
|
||||||
|
|
||||||
|
if(tabWidth == AUTO_WIDTH)
|
||||||
|
_tabs.push_back(Tab(title, newWidth));
|
||||||
|
else
|
||||||
|
_tabs.push_back(Tab(title, tabWidth));
|
||||||
int numTabs = int(_tabs.size());
|
int numTabs = int(_tabs.size());
|
||||||
|
|
||||||
// Determine the new tab width
|
// Determine the new tab width
|
||||||
int newWidth = _font.getStringWidth(title) + 2 * kTabPadding;
|
int fixedWidth = 0, fixedTabs = 0;
|
||||||
if (_tabWidth < newWidth)
|
for(int i = 0; i < int(_tabs.size()); ++i)
|
||||||
_tabWidth = newWidth;
|
{
|
||||||
|
if(_tabs[i].tabWidth != NO_WIDTH)
|
||||||
|
{
|
||||||
|
fixedWidth += _tabs[i].tabWidth;
|
||||||
|
fixedTabs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int maxWidth = (_w - kTabLeftOffset) / numTabs - kTabLeftOffset;
|
if(tabWidth == NO_WIDTH)
|
||||||
if (_tabWidth > maxWidth)
|
if(_tabWidth < newWidth)
|
||||||
_tabWidth = maxWidth;
|
_tabWidth = newWidth;
|
||||||
|
|
||||||
|
if(numTabs - fixedTabs)
|
||||||
|
{
|
||||||
|
int maxWidth = (_w - kTabLeftOffset - fixedWidth) / (numTabs - fixedTabs) - kTabLeftOffset;
|
||||||
|
if(_tabWidth > maxWidth)
|
||||||
|
_tabWidth = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
// Activate the new tab
|
// Activate the new tab
|
||||||
setActiveTab(numTabs - 1);
|
setActiveTab(numTabs - 1);
|
||||||
|
@ -178,11 +196,16 @@ void TabWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
|
||||||
// Determine which tab was clicked
|
// Determine which tab was clicked
|
||||||
int tabID = -1;
|
int tabID = -1;
|
||||||
x -= kTabLeftOffset;
|
x -= kTabLeftOffset;
|
||||||
if (x >= 0 && x % (_tabWidth + kTabSpacing) < _tabWidth)
|
|
||||||
|
for(int i = 0; i < int(_tabs.size()); ++i)
|
||||||
{
|
{
|
||||||
tabID = x / (_tabWidth + kTabSpacing);
|
int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth;
|
||||||
if (tabID >= int(_tabs.size()))
|
if(x >= 0 && x < tabWidth)
|
||||||
tabID = -1;
|
{
|
||||||
|
tabID = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
x -= (tabWidth + kTabSpacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a tab was clicked, switch to that pane
|
// If a tab was clicked, switch to that pane
|
||||||
|
@ -264,24 +287,25 @@ void TabWidget::drawWidget(bool hilite)
|
||||||
int i, x = _x + kTabLeftOffset;
|
int i, x = _x + kTabLeftOffset;
|
||||||
for (i = 0; i < int(_tabs.size()); ++i)
|
for (i = 0; i < int(_tabs.size()); ++i)
|
||||||
{
|
{
|
||||||
|
int tabWidth = _tabs[i].tabWidth ? _tabs[i].tabWidth : _tabWidth;
|
||||||
ColorId fontcolor = _tabs[i].enabled && onTop? kTextColor : kColor;
|
ColorId fontcolor = _tabs[i].enabled && onTop? kTextColor : kColor;
|
||||||
int yOffset = (i == _activeTab) ? 0 : 1;
|
int yOffset = (i == _activeTab) ? 0 : 1;
|
||||||
s.fillRect(x, _y + 1, _tabWidth, _tabHeight - 1,
|
s.fillRect(x, _y + 1, tabWidth, _tabHeight - 1,
|
||||||
(i == _activeTab)
|
(i == _activeTab)
|
||||||
? onTop ? kDlgColor : kBGColorLo
|
? onTop ? kDlgColor : kBGColorLo
|
||||||
: onTop ? kBGColorHi : kDlgColor); // ? kWidColor : kDlgColor
|
: onTop ? kBGColorHi : kDlgColor); // ? kWidColor : kDlgColor
|
||||||
s.drawString(_font, _tabs[i].title, x + kTabPadding + yOffset,
|
s.drawString(_font, _tabs[i].title, x + kTabPadding + yOffset,
|
||||||
_y + yOffset + (_tabHeight - _fontHeight - 1),
|
_y + yOffset + (_tabHeight - _fontHeight - 1),
|
||||||
_tabWidth - 2 * kTabPadding, fontcolor, TextAlign::Center);
|
tabWidth - 2 * kTabPadding, fontcolor, TextAlign::Center);
|
||||||
if(i == _activeTab)
|
if(i == _activeTab)
|
||||||
{
|
{
|
||||||
s.hLine(x, _y, x + _tabWidth - 1, onTop ? kWidColor : kDlgColor);
|
s.hLine(x, _y, x + tabWidth - 1, onTop ? kWidColor : kDlgColor);
|
||||||
s.vLine(x + _tabWidth, _y + 1, _y + _tabHeight - 1, onTop ? kBGColorLo : kColor);
|
s.vLine(x + tabWidth, _y + 1, _y + _tabHeight - 1, onTop ? kBGColorLo : kColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s.hLine(x, _y + _tabHeight, x + _tabWidth, onTop ? kWidColor : kDlgColor);
|
s.hLine(x, _y + _tabHeight, x + tabWidth, onTop ? kWidColor : kDlgColor);
|
||||||
|
|
||||||
x += _tabWidth + kTabSpacing;
|
x += tabWidth + kTabSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill empty right space
|
// fill empty right space
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
class TabWidget : public Widget, public CommandSender
|
class TabWidget : public Widget, public CommandSender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const int NO_WIDTH = 0;
|
||||||
|
static const int AUTO_WIDTH = -1;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kTabChangedCmd = 'TBCH'
|
kTabChangedCmd = 'TBCH'
|
||||||
};
|
};
|
||||||
|
@ -40,7 +43,7 @@ class TabWidget : public Widget, public CommandSender
|
||||||
// First off, widget should allow non-dialog bosses, (i.e. also other widgets)
|
// First off, widget should allow non-dialog bosses, (i.e. also other widgets)
|
||||||
// Could add a common base class for Widgets and Dialogs.
|
// Could add a common base class for Widgets and Dialogs.
|
||||||
// Then you add tabs using the following method, which returns a unique ID
|
// Then you add tabs using the following method, which returns a unique ID
|
||||||
int addTab(const string& title);
|
int addTab(const string& title, int tabWidth = NO_WIDTH);
|
||||||
// Maybe we need to remove tabs again? Hm
|
// Maybe we need to remove tabs again? Hm
|
||||||
//void removeTab(int tabID);
|
//void removeTab(int tabID);
|
||||||
// Setting the active tab:
|
// Setting the active tab:
|
||||||
|
@ -76,10 +79,11 @@ class TabWidget : public Widget, public CommandSender
|
||||||
Widget* firstWidget;
|
Widget* firstWidget;
|
||||||
Widget* parentWidget;
|
Widget* parentWidget;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
int tabWidth;
|
||||||
|
|
||||||
Tab(const string& t = "", Widget* first = nullptr, Widget* parent = nullptr,
|
Tab(const string& t, int tw = NO_WIDTH,
|
||||||
bool e = true)
|
Widget* first = nullptr, Widget* parent = nullptr, bool e = true)
|
||||||
: title(t), firstWidget(first), parentWidget(parent), enabled(e) { }
|
: title(t), firstWidget(first), parentWidget(parent), enabled(e), tabWidth(tw) { }
|
||||||
};
|
};
|
||||||
using TabList = vector<Tab>;
|
using TabList = vector<Tab>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue