mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 12:39:57 +00:00
Now when you pass the mouse over a tool button, the tool name and shortcut are shown in the status bar.
Added StatusBar::showTool().
This commit is contained in:
parent
e12fd03b7b
commit
d79d29c1a5
@ -146,9 +146,10 @@ void StatusBar::onCurrentToolChange()
|
||||
{
|
||||
if (jwidget_is_visible(this)) {
|
||||
Tool* currentTool = UIContext::instance()->getSettings()->getCurrentTool();
|
||||
if (currentTool)
|
||||
this->setStatusText(500, "%s selected",
|
||||
currentTool->getText().c_str());
|
||||
if (currentTool) {
|
||||
this->showTool(500, currentTool);
|
||||
this->setTextf("%s Selected", currentTool->getText().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,6 +224,30 @@ void StatusBar::showColor(int msecs, const char* text, color_t color, int alpha)
|
||||
}
|
||||
}
|
||||
|
||||
void StatusBar::showTool(int msecs, Tool* tool)
|
||||
{
|
||||
assert(tool != NULL);
|
||||
|
||||
// Tool name
|
||||
std::string text = tool->getText();
|
||||
|
||||
// Tool shortcut
|
||||
JAccel accel = get_accel_to_change_tool(tool);
|
||||
if (accel) {
|
||||
char buf[512]; // TODO possible buffer overflow
|
||||
jaccel_to_string(accel, buf);
|
||||
text += ", Shortcut: ";
|
||||
text += buf;
|
||||
}
|
||||
|
||||
// Set text
|
||||
if (setStatusText(msecs, text.c_str())) {
|
||||
// Show tool
|
||||
m_state = SHOW_TOOL;
|
||||
m_tool = tool;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Progress bars stuff
|
||||
|
||||
@ -355,6 +380,19 @@ bool StatusBar::msg_proc(JMessage msg)
|
||||
x += ji_font_text_len(this->getFont(), buf) + 4*jguiscale();
|
||||
}
|
||||
|
||||
// Show tool
|
||||
if (m_state == SHOW_TOOL) {
|
||||
// Draw eyedropper icon
|
||||
BITMAP* icon = theme->get_toolicon(m_tool->getId().c_str());
|
||||
if (icon) {
|
||||
set_alpha_blender();
|
||||
draw_trans_sprite(doublebuffer, icon,
|
||||
x, (rc->y1+rc->y2)/2-icon->h/2);
|
||||
}
|
||||
|
||||
x += icon->w + 4*jguiscale();
|
||||
}
|
||||
|
||||
// Status bar text
|
||||
if (this->getTextSize() > 0) {
|
||||
textout_ex(doublebuffer, this->getFont(), this->getText(),
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
class Frame;
|
||||
class StatusBar;
|
||||
class Tool;
|
||||
|
||||
class Progress
|
||||
{
|
||||
@ -52,6 +53,7 @@ public:
|
||||
bool setStatusText(int msecs, const char *format, ...);
|
||||
void showTip(int msecs, const char *format, ...);
|
||||
void showColor(int msecs, const char* text, color_t color, int alpha);
|
||||
void showTool(int msecs, Tool* tool);
|
||||
|
||||
Progress* addProgress();
|
||||
void removeProgress(Progress* progress);
|
||||
@ -63,11 +65,14 @@ private:
|
||||
void onCurrentToolChange();
|
||||
void updateFromLayer();
|
||||
|
||||
enum State { SHOW_TEXT, SHOW_COLOR };
|
||||
enum State { SHOW_TEXT, SHOW_COLOR, SHOW_TOOL };
|
||||
|
||||
int m_timeout;
|
||||
State m_state;
|
||||
|
||||
// Showing a tool
|
||||
Tool* m_tool;
|
||||
|
||||
// Showing a color
|
||||
color_t m_color;
|
||||
int m_alpha;
|
||||
|
@ -28,14 +28,15 @@
|
||||
#include "Vaca/Size.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "ui_context.h"
|
||||
#include "commands/commands.h"
|
||||
#include "commands/command.h"
|
||||
#include "commands/commands.h"
|
||||
#include "modules/gfx.h"
|
||||
#include "modules/gui.h"
|
||||
#include "modules/skinneable_theme.h"
|
||||
#include "tools/toolbox.h"
|
||||
#include "ui_context.h"
|
||||
#include "widgets/groupbut.h"
|
||||
#include "widgets/statebar.h"
|
||||
#include "widgets/toolbar.h"
|
||||
|
||||
using Vaca::Size;
|
||||
@ -326,6 +327,9 @@ bool ToolBar::msg_proc(JMessage msg)
|
||||
openTipWindow(tip_index, m_hot_tool);
|
||||
else
|
||||
closeTipWindow();
|
||||
|
||||
if (m_hot_tool)
|
||||
app_get_statusbar()->showTool(0, m_hot_tool);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -667,6 +671,9 @@ bool ToolStrip::msg_proc(JMessage msg)
|
||||
m_toolbar->openTipWindow(m_group, m_hot_tool);
|
||||
else
|
||||
m_toolbar->closeTipWindow();
|
||||
|
||||
if (m_hot_tool)
|
||||
app_get_statusbar()->showTool(0, m_hot_tool);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user