Convert flag and warning_box to new styles

This commit is contained in:
David Capello 2017-03-13 14:14:29 -03:00
parent ca2aae6349
commit e2311392b8
7 changed files with 30 additions and 135 deletions

View File

@ -642,26 +642,6 @@
<background part="timeline_loop_range" />
</style>
<!-- flag -->
<style id="flag">
<background part="flag_normal" color="flag_normal" />
</style>
<style id="flag:active">
<background part="flag_highlight" color="flag_active" />
</style>
<style id="flag:clicked">
<background part="flag_highlight" color="flag_clicked" />
</style>
<!-- warning_box -->
<style id="warning_box">
<background color="workspace" />
<icon part="warning_box" align="center" valign="middle" />
</style>
<style id="warning_box:hover">
<background color="hot_face" />
</style>
</stylesheet>
<styles>
@ -991,6 +971,18 @@
<icon part="tab_home_icon_active" align="left middle" x="4" y="1" state="focus" />
</style>
<style id="flag">
<background part="flag_normal" color="flag_normal" />
<background part="flag_highlight" color="flag_active" state="focus" />
<background part="flag_highlight" color="flag_clicked" state="selected" />
</style>
<style id="warning_box" padding-left="2" padding-right="2">
<background color="workspace" />
<background color="hot_face" state="mouse" />
<icon part="warning_box" align="center middle" />
</style>
</styles>
</theme>

View File

@ -488,7 +488,6 @@ add_library(app-lib
ui/skin/style_sheet.cpp
ui/slice_window.cpp
ui/status_bar.cpp
ui/styled_button.cpp
ui/tabs.cpp
ui/timeline.cpp
ui/toolbar.cpp

View File

@ -38,7 +38,6 @@
#include "app/ui/palette_popup.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/status_bar.h"
#include "app/ui/styled_button.h"
#include "app/ui_context.h"
#include "app/ui_context.h"
#include "app/util/clipboard.h"
@ -82,18 +81,10 @@ enum class PalButton {
using namespace app::skin;
using namespace ui;
class ColorBar::WarningIcon : public StyledButton {
class ColorBar::WarningIcon : public ui::Button {
public:
WarningIcon()
: StyledButton(skin::SkinTheme::instance()->styles.warningBox()) {
}
protected:
void onPaint(ui::PaintEvent& ev) override {
// if (isEnabled())
StyledButton::onPaint(ev);
// else
// ev.graphics()->fillRect(getBgColor(), clientBounds());
WarningIcon() : ui::Button(std::string()) {
setStyle(skin::SkinTheme::instance()->newStyles.warningBox());
}
};

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -41,7 +41,7 @@ private:
Notifications::Notifications()
: Button("")
, m_flagStyle(skin::SkinTheme::instance()->styles.flag())
, m_flagStyle(skin::SkinTheme::instance()->newStyles.flag())
, m_withNotifications(false)
{
}
@ -61,11 +61,13 @@ void Notifications::onPaint(PaintEvent& ev)
{
Graphics* g = ev.graphics();
skin::Style::State state;
if (hasMouseOver()) state += skin::Style::hover();
if (m_withNotifications) state += skin::Style::active();
if (isSelected()) state += skin::Style::clicked();
m_flagStyle->paint(g, clientBounds(), NULL, state);
PaintWidgetPartInfo info;
if (hasMouseOver()) info.styleFlags |= ui::Style::Layer::kMouse;
if (m_withNotifications) info.styleFlags |= ui::Style::Layer::kFocus;
if (isSelected()) info.styleFlags |= ui::Style::Layer::kSelected;
theme()->paintWidgetPart(
g, m_flagStyle, clientBounds(), info);
}
void Notifications::onClick(ui::Event& ev)

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -11,11 +11,11 @@
#include "ui/button.h"
#include "ui/menu.h"
namespace app {
namespace skin {
class Style;
}
namespace ui {
class Style;
}
namespace app {
class INotificationDelegate;
class Notifications : public ui::Button {
@ -30,7 +30,7 @@ namespace app {
void onClick(ui::Event& ev) override;
private:
skin::Style* m_flagStyle;
ui::Style* m_flagStyle;
bool m_withNotifications;
ui::Menu m_popup;
};

View File

@ -1,55 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/ui/styled_button.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/skin/style.h"
#include "ui/message.h"
#include "ui/paint_event.h"
#include "ui/size_hint_event.h"
#include "ui/system.h"
namespace app {
using namespace ui;
StyledButton::StyledButton(skin::Style* style)
: Button("")
, m_style(style)
{
}
bool StyledButton::onProcessMessage(Message* msg) {
switch (msg->type()) {
case kSetCursorMessage:
if (isEnabled()) {
ui::set_mouse_cursor(kHandCursor);
return true;
}
break;
}
return Button::onProcessMessage(msg);
}
void StyledButton::onSizeHint(SizeHintEvent& ev) {
ev.setSizeHint(
m_style->sizeHint(NULL, skin::Style::State()) + 4*guiscale());
}
void StyledButton::onPaint(PaintEvent& ev) {
Graphics* g = ev.graphics();
skin::Style::State state;
if (hasMouse()) state += skin::Style::hover();
if (isSelected()) state += skin::Style::clicked();
m_style->paint(g, clientBounds(), NULL, state);
}
} // namespace app

View File

@ -1,34 +0,0 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_UI_STYLED_BUTTON_H_INCLUDED
#define APP_UI_STYLED_BUTTON_H_INCLUDED
#pragma once
#include "ui/button.h"
namespace app {
namespace skin {
class Style;
}
class StyledButton : public ui::Button {
public:
StyledButton(skin::Style* style);
protected:
bool onProcessMessage(ui::Message* msg) override;
void onSizeHint(ui::SizeHintEvent& ev) override;
void onPaint(ui::PaintEvent& ev) override;
private:
skin::Style* m_style;
};
} // namespace app
#endif