mirror of https://github.com/aseprite/aseprite.git
Add Timeline visibility button to Toolbar, extracted button draw logic to separate member function
This commit is contained in:
parent
27ec013f8b
commit
4f73b14f8f
|
|
@ -2120,6 +2120,8 @@ jumble = Jumble Tool
|
||||||
shortcut = Shortcut: {0}
|
shortcut = Shortcut: {0}
|
||||||
preview_hide = Hide Preview
|
preview_hide = Hide Preview
|
||||||
preview_show = Show Preview
|
preview_show = Show Preview
|
||||||
|
timeline_hide = Hide Timeline
|
||||||
|
timeline_show = Show Timeline
|
||||||
|
|
||||||
[undo_history]
|
[undo_history]
|
||||||
title = Undo History
|
title = Undo History
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,14 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||||
bool state = preview->isPreviewEnabled();
|
bool state = preview->isPreviewEnabled();
|
||||||
preview->setPreviewEnabled(!state);
|
preview->setPreviewEnabled(!state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toolrc = getToolGroupBounds(TimelineVisibilityIndex);
|
||||||
|
if (mousePos.y >= toolrc.y &&
|
||||||
|
mousePos.y < toolrc.y + toolrc.h) {
|
||||||
|
// Toggle timeline visibility
|
||||||
|
bool state = App::instance()->mainWindow()->getTimelineVisibility();
|
||||||
|
App::instance()->mainWindow()->setTimelineVisibility(!state);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,6 +201,12 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||||
new_hot_index = PreviewVisibilityIndex;
|
new_hot_index = PreviewVisibilityIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toolrc = getToolGroupBounds(TimelineVisibilityIndex);
|
||||||
|
if (mousePos.y >= toolrc.y &&
|
||||||
|
mousePos.y < toolrc.y + toolrc.h) {
|
||||||
|
new_hot_index = TimelineVisibilityIndex;
|
||||||
|
}
|
||||||
|
|
||||||
// hot button changed
|
// hot button changed
|
||||||
if (new_hot_tool != m_hotTool ||
|
if (new_hot_tool != m_hotTool ||
|
||||||
new_hot_index != m_hotIndex) {
|
new_hot_index != m_hotIndex) {
|
||||||
|
|
@ -299,13 +313,14 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||||
ToolGroupList::iterator it = toolbox->begin_group();
|
ToolGroupList::iterator it = toolbox->begin_group();
|
||||||
int groups = toolbox->getGroupsCount();
|
int groups = toolbox->getGroupsCount();
|
||||||
Rect toolrc;
|
Rect toolrc;
|
||||||
|
SkinPartPtr nw;
|
||||||
|
os::Surface* icon;
|
||||||
|
|
||||||
g->fillRect(theme->colors.tabActiveFace(), bounds);
|
g->fillRect(theme->colors.tabActiveFace(), bounds);
|
||||||
|
|
||||||
for (int c=0; c<groups; ++c, ++it) {
|
for (int c=0; c<groups; ++c, ++it) {
|
||||||
ToolGroup* tool_group = *it;
|
ToolGroup* tool_group = *it;
|
||||||
Tool* tool = m_selectedInGroup[tool_group];
|
Tool* tool = m_selectedInGroup[tool_group];
|
||||||
SkinPartPtr nw;
|
|
||||||
|
|
||||||
if (activeTool == tool || m_hotIndex == c) {
|
if (activeTool == tool || m_hotIndex == c) {
|
||||||
nw = theme->parts.toolbuttonHot();
|
nw = theme->parts.toolbuttonHot();
|
||||||
|
|
@ -315,36 +330,28 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||||
theme->parts.toolbuttonLast();
|
theme->parts.toolbuttonLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
toolrc = getToolGroupBounds(c);
|
|
||||||
toolrc.offset(-origin());
|
|
||||||
theme->drawRect(g, toolrc, nw.get());
|
|
||||||
|
|
||||||
// Draw the tool icon
|
// Draw the tool icon
|
||||||
os::Surface* icon = theme->getToolIcon(tool->getId().c_str());
|
icon = theme->getToolIcon(tool->getId().c_str());
|
||||||
if (icon) {
|
drawToolIcon(g, c, nw, icon);
|
||||||
g->drawRgbaSurface(icon,
|
|
||||||
CALC_FOR_CENTER(toolrc.x, toolrc.w, icon->width()),
|
|
||||||
CALC_FOR_CENTER(toolrc.y, toolrc.h, icon->height()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw button to show/hide preview
|
// Draw button to show/hide preview
|
||||||
toolrc = getToolGroupBounds(PreviewVisibilityIndex);
|
|
||||||
toolrc.offset(-origin());
|
|
||||||
bool isHot = (m_hotIndex == PreviewVisibilityIndex ||
|
bool isHot = (m_hotIndex == PreviewVisibilityIndex ||
|
||||||
App::instance()->mainWindow()->getPreviewEditor()->isPreviewEnabled());
|
App::instance()->mainWindow()->getPreviewEditor()->isPreviewEnabled());
|
||||||
theme->drawRect(
|
nw = isHot ? theme->parts.toolbuttonHot():
|
||||||
g,
|
theme->parts.toolbuttonLast();
|
||||||
toolrc,
|
icon = theme->getToolIcon("minieditor");
|
||||||
(isHot ? theme->parts.toolbuttonHot().get():
|
|
||||||
theme->parts.toolbuttonLast().get()));
|
|
||||||
|
|
||||||
os::Surface* icon = theme->getToolIcon("minieditor");
|
drawToolIcon(g, PreviewVisibilityIndex, nw, icon);
|
||||||
if (icon) {
|
|
||||||
g->drawRgbaSurface(icon,
|
// Draw button to show/hide timeline
|
||||||
CALC_FOR_CENTER(toolrc.x, toolrc.w, icon->width()),
|
isHot = (m_hotIndex == TimelineVisibilityIndex ||
|
||||||
CALC_FOR_CENTER(toolrc.y, toolrc.h, icon->height()));
|
App::instance()->mainWindow()->getTimelineVisibility());
|
||||||
}
|
nw = isHot ? theme->parts.toolbuttonHot():
|
||||||
|
theme->parts.toolbuttonLast();
|
||||||
|
icon = theme->getToolIcon("minieditor");
|
||||||
|
|
||||||
|
drawToolIcon(g, TimelineVisibilityIndex, nw, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBar::onVisible(bool visible)
|
void ToolBar::onVisible(bool visible)
|
||||||
|
|
@ -457,6 +464,11 @@ Rect ToolBar::getToolGroupBounds(int group_index)
|
||||||
rc.h = iconsize.h+2*guiscale();
|
rc.h = iconsize.h+2*guiscale();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TimelineVisibilityIndex:
|
||||||
|
rc.y += rc.h - iconsize.h - iconsize.h - 2*guiscale();
|
||||||
|
rc.h = iconsize.h+2*guiscale();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rc.y += group_index*(iconsize.h-1*guiscale());
|
rc.y += group_index*(iconsize.h-1*guiscale());
|
||||||
rc.h = group_index < groups-1 ? iconsize.h+1*guiscale():
|
rc.h = group_index < groups-1 ? iconsize.h+1*guiscale():
|
||||||
|
|
@ -517,6 +529,12 @@ void ToolBar::openTipWindow(int group_index, Tool* tool)
|
||||||
else
|
else
|
||||||
tooltip = Strings::tools_preview_show();
|
tooltip = Strings::tools_preview_show();
|
||||||
}
|
}
|
||||||
|
else if (group_index == TimelineVisibilityIndex) {
|
||||||
|
if (App::instance()->mainWindow()->getTimelineVisibility())
|
||||||
|
tooltip = Strings::tools_timeline_hide();
|
||||||
|
else
|
||||||
|
tooltip = Strings::tools_timeline_show();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -586,6 +604,20 @@ void ToolBar::onClosePopup()
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolBar::drawToolIcon(Graphics* g, int group_index, SkinPartPtr skin, os::Surface* icon) {
|
||||||
|
auto theme = SkinTheme::get(this);
|
||||||
|
Rect toolrc = getToolGroupBounds(group_index);
|
||||||
|
toolrc.offset(-origin());
|
||||||
|
|
||||||
|
theme->drawRect(g, toolrc, skin.get());
|
||||||
|
|
||||||
|
if (icon) {
|
||||||
|
g->drawRgbaSurface(icon,
|
||||||
|
CALC_FOR_CENTER(toolrc.x, toolrc.w, icon->width()),
|
||||||
|
CALC_FOR_CENTER(toolrc.y, toolrc.h, icon->height()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// ToolStrip
|
// ToolStrip
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "app/tools/active_tool_observer.h"
|
#include "app/tools/active_tool_observer.h"
|
||||||
|
#include "app/ui/skin/skin_part.h"
|
||||||
#include "gfx/point.h"
|
#include "gfx/point.h"
|
||||||
#include "obs/connection.h"
|
#include "obs/connection.h"
|
||||||
#include "ui/timer.h"
|
#include "ui/timer.h"
|
||||||
|
|
@ -37,6 +38,7 @@ namespace app {
|
||||||
|
|
||||||
static const int NoneIndex = -1;
|
static const int NoneIndex = -1;
|
||||||
static const int PreviewVisibilityIndex = -2;
|
static const int PreviewVisibilityIndex = -2;
|
||||||
|
static const int TimelineVisibilityIndex = -3;
|
||||||
|
|
||||||
ToolBar();
|
ToolBar();
|
||||||
~ToolBar();
|
~ToolBar();
|
||||||
|
|
@ -62,6 +64,7 @@ namespace app {
|
||||||
gfx::Point getToolPositionInGroup(int group_index, tools::Tool* tool);
|
gfx::Point getToolPositionInGroup(int group_index, tools::Tool* tool);
|
||||||
void openTipWindow(int group_index, tools::Tool* tool);
|
void openTipWindow(int group_index, tools::Tool* tool);
|
||||||
void onClosePopup();
|
void onClosePopup();
|
||||||
|
void drawToolIcon(ui::Graphics* g, int group_index, skin::SkinPartPtr skin, os::Surface* icon);
|
||||||
|
|
||||||
// ActiveToolObserver impl
|
// ActiveToolObserver impl
|
||||||
void onActiveToolChange(tools::Tool* tool) override;
|
void onActiveToolChange(tools::Tool* tool) override;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue