mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 01:20:25 +00:00
Animation controls always visible in StatusBar
This commit is contained in:
parent
486ab7dfc1
commit
4fe1e9771e
@ -181,7 +181,6 @@ StatusBar::StatusBar()
|
|||||||
{
|
{
|
||||||
Box* box1 = new Box(JI_HORIZONTAL);
|
Box* box1 = new Box(JI_HORIZONTAL);
|
||||||
Box* box2 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
Box* box2 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||||
Box* box3 = new Box(JI_HORIZONTAL);
|
|
||||||
Box* box4 = new Box(JI_HORIZONTAL);
|
Box* box4 = new Box(JI_HORIZONTAL);
|
||||||
m_slider = new Slider(0, 255, 255);
|
m_slider = new Slider(0, 255, 255);
|
||||||
m_currentFrame = new GotoFrameEntry();
|
m_currentFrame = new GotoFrameEntry();
|
||||||
@ -203,8 +202,6 @@ StatusBar::StatusBar()
|
|||||||
|
|
||||||
box1->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());
|
box1->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());
|
||||||
box2->noBorderNoChildSpacing();
|
box2->noBorderNoChildSpacing();
|
||||||
box3->noBorderNoChildSpacing();
|
|
||||||
box3->setExpansive(true);
|
|
||||||
|
|
||||||
box4->addChild(m_currentFrame);
|
box4->addChild(m_currentFrame);
|
||||||
box4->addChild(m_newFrame);
|
box4->addChild(m_newFrame);
|
||||||
@ -215,21 +212,25 @@ StatusBar::StatusBar()
|
|||||||
box2->addChild(m_b_next);
|
box2->addChild(m_b_next);
|
||||||
box2->addChild(m_b_last);
|
box2->addChild(m_b_last);
|
||||||
|
|
||||||
box1->addChild(box3);
|
|
||||||
box1->addChild(box4);
|
box1->addChild(box4);
|
||||||
box1->addChild(box2);
|
box1->addChild(box2);
|
||||||
box1->addChild(m_slider);
|
box1->addChild(m_slider);
|
||||||
|
|
||||||
m_commandsBox = box1;
|
m_commandsBox = box1;
|
||||||
|
addChild(m_commandsBox);
|
||||||
|
m_commandsBox->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
App::instance()->CurrentToolChange.connect(&StatusBar::onCurrentToolChange, this);
|
App::instance()->CurrentToolChange.connect(&StatusBar::onCurrentToolChange, this);
|
||||||
|
UIContext::instance()->addObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBar::~StatusBar()
|
StatusBar::~StatusBar()
|
||||||
{
|
{
|
||||||
for (ProgressList::iterator it = m_progress.begin(); it != m_progress.end(); ++it)
|
UIContext::instance()->removeObserver(this);
|
||||||
delete *it;
|
|
||||||
|
for (Progress* bar : m_progress)
|
||||||
|
delete bar;
|
||||||
|
|
||||||
delete m_tipwindow; // widget
|
delete m_tipwindow; // widget
|
||||||
delete m_commandsBox;
|
delete m_commandsBox;
|
||||||
@ -396,46 +397,13 @@ double Progress::getPos() const
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// StatusBar message handler
|
// StatusBar message handler
|
||||||
|
|
||||||
bool StatusBar::onProcessMessage(Message* msg)
|
|
||||||
{
|
|
||||||
switch (msg->type()) {
|
|
||||||
|
|
||||||
case kMouseEnterMessage: {
|
|
||||||
updateSubwidgetsVisibility();
|
|
||||||
|
|
||||||
const Document* document = UIContext::instance()->activeDocument();
|
|
||||||
if (document != NULL) {
|
|
||||||
updateFromLayer();
|
|
||||||
updateCurrentFrame();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case kMouseLeaveMessage:
|
|
||||||
if (hasChild(m_commandsBox)) {
|
|
||||||
// If we want restore the state-bar and the slider doesn't have
|
|
||||||
// the capture...
|
|
||||||
if (getManager()->getCapture() != m_slider) {
|
|
||||||
// ...exit from command mode
|
|
||||||
getManager()->freeFocus(); // TODO Review this code
|
|
||||||
|
|
||||||
removeChild(m_commandsBox);
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return Widget::onProcessMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusBar::onResize(ResizeEvent& ev)
|
void StatusBar::onResize(ResizeEvent& ev)
|
||||||
{
|
{
|
||||||
setBoundsQuietly(ev.getBounds());
|
setBoundsQuietly(ev.getBounds());
|
||||||
|
|
||||||
Rect rc = ev.getBounds();
|
Rect rc = ev.getBounds();
|
||||||
rc.w -= rc.w/4 + 4*guiscale();
|
rc.x += rc.w/2;
|
||||||
|
rc.w /= 2;
|
||||||
m_commandsBox->setBounds(rc);
|
m_commandsBox->setBounds(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,8 +489,12 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
|
|||||||
x -= width+4;
|
x -= width+4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateSubwidgetsVisibility();
|
void StatusBar::onSetActiveDocument(doc::Document* document)
|
||||||
|
{
|
||||||
|
updateFromDocument();
|
||||||
|
updateCurrentFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StatusBar::CustomizedTipWindow::onProcessMessage(Message* msg)
|
bool StatusBar::CustomizedTipWindow::onProcessMessage(Message* msg)
|
||||||
@ -580,25 +552,30 @@ static void ani_button_command(Button* widget, AniAction action)
|
|||||||
UIContext::instance()->executeCommand(cmd);
|
UIContext::instance()->executeCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::updateFromLayer()
|
void StatusBar::updateFromDocument()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
const ContextReader reader(UIContext::instance());
|
if (UIContext::instance()->activeDocument()) {
|
||||||
const Cel* cel;
|
const ContextReader reader(UIContext::instance());
|
||||||
|
m_commandsBox->setVisible(true);
|
||||||
|
|
||||||
// Opacity layer
|
// Cel opacity
|
||||||
if (reader.sprite() &&
|
const Cel* cel;
|
||||||
reader.sprite()->supportAlpha() &&
|
if (reader.sprite()->supportAlpha() &&
|
||||||
reader.layer() &&
|
reader.layer() &&
|
||||||
reader.layer()->isImage() &&
|
reader.layer()->isImage() &&
|
||||||
!reader.layer()->isBackground() &&
|
!reader.layer()->isBackground() &&
|
||||||
(cel = reader.cel())) {
|
(cel = reader.cel())) {
|
||||||
m_slider->setValue(MID(0, cel->opacity(), 255));
|
m_slider->setValue(MID(0, cel->opacity(), 255));
|
||||||
m_slider->setEnabled(true);
|
m_slider->setEnabled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_slider->setValue(255);
|
||||||
|
m_slider->setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_slider->setValue(255);
|
m_commandsBox->setVisible(false);
|
||||||
m_slider->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (LockedDocumentException&) {
|
catch (LockedDocumentException&) {
|
||||||
@ -621,23 +598,4 @@ void StatusBar::newFrame()
|
|||||||
updateCurrentFrame();
|
updateCurrentFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBar::updateSubwidgetsVisibility()
|
|
||||||
{
|
|
||||||
const Document* document = UIContext::instance()->activeDocument();
|
|
||||||
bool commandsVisible = (document != NULL && hasMouse());
|
|
||||||
|
|
||||||
if (commandsVisible) {
|
|
||||||
if (!hasChild(m_commandsBox)) {
|
|
||||||
addChild(m_commandsBox);
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (hasChild(m_commandsBox)) {
|
|
||||||
removeChild(m_commandsBox);
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include "app/color.h"
|
#include "app/color.h"
|
||||||
#include "base/observers.h"
|
#include "base/observers.h"
|
||||||
|
#include "doc/context_observer.h"
|
||||||
#include "doc/layer_index.h"
|
#include "doc/layer_index.h"
|
||||||
#include "ui/base.h"
|
#include "ui/base.h"
|
||||||
#include "ui/link_label.h"
|
#include "ui/link_label.h"
|
||||||
@ -49,7 +50,8 @@ namespace app {
|
|||||||
double m_pos;
|
double m_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StatusBar : public ui::Widget {
|
class StatusBar : public ui::Widget
|
||||||
|
, public doc::ContextObserver {
|
||||||
static StatusBar* m_instance;
|
static StatusBar* m_instance;
|
||||||
public:
|
public:
|
||||||
static StatusBar* instance() { return m_instance; }
|
static StatusBar* instance() { return m_instance; }
|
||||||
@ -69,17 +71,19 @@ namespace app {
|
|||||||
void removeProgress(Progress* progress);
|
void removeProgress(Progress* progress);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onProcessMessage(ui::Message* msg) override;
|
|
||||||
void onResize(ui::ResizeEvent& ev) override;
|
void onResize(ui::ResizeEvent& ev) override;
|
||||||
void onPreferredSize(ui::PreferredSizeEvent& ev) override;
|
void onPreferredSize(ui::PreferredSizeEvent& ev) override;
|
||||||
void onPaint(ui::PaintEvent& ev) override;
|
void onPaint(ui::PaintEvent& ev) override;
|
||||||
|
|
||||||
|
// ContextObserver impl
|
||||||
|
void onSetActiveDocument(doc::Document* document) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onCurrentToolChange();
|
void onCurrentToolChange();
|
||||||
|
void updateFromDocument();
|
||||||
void updateFromLayer();
|
void updateFromLayer();
|
||||||
void updateCurrentFrame();
|
void updateCurrentFrame();
|
||||||
void newFrame();
|
void newFrame();
|
||||||
void updateSubwidgetsVisibility();
|
|
||||||
|
|
||||||
enum State { SHOW_TEXT, SHOW_COLOR, SHOW_TOOL };
|
enum State { SHOW_TEXT, SHOW_COLOR, SHOW_TOOL };
|
||||||
|
|
||||||
|
@ -154,28 +154,27 @@ void UIContext::onAddDocument(doc::Document* doc)
|
|||||||
|
|
||||||
void UIContext::onRemoveDocument(doc::Document* doc)
|
void UIContext::onRemoveDocument(doc::Document* doc)
|
||||||
{
|
{
|
||||||
Context::onRemoveDocument(doc);
|
|
||||||
|
|
||||||
// We don't destroy views in batch mode.
|
// We don't destroy views in batch mode.
|
||||||
if (!isUiAvailable())
|
if (isUiAvailable()) {
|
||||||
return;
|
Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
|
||||||
|
DocumentViews docViews;
|
||||||
|
|
||||||
Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
|
// Collect all views related to the document.
|
||||||
DocumentViews docViews;
|
for (WorkspaceView* view : *workspace) {
|
||||||
|
if (DocumentView* docView = dynamic_cast<DocumentView*>(view)) {
|
||||||
// Collect all views related to the document.
|
if (docView->getDocument() == doc) {
|
||||||
for (WorkspaceView* view : *workspace) {
|
docViews.push_back(docView);
|
||||||
if (DocumentView* docView = dynamic_cast<DocumentView*>(view)) {
|
}
|
||||||
if (docView->getDocument() == doc) {
|
|
||||||
docViews.push_back(docView);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (DocumentView* docView : docViews) {
|
||||||
|
workspace->removeView(docView);
|
||||||
|
delete docView;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DocumentView* docView : docViews) {
|
Context::onRemoveDocument(doc);
|
||||||
workspace->removeView(docView);
|
|
||||||
delete docView;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIContext::onGetActiveLocation(DocumentLocation* location) const
|
void UIContext::onGetActiveLocation(DocumentLocation* location) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user