Merge branch 'dev' of git@github.com:aseprite/aseprite.git into dev

This commit is contained in:
David Capello 2014-04-17 16:24:53 -03:00
commit d3591ffdf7
16 changed files with 49 additions and 69 deletions

View File

@ -91,11 +91,11 @@ void AboutCommand::onExecute(Context* context)
box1->addChild(grid);
window->addChild(box1);
jwidget_set_border(close_button,
close_button->border_width.l + 16*jguiscale(),
close_button->border_width.t,
close_button->border_width.r + 16*jguiscale(),
close_button->border_width.b);
close_button->setBorder(gfx::Border(
close_button->border_width.l + 16*jguiscale(),
close_button->border_width.t,
close_button->border_width.r + 16*jguiscale(),
close_button->border_width.b));
close_button->Click.connect(Bind<void>(&Window::closeWindow, window.get(), close_button));

View File

@ -46,7 +46,7 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
{
#define ADD(box, widget, hook) \
if (widget) { \
jwidget_set_border(widget, 2 * jguiscale()); \
widget->setBorder(gfx::Border(2 * jguiscale())); \
box->addChild(widget); \
widget->Click.connect(Bind<void>(&FilterTargetButtons::hook, this, widget)); \
}
@ -62,8 +62,8 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
hbox = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
jwidget_noborders(this);
jwidget_noborders(hbox);
this->noBorderNoChildSpacing();
hbox->noBorderNoChildSpacing();
if (withChannels) {
switch (imgtype) {

View File

@ -70,12 +70,12 @@ ButtonSet::ButtonSet(int w, int h, int firstSelected, ...)
va_start(ap, firstSelected);
jwidget_noborders(this);
this->noBorderNoChildSpacing();
for (y=0; y<h; y++) {
if (w > 1) {
hbox = new Box(JI_HORIZONTAL | JI_HOMOGENEOUS);
jwidget_noborders(hbox);
hbox->noBorderNoChildSpacing();
}
for (x=0; x<w; x++) {

View File

@ -56,7 +56,7 @@ ColorBar::ScrollableView::ScrollableView()
int r = theme->get_part(PART_EDITOR_SELECTED_E)->w;
int b = theme->get_part(PART_EDITOR_SELECTED_S)->h;
jwidget_set_border(this, l, t, r, b);
setBorder(gfx::Border(l, t, r, b));
}
void ColorBar::ScrollableView::onPaint(ui::PaintEvent& ev)

View File

@ -48,7 +48,7 @@ EditorView::EditorView(EditorView::Type type)
int r = theme->get_part(PART_EDITOR_SELECTED_E)->w;
int b = theme->get_part(PART_EDITOR_SELECTED_S)->h;
jwidget_set_border(this, l, t, r, b);
setBorder(gfx::Border(l, t, r, b));
setupScrollbars();
UIContext::instance()->settings()->addObserver(this);

View File

@ -183,7 +183,7 @@ StatusBar::StatusBar()
// The extra pixel in left and right borders are necessary so
// m_commandsBox and m_movePixelsBox do not overlap the upper-left
// and upper-right pixels drawn in onPaint() event (see putpixels)
jwidget_set_border(this, 1*jguiscale(), 0, 1*jguiscale(), 0);
setBorder(gfx::Border(1*jguiscale(), 0, 1*jguiscale(), 0));
// Construct the commands box
{
@ -209,9 +209,9 @@ StatusBar::StatusBar()
m_slider->Change.connect(Bind<void>(&slider_change_hook, m_slider));
jwidget_set_min_size(m_slider, JI_SCREEN_W/5, 0);
jwidget_set_border(box1, 2*jguiscale(), 1*jguiscale(), 2*jguiscale(), 2*jguiscale());
jwidget_noborders(box2);
jwidget_noborders(box3);
box1->setBorder(gfx::Border(2, 1, 2, 2)*jguiscale());
box2->noBorderNoChildSpacing();
box3->noBorderNoChildSpacing();
box3->setExpansive(true);
box4->addChild(m_currentFrame);
@ -236,8 +236,8 @@ StatusBar::StatusBar()
Box* box1 = new Box(JI_HORIZONTAL);
Box* box2 = new Box(JI_VERTICAL);
jwidget_set_border(box1, 2*jguiscale(), 1*jguiscale(), 2*jguiscale(), 2*jguiscale());
jwidget_noborders(box2);
box1->setBorder(gfx::Border(2, 1, 2, 2)*jguiscale());
box2->noBorderNoChildSpacing();
box2->setExpansive(true);
m_linkLabel = new LinkLabel((std::string(WEBSITE) + "donate/").c_str(), "Support This Project");

View File

@ -430,7 +430,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
widget->setFocusMagnet(true);
if (noborders)
jwidget_noborders(widget);
widget->noBorderNoChildSpacing();
if (childspacing)
widget->child_spacing = ustrtol(childspacing, NULL, 10);

View File

@ -11,7 +11,7 @@
namespace she {
class EventQueue;
class NotDisposableSurface;
class NonDisposableSurface;
class Surface;
// A display or window to show graphics.
@ -35,7 +35,7 @@ namespace she {
// Returns the main surface to draw into this display.
// You must not dispose this surface.
virtual NotDisposableSurface* getSurface() = 0;
virtual NonDisposableSurface* getSurface() = 0;
// Flips all graphics in the surface to the real display. Returns
// false if the flip couldn't be done because the display was

View File

@ -318,8 +318,8 @@ public:
m_surface = newSurface;
}
NotDisposableSurface* getSurface() OVERRIDE {
return static_cast<NotDisposableSurface*>(m_surface);
NonDisposableSurface* getSurface() OVERRIDE {
return static_cast<NonDisposableSurface*>(m_surface);
}
bool flip() OVERRIDE {

View File

@ -22,9 +22,9 @@ namespace she {
virtual void* nativeHandle() = 0;
};
class NotDisposableSurface : public Surface {
class NonDisposableSurface : public Surface {
public:
virtual ~NotDisposableSurface() { }
virtual ~NonDisposableSurface() { }
private:
virtual void dispose() = 0;
};

View File

@ -191,8 +191,8 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
box4->setExpansive(true);
box5->setExpansive(true);
jwidget_noborders(box4);
jwidget_noborders(box5);
box4->noBorderNoChildSpacing();
box5->noBorderNoChildSpacing();
// Setup parent <-> children relationship

View File

@ -502,7 +502,7 @@ void ComboBox::openListBox()
View* view = new View();
m_listbox = new ComboBoxListBox(this);
m_window->setOnTop(true);
jwidget_noborders(m_window);
m_window->noBorderNoChildSpacing();
Widget* viewport = view->getViewport();
int size = getItemCount();

View File

@ -12,8 +12,10 @@
#include <allegro/gfx.h>
#include "ui/draw.h"
#include "ui/graphics.h"
#include "ui/image_view.h"
#include "ui/message.h"
#include "ui/paint_event.h"
#include "ui/preferred_size_event.h"
#include "ui/system.h"
#include "ui/theme.h"
@ -38,13 +40,18 @@ void ImageView::onPreferredSize(PreferredSizeEvent& ev)
void ImageView::onPaint(PaintEvent& ev)
{
Graphics* g = ev.getGraphics();
gfx::Rect bounds = getClientBounds();
gfx::Rect icon;
jwidget_get_texticon_info(this, NULL, NULL, &icon,
getAlign(), m_bmp->w, m_bmp->h);
jdraw_rectexclude(getBounds(), icon, getBgColor());
g->fillRect(getBgColor(), bounds);
blit(m_bmp, ji_screen, 0, 0, icon.x, icon.y, icon.w, icon.h);
icon.x -= getBounds().x;
icon.y -= getBounds().y;
g->blit(m_bmp, 0, 0, icon.x, icon.y, icon.w, icon.h);
}
} // namespace ui

View File

@ -34,7 +34,7 @@ PopupWindow::PopupWindow(const base::string& text, ClickBehavior clickBehavior)
removeDecorativeWidgets();
initTheme();
jwidget_noborders(this);
noBorderNoChildSpacing();
}
PopupWindow::~PopupWindow()

View File

@ -617,6 +617,15 @@ void Widget::setBorder(const Border& br)
border_width.b = br.bottom();
}
void Widget::noBorderNoChildSpacing()
{
border_width.l = 0;
border_width.t = 0;
border_width.r = 0;
border_width.b = 0;
child_spacing = 0;
}
void Widget::getRegion(gfx::Region& region)
{
if (this->type == kWindowWidget)
@ -838,41 +847,6 @@ void jwidget_get_texticon_info(Widget* widget,
SETRECT(icon);
}
void jwidget_noborders(Widget* widget)
{
widget->border_width.l = 0;
widget->border_width.t = 0;
widget->border_width.r = 0;
widget->border_width.b = 0;
widget->child_spacing = 0;
widget->invalidate();
}
void jwidget_set_border(Widget* widget, int value)
{
ASSERT_VALID_WIDGET(widget);
widget->border_width.l = value;
widget->border_width.t = value;
widget->border_width.r = value;
widget->border_width.b = value;
widget->invalidate();
}
void jwidget_set_border(Widget* widget, int l, int t, int r, int b)
{
ASSERT_VALID_WIDGET(widget);
widget->border_width.l = l;
widget->border_width.t = t;
widget->border_width.r = r;
widget->border_width.b = b;
widget->invalidate();
}
void jwidget_set_min_size(Widget* widget, int w, int h)
{
ASSERT_VALID_WIDGET(widget);

View File

@ -51,9 +51,6 @@ namespace ui {
gfx::Rect* icon,
int icon_align, int icon_w, int icon_h);
void jwidget_noborders(Widget* widget);
void jwidget_set_border(Widget* widget, int value);
void jwidget_set_border(Widget* widget, int l, int t, int r, int b);
void jwidget_set_min_size(Widget* widget, int w, int h);
void jwidget_set_max_size(Widget* widget, int w, int h);
@ -277,6 +274,8 @@ namespace ui {
gfx::Border getBorder() const;
void setBorder(const gfx::Border& border);
void noBorderNoChildSpacing();
// Flags for getDrawableRegion()
enum DrawableRegionFlags {
kCutTopWindows = 1, // Cut areas where are windows on top.