mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 13:21:34 +00:00
Remove unused code from ui::Button
Removed IButtonIcon interface and Button::m_drawType field.
This commit is contained in:
parent
bc01f16a4e
commit
60970b8eae
@ -473,7 +473,6 @@ add_library(app-lib
|
||||
ui/resources_listbox.cpp
|
||||
ui/search_entry.cpp
|
||||
ui/select_accelerator.cpp
|
||||
ui/skin/button_icon_impl.cpp
|
||||
ui/skin/font_data.cpp
|
||||
ui/skin/skin_part.cpp
|
||||
ui/skin/skin_property.cpp
|
||||
|
@ -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.
|
||||
@ -12,7 +12,6 @@
|
||||
|
||||
#include "app/modules/gfx.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/bind.h"
|
||||
#include "doc/image.h"
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include "app/color_utils.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "base/bind.h"
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "app/ui/button_set.h"
|
||||
#include "app/ui/color_button.h"
|
||||
#include "app/ui/icon_button.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "base/bind.h"
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "app/ui/drop_down_button.h"
|
||||
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_property.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "ui/button.h"
|
||||
#include "ui/theme.h"
|
||||
|
||||
namespace app {
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "app/recent_files.h"
|
||||
#include "app/ui/file_list.h"
|
||||
#include "app/ui/file_list_view.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/widget_loader.h"
|
||||
#include "base/bind.h"
|
||||
|
@ -1,61 +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/skin/button_icon_impl.h"
|
||||
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "she/surface.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
|
||||
ButtonIconImpl::ButtonIconImpl(const SkinPartPtr& normalIcon,
|
||||
const SkinPartPtr& selectedIcon,
|
||||
const SkinPartPtr& disabledIcon,
|
||||
int iconAlign)
|
||||
: m_normalIcon(normalIcon)
|
||||
, m_selectedIcon(selectedIcon)
|
||||
, m_disabledIcon(disabledIcon)
|
||||
, m_iconAlign(iconAlign)
|
||||
{
|
||||
}
|
||||
|
||||
void ButtonIconImpl::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
gfx::Size ButtonIconImpl::size()
|
||||
{
|
||||
return m_normalIcon ? m_normalIcon->size(): gfx::Size(0, 0);
|
||||
}
|
||||
|
||||
she::Surface* ButtonIconImpl::normalIcon()
|
||||
{
|
||||
return m_normalIcon ? m_normalIcon->bitmap(0): nullptr;
|
||||
}
|
||||
|
||||
she::Surface* ButtonIconImpl::selectedIcon()
|
||||
{
|
||||
return m_selectedIcon ? m_selectedIcon->bitmap(0): nullptr;
|
||||
}
|
||||
|
||||
she::Surface* ButtonIconImpl::disabledIcon()
|
||||
{
|
||||
return m_disabledIcon ? m_disabledIcon->bitmap(0): nullptr;
|
||||
}
|
||||
|
||||
int ButtonIconImpl::iconAlign()
|
||||
{
|
||||
return m_iconAlign;
|
||||
}
|
||||
|
||||
} // namespace app
|
@ -1,44 +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_SKIN_BUTTON_ICON_IMPL_H_INCLUDED
|
||||
#define APP_UI_SKIN_BUTTON_ICON_IMPL_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/skin/skin_part.h"
|
||||
#include "ui/button.h"
|
||||
|
||||
namespace app {
|
||||
namespace skin {
|
||||
|
||||
class SkinTheme;
|
||||
|
||||
class ButtonIconImpl : public ui::IButtonIcon {
|
||||
public:
|
||||
ButtonIconImpl(const SkinPartPtr& normalIcon,
|
||||
const SkinPartPtr& selectedIcon,
|
||||
const SkinPartPtr& disabledIcon,
|
||||
int iconAlign);
|
||||
|
||||
// IButtonIcon implementation
|
||||
void destroy();
|
||||
gfx::Size size();
|
||||
she::Surface* normalIcon();
|
||||
she::Surface* selectedIcon();
|
||||
she::Surface* disabledIcon();
|
||||
int iconAlign();
|
||||
|
||||
public:
|
||||
SkinPartPtr m_normalIcon;
|
||||
SkinPartPtr m_selectedIcon;
|
||||
SkinPartPtr m_disabledIcon;
|
||||
int m_iconAlign;
|
||||
};
|
||||
|
||||
} // namespace skin
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -15,7 +15,6 @@
|
||||
#include "app/resource_finder.h"
|
||||
#include "app/ui/app_menuitem.h"
|
||||
#include "app/ui/keyboard_shortcuts.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/font_data.h"
|
||||
#include "app/ui/skin/skin_property.h"
|
||||
#include "app/ui/skin/skin_slider_property.h"
|
||||
@ -1613,26 +1612,6 @@ void SkinTheme::paintProgressBar(ui::Graphics* g, const gfx::Rect& rc0, double p
|
||||
g->fillRect(colors.background(), gfx::Rect(rc.x+u, rc.y, rc.w-u, rc.h));
|
||||
}
|
||||
|
||||
void SkinTheme::paintIcon(Widget* widget, Graphics* g, IButtonIcon* iconInterface, int x, int y)
|
||||
{
|
||||
she::Surface* icon_bmp = NULL;
|
||||
|
||||
// enabled
|
||||
if (widget->isEnabled()) {
|
||||
if (widget->isSelected()) // selected
|
||||
icon_bmp = iconInterface->selectedIcon();
|
||||
else
|
||||
icon_bmp = iconInterface->normalIcon();
|
||||
}
|
||||
// disabled
|
||||
else {
|
||||
icon_bmp = iconInterface->disabledIcon();
|
||||
}
|
||||
|
||||
if (icon_bmp)
|
||||
g->drawRgbaSurface(icon_bmp, x, y);
|
||||
}
|
||||
|
||||
std::string SkinTheme::themeFileName(const std::string& skinId,
|
||||
const std::string& fileName) const
|
||||
{
|
||||
|
@ -22,7 +22,6 @@
|
||||
namespace ui {
|
||||
class Entry;
|
||||
class Graphics;
|
||||
class IButtonIcon;
|
||||
}
|
||||
|
||||
namespace she {
|
||||
@ -133,8 +132,6 @@ namespace app {
|
||||
int selected_offset, int mnemonic);
|
||||
void drawEntryText(ui::Graphics* g, ui::Entry* widget);
|
||||
|
||||
void paintIcon(ui::Widget* widget, ui::Graphics* g, ui::IButtonIcon* iconInterface, int x, int y);
|
||||
|
||||
std::string themeFileName(const std::string& skinId,
|
||||
const std::string& fileName) const;
|
||||
|
||||
|
@ -28,8 +28,6 @@ ButtonBase::ButtonBase(const std::string& text,
|
||||
: Widget(type)
|
||||
, m_pressedStatus(false)
|
||||
, m_behaviorType(behaviorType)
|
||||
, m_drawType(drawType)
|
||||
, m_iconInterface(NULL)
|
||||
, m_handleSelect(true)
|
||||
{
|
||||
setAlign(CENTER | MIDDLE);
|
||||
@ -37,15 +35,13 @@ ButtonBase::ButtonBase(const std::string& text,
|
||||
setFocusStop(true);
|
||||
|
||||
// Initialize theme
|
||||
setType(m_drawType); // TODO Fix this nasty trick
|
||||
setType(drawType); // TODO Fix this nasty trick
|
||||
initTheme();
|
||||
setType(type);
|
||||
}
|
||||
|
||||
ButtonBase::~ButtonBase()
|
||||
{
|
||||
if (m_iconInterface)
|
||||
m_iconInterface->destroy();
|
||||
}
|
||||
|
||||
WidgetType ButtonBase::behaviorType() const
|
||||
@ -53,21 +49,6 @@ WidgetType ButtonBase::behaviorType() const
|
||||
return m_behaviorType;
|
||||
}
|
||||
|
||||
WidgetType ButtonBase::drawType() const
|
||||
{
|
||||
return m_drawType;
|
||||
}
|
||||
|
||||
void ButtonBase::setIconInterface(IButtonIcon* iconInterface)
|
||||
{
|
||||
if (m_iconInterface)
|
||||
m_iconInterface->destroy();
|
||||
|
||||
m_iconInterface = iconInterface;
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void ButtonBase::onClick(Event& ev)
|
||||
{
|
||||
// Fire Click() signal
|
||||
@ -270,34 +251,6 @@ bool ButtonBase::onProcessMessage(Message* msg)
|
||||
return Widget::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
void ButtonBase::onSizeHint(SizeHintEvent& ev)
|
||||
{
|
||||
// If there is a style specified in this widget, use the new generic
|
||||
// widget to calculate the size hint.
|
||||
if (style())
|
||||
return Widget::onSizeHint(ev);
|
||||
|
||||
gfx::Rect box;
|
||||
gfx::Size iconSize = (m_iconInterface ? m_iconInterface->size(): gfx::Size(0, 0));
|
||||
getTextIconInfo(&box, NULL, NULL,
|
||||
m_iconInterface ? m_iconInterface->iconAlign(): 0,
|
||||
iconSize.w,
|
||||
iconSize.h);
|
||||
|
||||
ev.setSizeHint(box.w + border().width(),
|
||||
box.h + border().height());
|
||||
}
|
||||
|
||||
void ButtonBase::onPaint(PaintEvent& ev)
|
||||
{
|
||||
// If there is a style specified in this widget, use the new generic
|
||||
// widget painting code.
|
||||
if (style())
|
||||
return Widget::onPaint(ev);
|
||||
|
||||
ASSERT(false);
|
||||
}
|
||||
|
||||
void ButtonBase::generateButtonSelectSignal()
|
||||
{
|
||||
// Deselect
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -21,17 +21,6 @@ namespace ui {
|
||||
|
||||
class Event;
|
||||
|
||||
class IButtonIcon {
|
||||
public:
|
||||
virtual ~IButtonIcon() { }
|
||||
virtual void destroy() = 0;
|
||||
virtual gfx::Size size() = 0;
|
||||
virtual she::Surface* normalIcon() = 0;
|
||||
virtual she::Surface* selectedIcon() = 0;
|
||||
virtual she::Surface* disabledIcon() = 0;
|
||||
virtual int iconAlign() = 0;
|
||||
};
|
||||
|
||||
// Generic button
|
||||
class ButtonBase : public Widget {
|
||||
public:
|
||||
@ -42,23 +31,12 @@ namespace ui {
|
||||
virtual ~ButtonBase();
|
||||
|
||||
WidgetType behaviorType() const;
|
||||
WidgetType drawType() const;
|
||||
|
||||
// Sets the interface used to get icons for the button depending its
|
||||
// state. This interface is deleted automatically in the ButtonBase dtor.
|
||||
void setIconInterface(IButtonIcon* iconInterface);
|
||||
|
||||
// Used by the current theme to draw the button icon.
|
||||
IButtonIcon* iconInterface() const { return m_iconInterface; }
|
||||
|
||||
// Signals
|
||||
obs::signal<void(Event&)> Click;
|
||||
|
||||
protected:
|
||||
// Events
|
||||
bool onProcessMessage(Message* msg) override;
|
||||
void onSizeHint(SizeHintEvent& ev) override;
|
||||
void onPaint(PaintEvent& ev) override;
|
||||
|
||||
// New events
|
||||
virtual void onClick(Event& ev);
|
||||
@ -68,8 +46,6 @@ namespace ui {
|
||||
|
||||
bool m_pressedStatus;
|
||||
WidgetType m_behaviorType;
|
||||
WidgetType m_drawType;
|
||||
IButtonIcon* m_iconInterface;
|
||||
|
||||
protected:
|
||||
bool m_handleSelect;
|
||||
|
Loading…
x
Reference in New Issue
Block a user