mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 01:20:17 +00:00
Change scrollbar to new theme styles
This commit is contained in:
parent
36ee5a39c8
commit
aabdb11779
@ -411,42 +411,6 @@
|
||||
|
||||
<stylesheet>
|
||||
|
||||
<!-- scrollbar -->
|
||||
<style id="scrollbar">
|
||||
<background part="scrollbar_bg" repeat="repeat" />
|
||||
</style>
|
||||
<style id="scrollbar_thumb">
|
||||
<background part="scrollbar_thumb" repeat="repeat" />
|
||||
</style>
|
||||
|
||||
<!-- mini_scrollbar -->
|
||||
<style id="mini_scrollbar">
|
||||
<background part="mini_scrollbar_bg" />
|
||||
</style>
|
||||
<style id="mini_scrollbar:hover">
|
||||
<background part="mini_scrollbar_bg_hot" />
|
||||
</style>
|
||||
<style id="mini_scrollbar_thumb">
|
||||
<background part="mini_scrollbar_thumb" />
|
||||
</style>
|
||||
<style id="mini_scrollbar_thumb:hover">
|
||||
<background part="mini_scrollbar_thumb_hot" />
|
||||
</style>
|
||||
|
||||
<!-- transparent_scrollbar -->
|
||||
<style id="transparent_scrollbar">
|
||||
<background part="transparent_scrollbar_bg" />
|
||||
</style>
|
||||
<style id="transparent_scrollbar:hover">
|
||||
<background part="transparent_scrollbar_bg_hot" />
|
||||
</style>
|
||||
<style id="transparent_scrollbar_thumb">
|
||||
<background part="transparent_scrollbar_thumb" />
|
||||
</style>
|
||||
<style id="transparent_scrollbar_thumb:hover">
|
||||
<background part="transparent_scrollbar_thumb_hot" />
|
||||
</style>
|
||||
|
||||
<!-- timeline -->
|
||||
<style id="timeline">
|
||||
<background color="timeline_normal" part="timeline_normal" />
|
||||
@ -1040,6 +1004,29 @@
|
||||
<text color="listitem_selected_text" align="left top wordwrap" x="2" state="selected" />
|
||||
</style>
|
||||
|
||||
<style id="scrollbar">
|
||||
<background part="scrollbar_bg" repeat="repeat" />
|
||||
</style>
|
||||
<style id="scrollbar_thumb">
|
||||
<background part="scrollbar_thumb" repeat="repeat" />
|
||||
</style>
|
||||
<style id="mini_scrollbar">
|
||||
<background part="mini_scrollbar_bg" />
|
||||
<background part="mini_scrollbar_bg_hot" state="mouse" />
|
||||
</style>
|
||||
<style id="mini_scrollbar_thumb">
|
||||
<background part="mini_scrollbar_thumb" />
|
||||
<background part="mini_scrollbar_thumb_hot" state="mouse" />
|
||||
</style>
|
||||
<style id="transparent_scrollbar">
|
||||
<background part="transparent_scrollbar_bg" />
|
||||
<background part="transparent_scrollbar_bg_hot" state="mouse" />
|
||||
</style>
|
||||
<style id="transparent_scrollbar_thumb">
|
||||
<background part="transparent_scrollbar_thumb" />
|
||||
<background part="transparent_scrollbar_thumb_hot" state="mouse" />
|
||||
</style>
|
||||
|
||||
</styles>
|
||||
|
||||
</theme>
|
||||
|
@ -155,8 +155,10 @@ void EditorView::setupScrollbars()
|
||||
horizontalBar()->setBarWidth(barsize);
|
||||
verticalBar()->setBarWidth(barsize);
|
||||
|
||||
setup_mini_look(horizontalBar());
|
||||
setup_mini_look(verticalBar());
|
||||
horizontalBar()->setStyle(theme->newStyles.miniScrollbar());
|
||||
verticalBar()->setStyle(theme->newStyles.miniScrollbar());
|
||||
horizontalBar()->setThumbStyle(theme->newStyles.miniScrollbarThumb());
|
||||
verticalBar()->setThumbStyle(theme->newStyles.miniScrollbarThumb());
|
||||
|
||||
showScrollBars();
|
||||
}
|
||||
|
@ -974,8 +974,8 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
break;
|
||||
|
||||
case kViewScrollbarWidget:
|
||||
BORDER(1 * scale);
|
||||
widget->setChildSpacing(0);
|
||||
widget->setStyle(newStyles.scrollbar());
|
||||
static_cast<ScrollBar*>(widget)->setThumbStyle(newStyles.scrollbarThumb());
|
||||
break;
|
||||
|
||||
case kViewViewportWidget:
|
||||
@ -1589,55 +1589,6 @@ void SkinTheme::paintTextBox(ui::PaintEvent& ev)
|
||||
BGCOLOR, colors.textboxText());
|
||||
}
|
||||
|
||||
void SkinTheme::paintViewScrollbar(PaintEvent& ev)
|
||||
{
|
||||
ScrollBar* widget = static_cast<ScrollBar*>(ev.getSource());
|
||||
Graphics* g = ev.graphics();
|
||||
int pos, len;
|
||||
|
||||
bool isMiniLook = false;
|
||||
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
||||
if (skinPropery)
|
||||
isMiniLook = (skinPropery->getLook() == MiniLook);
|
||||
|
||||
skin::Style* bgStyle;
|
||||
skin::Style* thumbStyle;
|
||||
|
||||
if (widget->isTransparent()) {
|
||||
bgStyle = styles.transparentScrollbar();
|
||||
thumbStyle = styles.transparentScrollbarThumb();
|
||||
}
|
||||
else if (isMiniLook) {
|
||||
bgStyle = styles.miniScrollbar();
|
||||
thumbStyle = styles.miniScrollbarThumb();
|
||||
}
|
||||
else {
|
||||
bgStyle = styles.scrollbar();
|
||||
thumbStyle = styles.scrollbarThumb();
|
||||
}
|
||||
|
||||
widget->getScrollBarThemeInfo(&pos, &len);
|
||||
|
||||
Style::State state;
|
||||
if (widget->hasMouse()) state += Style::hover();
|
||||
|
||||
gfx::Rect rc = widget->clientBounds();
|
||||
bgStyle->paint(g, rc, NULL, state);
|
||||
|
||||
// Horizontal bar
|
||||
if (widget->align() & HORIZONTAL) {
|
||||
rc.x += pos;
|
||||
rc.w = len;
|
||||
}
|
||||
// Vertical bar
|
||||
else {
|
||||
rc.y += pos;
|
||||
rc.h = len;
|
||||
}
|
||||
|
||||
thumbStyle->paint(g, rc, NULL, state);
|
||||
}
|
||||
|
||||
void SkinTheme::paintViewViewport(PaintEvent& ev)
|
||||
{
|
||||
Viewport* widget = static_cast<Viewport*>(ev.getSource());
|
||||
|
@ -67,7 +67,6 @@ namespace app {
|
||||
void paintSlider(ui::PaintEvent& ev) override;
|
||||
void paintComboBoxEntry(ui::PaintEvent& ev) override;
|
||||
void paintTextBox(ui::PaintEvent& ev) override;
|
||||
void paintViewScrollbar(ui::PaintEvent& ev) override;
|
||||
void paintViewViewport(ui::PaintEvent& ev) override;
|
||||
|
||||
int get_button_selected_offset() const { return 0; } // TODO Configurable in xml
|
||||
|
@ -158,13 +158,17 @@ Timeline::Timeline()
|
||||
addChild(&m_hbar);
|
||||
addChild(&m_vbar);
|
||||
|
||||
int barsize = skinTheme()->dimensions.miniScrollbarSize();
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
|
||||
|
||||
int barsize = theme->dimensions.miniScrollbarSize();
|
||||
m_hbar.setBarWidth(barsize);
|
||||
m_vbar.setBarWidth(barsize);
|
||||
m_hbar.setBgColor(gfx::rgba(0, 0, 0, 128));
|
||||
m_vbar.setBgColor(gfx::rgba(0, 0, 0, 128));
|
||||
m_hbar.setTransparent(true);
|
||||
m_vbar.setTransparent(true);
|
||||
m_hbar.setStyle(theme->newStyles.transparentScrollbar());
|
||||
m_vbar.setStyle(theme->newStyles.transparentScrollbar());
|
||||
m_hbar.setThumbStyle(theme->newStyles.transparentScrollbarThumb());
|
||||
m_vbar.setThumbStyle(theme->newStyles.transparentScrollbarThumb());
|
||||
}
|
||||
|
||||
Timeline::~Timeline()
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013, 2015 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.
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "gfx/size.h"
|
||||
#include "ui/message.h"
|
||||
#include "ui/paint_event.h"
|
||||
#include "ui/scroll_bar.h"
|
||||
#include "ui/theme.h"
|
||||
|
||||
@ -25,6 +26,7 @@ int ScrollBar::m_whereclick = 0;
|
||||
ScrollBar::ScrollBar(int align, ScrollableViewDelegate* delegate)
|
||||
: Widget(kViewScrollbarWidget)
|
||||
, m_delegate(delegate)
|
||||
, m_thumbStyle(nullptr)
|
||||
, m_barWidth(theme()->getScrollbarSize())
|
||||
, m_pos(0)
|
||||
, m_size(0)
|
||||
@ -178,7 +180,15 @@ bool ScrollBar::onProcessMessage(Message* msg)
|
||||
|
||||
void ScrollBar::onPaint(PaintEvent& ev)
|
||||
{
|
||||
theme()->paintViewScrollbar(ev);
|
||||
gfx::Rect thumbBounds = clientBounds();
|
||||
if (align() & HORIZONTAL)
|
||||
getScrollBarThemeInfo(&thumbBounds.x, &thumbBounds.w);
|
||||
else
|
||||
getScrollBarThemeInfo(&thumbBounds.y, &thumbBounds.h);
|
||||
|
||||
theme()->paintScrollBar(
|
||||
ev.graphics(), this, style(), thumbStyle(),
|
||||
clientBounds(), thumbBounds);
|
||||
}
|
||||
|
||||
void ScrollBar::getScrollBarInfo(int *_pos, int *_len, int *_bar_size, int *_viewport_size)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite UI Library
|
||||
// Copyright (C) 2001-2013, 2015 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.
|
||||
@ -24,6 +24,9 @@ namespace ui {
|
||||
public:
|
||||
ScrollBar(int align, ScrollableViewDelegate* delegate);
|
||||
|
||||
Style* thumbStyle() { return m_thumbStyle; }
|
||||
void setThumbStyle(Style* style) { m_thumbStyle = style; }
|
||||
|
||||
int getBarWidth() const { return m_barWidth; }
|
||||
void setBarWidth(int barWidth) { m_barWidth = barWidth; }
|
||||
|
||||
@ -45,6 +48,7 @@ namespace ui {
|
||||
void getScrollBarInfo(int* _pos, int* _len, int* _bar_size, int* _viewport_size);
|
||||
|
||||
ScrollableViewDelegate* m_delegate;
|
||||
Style* m_thumbStyle;
|
||||
int m_barWidth;
|
||||
int m_pos;
|
||||
int m_size;
|
||||
|
@ -149,7 +149,8 @@ void Theme::paintWidget(Graphics* g,
|
||||
ASSERT(style);
|
||||
|
||||
// External background
|
||||
g->fillRect(widget->bgColor(), bounds);
|
||||
if (!widget->isTransparent())
|
||||
g->fillRect(widget->bgColor(), bounds);
|
||||
|
||||
gfx::Rect rc = bounds;
|
||||
gfx::Color bgColor = gfx::ColorNone;
|
||||
@ -160,6 +161,24 @@ void Theme::paintWidget(Graphics* g,
|
||||
});
|
||||
}
|
||||
|
||||
void Theme::paintScrollBar(Graphics* g,
|
||||
const Widget* widget,
|
||||
const Style* style,
|
||||
const Style* thumbStyle,
|
||||
const gfx::Rect& bounds,
|
||||
const gfx::Rect& thumbBounds)
|
||||
{
|
||||
paintWidget(g, widget, style, bounds);
|
||||
|
||||
gfx::Rect rc = thumbBounds;
|
||||
gfx::Color bgColor = gfx::ColorNone;
|
||||
for_each_layer(
|
||||
widget, thumbStyle,
|
||||
[this, g, widget, &rc, &bgColor](const Style::Layer& layer) {
|
||||
paintLayer(g, widget, layer, rc, bgColor);
|
||||
});
|
||||
}
|
||||
|
||||
void Theme::paintTooltip(Graphics* g,
|
||||
const Widget* widget,
|
||||
const Style* style,
|
||||
@ -219,7 +238,6 @@ void Theme::paintTooltip(Graphics* g,
|
||||
if (intClip)
|
||||
paintWidget(g, widget, arrowStyle, rc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Theme::paintLayer(Graphics* g,
|
||||
|
@ -63,7 +63,6 @@ namespace ui {
|
||||
virtual void paintSlider(PaintEvent& ev) = 0;
|
||||
virtual void paintComboBoxEntry(PaintEvent& ev) = 0;
|
||||
virtual void paintTextBox(PaintEvent& ev) = 0;
|
||||
virtual void paintViewScrollbar(PaintEvent& ev) = 0;
|
||||
virtual void paintViewViewport(PaintEvent& ev) = 0;
|
||||
|
||||
// Default implementation to draw widgets with new ui::Styles
|
||||
@ -72,6 +71,13 @@ namespace ui {
|
||||
const Style* style,
|
||||
const gfx::Rect& bounds);
|
||||
|
||||
virtual void paintScrollBar(Graphics* g,
|
||||
const Widget* widget,
|
||||
const Style* style,
|
||||
const Style* thumbStyle,
|
||||
const gfx::Rect& bounds,
|
||||
const gfx::Rect& thumbBounds);
|
||||
|
||||
virtual void paintTooltip(Graphics* g,
|
||||
const Widget* widget,
|
||||
const Style* style,
|
||||
|
Loading…
x
Reference in New Issue
Block a user