mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Add text entry to go to frame in the status bar (issue #6).
+ Added a button to create new frames in the status bar.
This commit is contained in:
parent
b97fb14e0a
commit
917f724861
Binary file not shown.
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.7 KiB |
@ -83,6 +83,8 @@
|
||||
<part id="sunken_focused" x="0" y="48" w1="4" w2="4" w3="4" h1="4" h2="4" h3="4" />
|
||||
<part id="sunken2_normal" x="0" y="64" w1="5" w2="6" w3="5" h1="5" h2="6" h3="5" />
|
||||
<part id="sunken2_focused" x="0" y="80" w1="5" w2="6" w3="5" h1="5" h2="6" h3="5" />
|
||||
<part id="sunken_mini_normal" x="16" y="64" w1="4" w2="4" w3="4" h1="4" h2="4" h3="4" />
|
||||
<part id="sunken_mini_focused" x="16" y="80" w1="4" w2="4" w3="4" h1="4" h2="4" h3="4" />
|
||||
<part id="window" x="0" y="0" w1="3" w2="7" w3="3" h1="15" h2="4" h3="5" />
|
||||
<part id="menu" x="0" y="96" w1="3" w2="10" w3="3" h1="3" h2="9" h3="4" />
|
||||
<part id="window_close_button_normal" x="16" y= "0" w="9" h="11" />
|
||||
|
@ -120,6 +120,24 @@ enum {
|
||||
PART_SUNKEN2_FOCUSED_SW,
|
||||
PART_SUNKEN2_FOCUSED_W,
|
||||
|
||||
PART_SUNKEN_MINI_NORMAL_NW,
|
||||
PART_SUNKEN_MINI_NORMAL_N,
|
||||
PART_SUNKEN_MINI_NORMAL_NE,
|
||||
PART_SUNKEN_MINI_NORMAL_E,
|
||||
PART_SUNKEN_MINI_NORMAL_SE,
|
||||
PART_SUNKEN_MINI_NORMAL_S,
|
||||
PART_SUNKEN_MINI_NORMAL_SW,
|
||||
PART_SUNKEN_MINI_NORMAL_W,
|
||||
|
||||
PART_SUNKEN_MINI_FOCUSED_NW,
|
||||
PART_SUNKEN_MINI_FOCUSED_N,
|
||||
PART_SUNKEN_MINI_FOCUSED_NE,
|
||||
PART_SUNKEN_MINI_FOCUSED_E,
|
||||
PART_SUNKEN_MINI_FOCUSED_SE,
|
||||
PART_SUNKEN_MINI_FOCUSED_S,
|
||||
PART_SUNKEN_MINI_FOCUSED_SW,
|
||||
PART_SUNKEN_MINI_FOCUSED_W,
|
||||
|
||||
PART_WINDOW_NW,
|
||||
PART_WINDOW_N,
|
||||
PART_WINDOW_NE,
|
||||
|
@ -113,6 +113,8 @@ SkinTheme::SkinTheme()
|
||||
sheet_mapping["sunken_focused"] = PART_SUNKEN_FOCUSED_NW;
|
||||
sheet_mapping["sunken2_normal"] = PART_SUNKEN2_NORMAL_NW;
|
||||
sheet_mapping["sunken2_focused"] = PART_SUNKEN2_FOCUSED_NW;
|
||||
sheet_mapping["sunken_mini_normal"] = PART_SUNKEN_MINI_NORMAL_NW;
|
||||
sheet_mapping["sunken_mini_focused"] = PART_SUNKEN_MINI_FOCUSED_NW;
|
||||
sheet_mapping["window"] = PART_WINDOW_NW;
|
||||
sheet_mapping["menu"] = PART_MENU_NW;
|
||||
sheet_mapping["window_close_button_normal"] = PART_WINDOW_CLOSE_BUTTON_NORMAL;
|
||||
@ -892,10 +894,16 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
||||
|
||||
bg = COLOR_BACKGROUND;
|
||||
|
||||
bool isMiniLook = false;
|
||||
SharedPtr<SkinProperty> skinPropery = widget->getProperty(SkinProperty::SkinPropertyName);
|
||||
if (skinPropery != NULL)
|
||||
isMiniLook = (skinPropery->getLook() == MiniLook);
|
||||
|
||||
draw_bounds_nw(ji_screen,
|
||||
x1, y1, x2, y2,
|
||||
widget->hasFocus() ? PART_SUNKEN_FOCUSED_NW:
|
||||
PART_SUNKEN_NORMAL_NW, bg);
|
||||
(widget->hasFocus() ?
|
||||
(isMiniLook ? PART_SUNKEN_MINI_FOCUSED_NW: PART_SUNKEN_FOCUSED_NW):
|
||||
(isMiniLook ? PART_SUNKEN_MINI_NORMAL_NW : PART_SUNKEN_NORMAL_NW)), bg);
|
||||
|
||||
/* draw the text */
|
||||
x = widget->rc->x1 + widget->border_width.l;
|
||||
|
@ -71,6 +71,42 @@ static int statusbar_type()
|
||||
return type;
|
||||
}
|
||||
|
||||
// This widget is used to show the current frame.
|
||||
class GotoFrameEntry : public Entry {
|
||||
public:
|
||||
GotoFrameEntry() : Entry(4, "") {
|
||||
}
|
||||
|
||||
bool onProcessMessage(Message* msg) OVERRIDE {
|
||||
switch (msg->type) {
|
||||
// When the mouse enter in this entry, it got the focus and the
|
||||
// text is automatically selected.
|
||||
case JM_MOUSEENTER:
|
||||
requestFocus();
|
||||
selectText(0, -1);
|
||||
break;
|
||||
|
||||
case JM_KEYPRESSED:
|
||||
if (msg->key.scancode == KEY_ENTER ||
|
||||
msg->key.scancode == KEY_ENTER_PAD) {
|
||||
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::GotoFrame);
|
||||
Params params;
|
||||
int frame = strtol(this->getText(), NULL, 10);
|
||||
if (frame > 0) {
|
||||
params.set("frame", this->getText());
|
||||
UIContext::instance()->executeCommand(cmd, ¶ms);
|
||||
}
|
||||
// Select the text again
|
||||
selectText(0, -1);
|
||||
return true; // Key used.
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Entry::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
StatusBar::StatusBar()
|
||||
: Widget(statusbar_type())
|
||||
, m_color(Color::fromMask())
|
||||
@ -106,9 +142,15 @@ StatusBar::StatusBar()
|
||||
Box* box1 = new Box(JI_HORIZONTAL);
|
||||
Box* box2 = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
Box* box3 = new Box(JI_HORIZONTAL);
|
||||
Box* box4 = new Box(JI_HORIZONTAL);
|
||||
m_slider = new Slider(0, 255, 255);
|
||||
m_currentFrame = new GotoFrameEntry();
|
||||
m_newFrame = new Button("+");
|
||||
m_newFrame->Click.connect(Bind<void>(&StatusBar::newFrame, this));
|
||||
|
||||
setup_mini_look(m_slider);
|
||||
setup_mini_look(m_currentFrame);
|
||||
setup_mini_look(m_newFrame);
|
||||
|
||||
ICON_NEW(m_b_first, PART_ANI_FIRST, ACTION_FIRST);
|
||||
ICON_NEW(m_b_prev, PART_ANI_PREVIOUS, ACTION_PREV);
|
||||
@ -124,6 +166,9 @@ StatusBar::StatusBar()
|
||||
jwidget_noborders(box3);
|
||||
jwidget_expansive(box3, true);
|
||||
|
||||
box4->addChild(m_currentFrame);
|
||||
box4->addChild(m_newFrame);
|
||||
|
||||
box2->addChild(m_b_first);
|
||||
box2->addChild(m_b_prev);
|
||||
box2->addChild(m_b_play);
|
||||
@ -131,6 +176,7 @@ StatusBar::StatusBar()
|
||||
box2->addChild(m_b_last);
|
||||
|
||||
box1->addChild(box3);
|
||||
box1->addChild(box4);
|
||||
box1->addChild(box2);
|
||||
box1->addChild(m_slider);
|
||||
|
||||
@ -219,6 +265,9 @@ void StatusBar::clearText()
|
||||
|
||||
bool StatusBar::setStatusText(int msecs, const char *format, ...)
|
||||
{
|
||||
// TODO this call should be in a listener of the "current frame" property changes.
|
||||
updateCurrentFrame();
|
||||
|
||||
if ((ji_clock > m_timeout) || (msecs > 0)) {
|
||||
char buf[256]; // TODO warning buffer overflow
|
||||
va_list ap;
|
||||
@ -606,10 +655,13 @@ bool StatusBar::onProcessMessage(Message* msg)
|
||||
}
|
||||
|
||||
case JM_MOUSEENTER: {
|
||||
bool state = (UIContext::instance()->getActiveDocument() != NULL);
|
||||
const Document* document = UIContext::instance()->getActiveDocument();
|
||||
bool state = (document != NULL);
|
||||
|
||||
if (!hasChild(m_movePixelsBox)) {
|
||||
if (state && !hasChild(m_commandsBox)) {
|
||||
updateCurrentFrame();
|
||||
|
||||
m_b_first->setEnabled(state);
|
||||
m_b_prev->setEnabled(state);
|
||||
m_b_play->setEnabled(state);
|
||||
@ -830,3 +882,17 @@ void StatusBar::updateFromLayer()
|
||||
m_slider->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void StatusBar::updateCurrentFrame()
|
||||
{
|
||||
const Document* document = UIContext::instance()->getActiveDocument();
|
||||
if (document)
|
||||
m_currentFrame->setTextf("%d", document->getSprite()->getCurrentFrame()+1);
|
||||
}
|
||||
|
||||
void StatusBar::newFrame()
|
||||
{
|
||||
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::NewFrame);
|
||||
UIContext::instance()->executeCommand(cmd);
|
||||
updateCurrentFrame();
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
class Box;
|
||||
class Button;
|
||||
class ColorButton;
|
||||
class Entry;
|
||||
class Frame;
|
||||
class Slider;
|
||||
class StatusBar;
|
||||
@ -99,6 +100,8 @@ private:
|
||||
void onCurrentToolChange();
|
||||
void onTransparentColorChange();
|
||||
void updateFromLayer();
|
||||
void updateCurrentFrame();
|
||||
void newFrame();
|
||||
|
||||
enum State { SHOW_TEXT, SHOW_COLOR, SHOW_TOOL };
|
||||
|
||||
@ -119,12 +122,14 @@ private:
|
||||
|
||||
// Box of main commands
|
||||
Widget* m_commandsBox;
|
||||
Slider* m_slider; // Opacity slider
|
||||
Button* m_b_first; // Go to first frame
|
||||
Button* m_b_prev; // Go to previous frame
|
||||
Button* m_b_play; // Play animation
|
||||
Button* m_b_next; // Go to next frame
|
||||
Button* m_b_last; // Go to last frame
|
||||
Slider* m_slider; // Opacity slider
|
||||
Entry* m_currentFrame; // Current frame and go to frame entry
|
||||
Button* m_newFrame; // Button to create a new frame
|
||||
Button* m_b_first; // Go to first frame
|
||||
Button* m_b_prev; // Go to previous frame
|
||||
Button* m_b_play; // Play animation
|
||||
Button* m_b_next; // Go to next frame
|
||||
Button* m_b_last; // Go to last frame
|
||||
|
||||
// Box of notifications.
|
||||
Widget* m_notificationsBox;
|
||||
|
Loading…
x
Reference in New Issue
Block a user