mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Add an icon to "Home" tab
This commit is contained in:
parent
c704d20534
commit
e850c8dbb0
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -4,11 +4,12 @@
|
|||||||
url="http://ilkke.blogspot.com/">
|
url="http://ilkke.blogspot.com/">
|
||||||
|
|
||||||
<dimensions>
|
<dimensions>
|
||||||
|
<dim id="tabs_width" value="80" />
|
||||||
<dim id="tabs_height" value="17" />
|
<dim id="tabs_height" value="17" />
|
||||||
<dim id="tabs_empty_height" value="5" />
|
<dim id="tabs_empty_height" value="5" />
|
||||||
<dim id="tabs_width" value="80" />
|
|
||||||
<dim id="tabs_close_icon_width" value="14" />
|
<dim id="tabs_close_icon_width" value="14" />
|
||||||
<dim id="tabs_close_icon_height" value="12" />
|
<dim id="tabs_close_icon_height" value="12" />
|
||||||
|
<dim id="tabs_icon_width" value="10" />
|
||||||
</dimensions>
|
</dimensions>
|
||||||
|
|
||||||
<colors>
|
<colors>
|
||||||
@ -233,6 +234,8 @@
|
|||||||
<part id="tab_close_icon_active" x="37" y="117" w="5" h="5" />
|
<part id="tab_close_icon_active" x="37" y="117" w="5" h="5" />
|
||||||
<part id="tab_icon_bg_active" x="42" y="112" w="14" h="12" />
|
<part id="tab_icon_bg_active" x="42" y="112" w="14" h="12" />
|
||||||
<part id="tab_icon_bg_hover" x="56" y="112" w="14" h="12" />
|
<part id="tab_icon_bg_hover" x="56" y="112" w="14" h="12" />
|
||||||
|
<part id="tab_home_icon_normal" x="32" y="240" w="7" h="8" />
|
||||||
|
<part id="tab_home_icon_active" x="40" y="240" w="7" h="8" />
|
||||||
<part id="editor_normal" x="40" y="96" w1="3" w2="10" w3="3" h1="3" h2="10" h3="3" />
|
<part id="editor_normal" x="40" y="96" w1="3" w2="10" w3="3" h1="3" h2="10" h3="3" />
|
||||||
<part id="editor_selected" x="56" y="96" w1="3" w2="10" w3="3" h1="3" h2="10" h3="3" />
|
<part id="editor_selected" x="56" y="96" w1="3" w2="10" w3="3" h1="3" h2="10" h3="3" />
|
||||||
<part id="colorbar_0" x="0" y="192" w1="5" w2="6" w3="5" h1="5" h2="6" h3="5" />
|
<part id="colorbar_0" x="0" y="192" w1="5" w2="6" w3="5" h1="5" h2="6" h3="5" />
|
||||||
@ -627,6 +630,14 @@
|
|||||||
<text color="tab_active_text" />
|
<text color="tab_active_text" />
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- tab_text -->
|
||||||
|
<style id="tab_text">
|
||||||
|
<text color="tab_normal_text" align="left" valign="middle" padding-left="4" padding-top="2" />
|
||||||
|
</style>
|
||||||
|
<style id="tab_text:active">
|
||||||
|
<text color="tab_active_text" />
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- tab_bottom -->
|
<!-- tab_bottom -->
|
||||||
<style id="tab_bottom">
|
<style id="tab_bottom">
|
||||||
<background part="tab_bottom_normal" color="tab_normal_face" repeat="repeat-x" />
|
<background part="tab_bottom_normal" color="tab_normal_face" repeat="repeat-x" />
|
||||||
@ -679,6 +690,14 @@
|
|||||||
<icon part="tab_modified_icon_normal" />
|
<icon part="tab_modified_icon_normal" />
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- tab_home -->
|
||||||
|
<style id="tab_home">
|
||||||
|
<icon part="tab_home_icon_normal" align="left" valign="middle" x="4" y="1" />
|
||||||
|
</style>
|
||||||
|
<style id="tab_home:active">
|
||||||
|
<icon part="tab_home_icon_active" />
|
||||||
|
</style>
|
||||||
|
|
||||||
</stylesheet>
|
</stylesheet>
|
||||||
|
|
||||||
</skin>
|
</skin>
|
||||||
|
@ -83,6 +83,11 @@ std::string DevConsoleView::getTabText()
|
|||||||
return "Console";
|
return "Console";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TabIcon DevConsoleView::getTabIcon()
|
||||||
|
{
|
||||||
|
return TabIcon::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceView* DevConsoleView::cloneWorkspaceView()
|
WorkspaceView* DevConsoleView::cloneWorkspaceView()
|
||||||
{
|
{
|
||||||
return new DevConsoleView();
|
return new DevConsoleView();
|
||||||
|
@ -26,6 +26,7 @@ namespace app {
|
|||||||
|
|
||||||
// TabView implementation
|
// TabView implementation
|
||||||
std::string getTabText() override;
|
std::string getTabText() override;
|
||||||
|
TabIcon getTabIcon() override;
|
||||||
|
|
||||||
// WorkspaceView implementation
|
// WorkspaceView implementation
|
||||||
ui::Widget* getContentWidget() override { return this; }
|
ui::Widget* getContentWidget() override { return this; }
|
||||||
|
@ -194,6 +194,11 @@ std::string DocumentView::getTabText()
|
|||||||
return m_document->name();
|
return m_document->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TabIcon DocumentView::getTabIcon()
|
||||||
|
{
|
||||||
|
return TabIcon::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceView* DocumentView::cloneWorkspaceView()
|
WorkspaceView* DocumentView::cloneWorkspaceView()
|
||||||
{
|
{
|
||||||
return new DocumentView(m_document, Normal);
|
return new DocumentView(m_document, Normal);
|
||||||
|
@ -42,6 +42,7 @@ namespace app {
|
|||||||
|
|
||||||
// TabView implementation
|
// TabView implementation
|
||||||
std::string getTabText() override;
|
std::string getTabText() override;
|
||||||
|
TabIcon getTabIcon() override;
|
||||||
|
|
||||||
// WorkspaceView implementation
|
// WorkspaceView implementation
|
||||||
ui::Widget* getContentWidget() override { return this; }
|
ui::Widget* getContentWidget() override { return this; }
|
||||||
|
@ -43,6 +43,11 @@ std::string HomeView::getTabText()
|
|||||||
return "Home";
|
return "Home";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TabIcon HomeView::getTabIcon()
|
||||||
|
{
|
||||||
|
return TabIcon::HOME;
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceView* HomeView::cloneWorkspaceView()
|
WorkspaceView* HomeView::cloneWorkspaceView()
|
||||||
{
|
{
|
||||||
return NULL; // This view cannot be cloned
|
return NULL; // This view cannot be cloned
|
||||||
|
@ -27,6 +27,7 @@ namespace app {
|
|||||||
|
|
||||||
// TabView implementation
|
// TabView implementation
|
||||||
std::string getTabText() override;
|
std::string getTabText() override;
|
||||||
|
TabIcon getTabIcon() override;
|
||||||
|
|
||||||
// WorkspaceView implementation
|
// WorkspaceView implementation
|
||||||
ui::Widget* getContentWidget() override { return this; }
|
ui::Widget* getContentWidget() override { return this; }
|
||||||
|
@ -80,6 +80,7 @@ void Tabs::addTab(TabView* tabView)
|
|||||||
{
|
{
|
||||||
Tab* tab = new Tab(tabView);
|
Tab* tab = new Tab(tabView);
|
||||||
tab->text = tab->view->getTabText();
|
tab->text = tab->view->getTabText();
|
||||||
|
tab->icon = tab->view->getTabIcon();
|
||||||
|
|
||||||
m_list.push_back(tab);
|
m_list.push_back(tab);
|
||||||
|
|
||||||
@ -131,8 +132,10 @@ void Tabs::removeTab(TabView* tabView)
|
|||||||
|
|
||||||
void Tabs::updateTabsText()
|
void Tabs::updateTabsText()
|
||||||
{
|
{
|
||||||
for (Tab* tab : m_list)
|
for (Tab* tab : m_list) {
|
||||||
tab->text = tab->view->getTabText();
|
tab->text = tab->view->getTabText();
|
||||||
|
tab->icon = tab->view->getTabIcon();
|
||||||
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +421,7 @@ void Tabs::selectTabInternal(Tab* tab)
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int y_delta,
|
void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int dy,
|
||||||
bool hover, bool selected)
|
bool hover, bool selected)
|
||||||
{
|
{
|
||||||
gfx::Rect box = _box;
|
gfx::Rect box = _box;
|
||||||
@ -439,7 +442,7 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int y_delta,
|
|||||||
if (closeBox.isEmpty())
|
if (closeBox.isEmpty())
|
||||||
clipTextRightSide = 4*ui::guiscale();
|
clipTextRightSide = 4*ui::guiscale();
|
||||||
else {
|
else {
|
||||||
closeBox.y += y_delta;
|
closeBox.y += dy;
|
||||||
clipTextRightSide = closeBox.w;
|
clipTextRightSide = closeBox.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,17 +461,40 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& _box, Tab* tab, int y_delta,
|
|||||||
if (selected) state += skin::Style::active();
|
if (selected) state += skin::Style::active();
|
||||||
if (hover) state += skin::Style::hover();
|
if (hover) state += skin::Style::hover();
|
||||||
|
|
||||||
|
// Tab without text
|
||||||
theme->styles.tab()->paint(g,
|
theme->styles.tab()->paint(g,
|
||||||
gfx::Rect(box.x, box.y+y_delta, box.w, box.h),
|
gfx::Rect(box.x, box.y+dy, box.w, box.h),
|
||||||
nullptr, state);
|
nullptr, state);
|
||||||
|
|
||||||
|
// Tab icon
|
||||||
|
TabIcon icon = tab->icon;
|
||||||
|
int dx = 0;
|
||||||
|
switch (icon) {
|
||||||
|
case TabIcon::NONE:
|
||||||
|
break;
|
||||||
|
case TabIcon::HOME:
|
||||||
|
{
|
||||||
|
theme->styles.tabHome()->paint(g,
|
||||||
|
gfx::Rect(
|
||||||
|
box.x,
|
||||||
|
box.y+dy,
|
||||||
|
box.x-dx,
|
||||||
|
box.h),
|
||||||
|
nullptr, state);
|
||||||
|
dx += theme->dimensions.tabsIconWidth();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tab with text + clipping the close button
|
||||||
if (box.w > 8*ui::guiscale()) {
|
if (box.w > 8*ui::guiscale()) {
|
||||||
IntersectClip clip(g, gfx::Rect(box.x, box.y+y_delta, box.w-clipTextRightSide, box.h));
|
IntersectClip clip(g, gfx::Rect(box.x+dx, box.y+dy, box.w-dx-clipTextRightSide, box.h));
|
||||||
theme->styles.tab()->paint(g,
|
theme->styles.tabText()->paint(g,
|
||||||
gfx::Rect(box.x, box.y+y_delta, box.w, box.h),
|
gfx::Rect(box.x+dx, box.y+dy, box.w-dx, box.h),
|
||||||
tab->text.c_str(), state);
|
tab->text.c_str(), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tab bottom part
|
||||||
theme->styles.tabBottom()->paint(g,
|
theme->styles.tabBottom()->paint(g,
|
||||||
gfx::Rect(box.x, box.y2(), box.w, getBounds().y2()-box.y2()),
|
gfx::Rect(box.x, box.y2(), box.w, getBounds().y2()-box.y2()),
|
||||||
nullptr, state);
|
nullptr, state);
|
||||||
|
@ -22,6 +22,11 @@ namespace ui {
|
|||||||
namespace app {
|
namespace app {
|
||||||
class Tabs;
|
class Tabs;
|
||||||
|
|
||||||
|
enum class TabIcon {
|
||||||
|
NONE,
|
||||||
|
HOME,
|
||||||
|
};
|
||||||
|
|
||||||
// Required interface to be implemented by each new tab that is added
|
// Required interface to be implemented by each new tab that is added
|
||||||
// in the Tabs widget.
|
// in the Tabs widget.
|
||||||
class TabView {
|
class TabView {
|
||||||
@ -30,6 +35,9 @@ namespace app {
|
|||||||
|
|
||||||
// Returns the text to be shown in the tab.
|
// Returns the text to be shown in the tab.
|
||||||
virtual std::string getTabText() = 0;
|
virtual std::string getTabText() = 0;
|
||||||
|
|
||||||
|
// Returns the icon to be shown in the tab
|
||||||
|
virtual TabIcon getTabIcon() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Interface used to control notifications from the Tabs widget.
|
// Interface used to control notifications from the Tabs widget.
|
||||||
@ -55,6 +63,7 @@ namespace app {
|
|||||||
struct Tab {
|
struct Tab {
|
||||||
TabView* view;
|
TabView* view;
|
||||||
std::string text;
|
std::string text;
|
||||||
|
TabIcon icon;
|
||||||
|
|
||||||
Tab(TabView* view) : view(view) {
|
Tab(TabView* view) : view(view) {
|
||||||
}
|
}
|
||||||
@ -92,7 +101,7 @@ namespace app {
|
|||||||
void stopAni();
|
void stopAni();
|
||||||
|
|
||||||
void selectTabInternal(Tab* tab);
|
void selectTabInternal(Tab* tab);
|
||||||
void drawTab(ui::Graphics* g, const gfx::Rect& box, Tab* tab, int y_delta, bool hover, bool selected);
|
void drawTab(ui::Graphics* g, const gfx::Rect& box, Tab* tab, int dy, bool hover, bool selected);
|
||||||
TabsListIterator getTabIteratorByView(TabView* tabView);
|
TabsListIterator getTabIteratorByView(TabView* tabView);
|
||||||
Tab* getTabByView(TabView* tabView);
|
Tab* getTabByView(TabView* tabView);
|
||||||
int getMaxScrollX();
|
int getMaxScrollX();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user