Minor fixes in style for ButtonSet and StatusBar controls (mini Entry/Slider)

This commit is contained in:
David Capello 2015-04-07 11:29:36 -03:00
parent ae90e8089c
commit 7a3c0a1eed
5 changed files with 30 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -70,8 +70,14 @@ void ButtonSet::Item::onPaint(ui::PaintEvent& ev)
g->fillRect(getBgColor(), g->getClipBounds()); g->fillRect(getBgColor(), g->getClipBounds());
if (isSelected() || hasMouseOver()) { if (isSelected() || hasMouseOver()) {
nw = PART_TOOLBUTTON_HOT_NW; if (hasCapture()) {
face = theme->colors.buttonHotFace(); nw = PART_TOOLBUTTON_PUSHED_NW;
face = theme->colors.buttonSelectedFace();
}
else {
nw = PART_TOOLBUTTON_HOT_NW;
face = theme->colors.buttonHotFace();
}
} }
else { else {
nw = PART_TOOLBUTTON_LAST_NW; nw = PART_TOOLBUTTON_LAST_NW;
@ -85,9 +91,13 @@ void ButtonSet::Item::onPaint(ui::PaintEvent& ev)
theme->draw_bounds_nw(g, rc, nw, face); theme->draw_bounds_nw(g, rc, nw, face);
if (m_icon) { if (m_icon) {
g->drawRgbaSurface(m_icon, int u = rc.x + rc.w/2 - m_icon->width()/2;
rc.x + rc.w/2 - m_icon->width()/2, int v = rc.y + rc.h/2 - m_icon->height()/2 - 1*guiscale();
rc.y + rc.h/2 - m_icon->height()/2 - 1*guiscale());
if (isSelected() && hasCapture())
g->drawColoredRgbaSurface(m_icon, theme->colors.buttonSelectedText(), u, v);
else
g->drawRgbaSurface(m_icon, u, v);
} }
} }
@ -98,6 +108,8 @@ bool ButtonSet::Item::onProcessMessage(ui::Message* msg)
case ui::kMouseDownMessage: case ui::kMouseDownMessage:
captureMouse(); captureMouse();
buttonSet()->setSelectedItem(this); buttonSet()->setSelectedItem(this);
invalidate();
if (!buttonSet()->m_triggerOnMouseUp) if (!buttonSet()->m_triggerOnMouseUp)
buttonSet()->onItemChange(); buttonSet()->onItemChange();
break; break;
@ -105,6 +117,8 @@ bool ButtonSet::Item::onProcessMessage(ui::Message* msg)
case ui::kMouseUpMessage: case ui::kMouseUpMessage:
if (hasCapture()) { if (hasCapture()) {
releaseMouse(); releaseMouse();
invalidate();
if (buttonSet()->m_triggerOnMouseUp) if (buttonSet()->m_triggerOnMouseUp)
buttonSet()->onItemChange(); buttonSet()->onItemChange();
} }

View File

@ -11,6 +11,7 @@
#include "ui/graphics.h" #include "ui/graphics.h"
#include "base/string.h" #include "base/string.h"
#include "gfx/clip.h"
#include "gfx/point.h" #include "gfx/point.h"
#include "gfx/rect.h" #include "gfx/rect.h"
#include "gfx/region.h" #include "gfx/region.h"
@ -148,6 +149,14 @@ void Graphics::drawRgbaSurface(she::Surface* surface, int x, int y)
dst->drawRgbaSurface(src, m_dx+x, m_dy+y); dst->drawRgbaSurface(src, m_dx+x, m_dy+y);
} }
void Graphics::drawColoredRgbaSurface(she::Surface* surface, gfx::Color color, int x, int y)
{
she::ScopedSurfaceLock src(surface);
she::ScopedSurfaceLock dst(m_surface);
dst->drawColoredRgbaSurface(src, color, gfx::ColorNone,
gfx::Clip(m_dx+x, m_dy+y, 0, 0, surface->width(), surface->height()));
}
void Graphics::blit(she::Surface* srcSurface, int srcx, int srcy, int dstx, int dsty, int w, int h) void Graphics::blit(she::Surface* srcSurface, int srcx, int srcy, int dstx, int dsty, int w, int h)
{ {
she::ScopedSurfaceLock src(srcSurface); she::ScopedSurfaceLock src(srcSurface);

View File

@ -67,6 +67,7 @@ namespace ui {
void drawSurface(she::Surface* surface, int x, int y); void drawSurface(she::Surface* surface, int x, int y);
void drawRgbaSurface(she::Surface* surface, int x, int y); void drawRgbaSurface(she::Surface* surface, int x, int y);
void drawColoredRgbaSurface(she::Surface* surface, gfx::Color color, int x, int y);
void blit(she::Surface* src, int srcx, int srcy, int dstx, int dsty, int w, int h); void blit(she::Surface* src, int srcx, int srcy, int dstx, int dsty, int w, int h);

View File

@ -1263,7 +1263,7 @@ void Widget::offerCapture(ui::MouseMessage* mouseMsg, int widget_type)
{ {
if (hasCapture()) { if (hasCapture()) {
Widget* pick = getManager()->pick(mouseMsg->position()); Widget* pick = getManager()->pick(mouseMsg->position());
if (pick && pick->getType() == widget_type) { if (pick && pick != this && pick->getType() == widget_type) {
releaseMouse(); releaseMouse();
MouseMessage* mouseMsg2 = new MouseMessage( MouseMessage* mouseMsg2 = new MouseMessage(