Rename ui::jguiscale() to ui::guiscale()

* Change Theme::guiscale member to Theme::m_guiscale
This commit is contained in:
David Capello 2014-11-25 22:33:45 -03:00
parent 9e0990a70f
commit ca9df1a05e
41 changed files with 177 additions and 173 deletions

View File

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

View File

@ -133,7 +133,7 @@ private:
gfx::Size size = getTextSize();
size.w = this->border_width.l + size.w + this->border_width.r;
size.h = this->border_width.t + size.h + this->border_width.b
+ 4*jguiscale();
+ 4*guiscale();
if (m_key && !m_key->accels().empty()) {
size_t combos = m_key->accels().size();
@ -164,19 +164,19 @@ private:
bounds.shrink(getBorder());
g->drawUIString(getText(), fg, bg,
gfx::Point(
bounds.x + m_level*16 * jguiscale(),
bounds.y + 2*jguiscale()));
bounds.x + m_level*16 * guiscale(),
bounds.y + 2*guiscale()));
if (m_key && !m_key->accels().empty()) {
std::string buf;
int y = bounds.y;
int dh = getTextSize().h + 4*jguiscale();
int dh = getTextSize().h + 4*guiscale();
int i = 0;
for (const Accelerator& accel : m_key->accels()) {
if (i != m_hotAccel || !m_changeButton) {
g->drawString(accel.toString(), fg, bg,
gfx::Point(bounds.x + g_sep, y + 2*jguiscale()));
gfx::Point(bounds.x + g_sep, y + 2*guiscale()));
}
y += dh;
@ -208,7 +208,7 @@ private:
const Accelerators* accels = (m_key ? &m_key->accels() : NULL);
int y = bounds.y;
int dh = getTextSize().h + 4*jguiscale();
int dh = getTextSize().h + 4*guiscale();
int maxi = (accels && accels->size() > 1 ? accels->size(): 1);
for (int i=0; i<maxi; ++i, y += dh) {
@ -221,8 +221,8 @@ private:
mouseMsg->position().y < bounds.y+bounds.h) {
itemBounds = itemBounds.enlarge(
gfx::Border(
4*jguiscale(), 0,
6*jguiscale(), 1*jguiscale()));
4*guiscale(), 0,
6*guiscale(), 1*guiscale()));
if (accels && i < (int)accels->size() &&
mouseMsg->position().y >= itemBounds.y &&
@ -250,10 +250,10 @@ private:
const char* label = "x";
m_deleteButton->setBgColor(gfx::ColorNone);
m_deleteButton->setBounds(gfx::Rect(
itemBounds.x + itemBounds.w + 2*jguiscale(),
itemBounds.x + itemBounds.w + 2*guiscale(),
itemBounds.y,
Graphics::measureUIStringLength(
label, getFont()) + 4*jguiscale(),
label, getFont()) + 4*guiscale(),
itemBounds.h));
m_deleteButton->setText(label);
@ -268,8 +268,8 @@ private:
addChild(m_addButton);
}
itemBounds.w = 8*jguiscale() + Graphics::measureUIStringLength("Add", getFont());
itemBounds.x -= itemBounds.w + 2*jguiscale();
itemBounds.w = 8*guiscale() + Graphics::measureUIStringLength("Add", getFont());
itemBounds.x -= itemBounds.w + 2*guiscale();
m_addButton->setBgColor(gfx::ColorNone);
m_addButton->setBounds(itemBounds);

View File

@ -103,13 +103,13 @@ protected:
gfx::Rect bounds = getBounds();
gfx::Border border;
if (bounds.w > 64*jguiscale()) {
border.left(32*jguiscale());
border.right(32*jguiscale());
if (bounds.w > 64*guiscale()) {
border.left(32*guiscale());
border.right(32*guiscale());
}
if (bounds.h > 64*jguiscale()) {
border.top(32*jguiscale());
border.bottom(32*jguiscale());
if (bounds.h > 64*guiscale()) {
border.top(32*guiscale());
border.bottom(32*guiscale());
}
m_delta += mousePos - m_oldMousePos;

View File

@ -46,7 +46,7 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
{
#define ADD(box, widget, hook) \
if (widget) { \
widget->setBorder(gfx::Border(2 * jguiscale())); \
widget->setBorder(gfx::Border(2 * guiscale())); \
box->addChild(widget); \
widget->Click.connect(Bind<void>(&FilterTargetButtons::hook, this, widget)); \
}

View File

@ -108,7 +108,7 @@ void draw_color_button(ui::Graphics* g,
bool hot, bool drag)
{
SkinTheme* theme = (SkinTheme*)ui::CurrentTheme::get();
int scale = ui::jguiscale();
int scale = ui::guiscale();
// Draw background (the color)
draw_color(g,

View File

@ -277,13 +277,14 @@ void gui_setup_screen(bool reload_font)
ui::set_display(main_display);
// Update guiscale factor
int old_guiscale = jguiscale();
CurrentTheme::get()->guiscale = (screen_scaling == 1 &&
ui::display_w() > 512 &&
ui::display_h() > 256) ? 2: 1;
int old_guiscale = guiscale();
CurrentTheme::get()->setScale(
(screen_scaling == 1 &&
ui::display_w() > 512 &&
ui::display_h() > 256) ? 2: 1);
// If the guiscale have changed
if (old_guiscale != jguiscale()) {
if (old_guiscale != guiscale()) {
reload_font = true;
regen = true;
}

View File

@ -90,8 +90,8 @@ void ButtonSet::Item::onPaint(ui::PaintEvent& ev)
}
Grid::Info info = buttonSet()->getChildInfo(this);
if (info.col < info.grid_cols-1) rc.w+=1*jguiscale();
if (info.row < info.grid_rows-1) rc.h+=3*jguiscale();
if (info.col < info.grid_cols-1) rc.w+=1*guiscale();
if (info.row < info.grid_rows-1) rc.h+=3*guiscale();
theme->draw_bounds_nw(g, rc, nw, face);
@ -140,7 +140,7 @@ void ButtonSet::Item::onPreferredSize(ui::PreferredSizeEvent& ev)
if (info.row == info.grid_rows-1)
sz.h += 3;
ev.setPreferredSize(sz*jguiscale());
ev.setPreferredSize(sz*guiscale());
}
ButtonSet::ButtonSet(int columns)

View File

@ -86,16 +86,16 @@ ColorBar::ColorBar(int align)
{
m_instance = this;
setBorder(gfx::Border(2*jguiscale(), 0, 0, 0));
child_spacing = 2*jguiscale();
setBorder(gfx::Border(2*guiscale(), 0, 0, 0));
child_spacing = 2*guiscale();
m_paletteView.setBoxSize(6*jguiscale());
m_paletteView.setBoxSize(6*guiscale());
m_paletteView.setColumns(8);
m_fgColor.setPreferredSize(0, m_fgColor.getPreferredSize().h);
m_bgColor.setPreferredSize(0, m_bgColor.getPreferredSize().h);
// TODO hardcoded scroll bar width should be get from skin.xml file
int scrollBarWidth = 6*jguiscale();
int scrollBarWidth = 6*guiscale();
m_scrollableView.getHorizontalBar()->setBarWidth(scrollBarWidth);
m_scrollableView.getVerticalBar()->setBarWidth(scrollBarWidth);
setup_mini_look(m_scrollableView.getHorizontalBar());

View File

@ -165,7 +165,7 @@ void ColorButton::onPreferredSize(PreferredSizeEvent& ev)
{
gfx::Rect box;
getTextIconInfo(&box);
box.w = 64*jguiscale();
box.w = 64*guiscale();
ev.setPreferredSize(box.w + border_width.l + border_width.r,
box.h + border_width.t + border_width.b);

View File

@ -79,7 +79,7 @@ ColorSelector::ColorSelector()
m_topBox.setBorder(gfx::Border(0));
m_topBox.child_spacing = 0;
m_colorPalette.setBoxSize(6*jguiscale());
m_colorPalette.setBoxSize(6*guiscale());
m_colorPaletteContainer.attachToView(&m_colorPalette);
m_colorPaletteContainer.setExpansive(true);
@ -125,7 +125,7 @@ ColorSelector::ColorSelector()
m_hexColorEntry.ColorChange.connect(&ColorSelector::onColorHexEntryChange, this);
selectColorType(app::Color::RgbType);
setPreferredSize(gfx::Size(300*jguiscale(), getPreferredSize().h));
setPreferredSize(gfx::Size(300*guiscale(), getPreferredSize().h));
m_onPaletteChangeConn =
App::instance()->PaletteChange.connect(&ColorSelector::onPaletteChange, this);

View File

@ -50,7 +50,7 @@ ConfigureTimelinePopup::ConfigureTimelinePopup()
, m_lockUpdates(false)
{
setAutoRemap(false);
setBorder(gfx::Border(4*jguiscale()));
setBorder(gfx::Border(4*guiscale()));
addChild(app::load_widget<Box>("timeline_conf.xml", "mainbox"));

View File

@ -119,7 +119,7 @@ protected:
}
void onPreferredSize(PreferredSizeEvent& ev) {
ev.setPreferredSize(Size(16, 18)*jguiscale());
ev.setPreferredSize(Size(16, 18)*guiscale());
}
private:
@ -127,7 +127,7 @@ private:
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
Rect rc = getBounds();
rc.y += rc.h - 2*jguiscale();
rc.y += rc.h - 2*guiscale();
rc.setSize(getPreferredSize());
rc.w *= 3;
m_popupWindow = new PopupWindow("", PopupWindow::kCloseOnClickInOtherWindow);
@ -534,14 +534,14 @@ protected:
}
void onPreferredSize(PreferredSizeEvent& ev) {
ev.setPreferredSize(Size(16, 18)*jguiscale());
ev.setPreferredSize(Size(16, 18)*guiscale());
}
private:
void openPopup() {
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
Border border = Border(2, 2, 2, 3)*jguiscale();
Border border = Border(2, 2, 2, 3)*guiscale();
Rect rc = getBounds();
rc.y += rc.h;
rc.w *= 3;
@ -742,7 +742,7 @@ ContextBar::ContextBar()
: Box(JI_HORIZONTAL)
, m_toolSettings(NULL)
{
border_width.b = 2*jguiscale();
border_width.b = 2*guiscale();
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
setBgColor(theme->getColor(ThemeColor::Workspace));
@ -832,7 +832,7 @@ bool ContextBar::onProcessMessage(Message* msg)
void ContextBar::onPreferredSize(PreferredSizeEvent& ev)
{
ev.setPreferredSize(gfx::Size(0, 18*jguiscale())); // TODO calculate height
ev.setPreferredSize(gfx::Size(0, 18*guiscale())); // TODO calculate height
}
void ContextBar::onSetOpacity(int newOpacity)

View File

@ -115,8 +115,8 @@ void EditorView::setupScrollbars()
!UIContext::instance()->settings()->getShowSpriteEditorScrollbars())
hideScrollBars();
else {
getHorizontalBar()->setBarWidth(kEditorViewScrollbarWidth*jguiscale());
getVerticalBar()->setBarWidth(kEditorViewScrollbarWidth*jguiscale());
getHorizontalBar()->setBarWidth(kEditorViewScrollbarWidth*guiscale());
getVerticalBar()->setBarWidth(kEditorViewScrollbarWidth*guiscale());
setup_mini_look(getHorizontalBar());
setup_mini_look(getVerticalBar());

View File

@ -139,9 +139,9 @@ bool FileList::onProcessMessage(Message* msg)
gfx::Size itemSize = getFileItemSize(fi);
if (((mouseMsg->position().y >= y) &&
(mouseMsg->position().y < y+th+4*jguiscale())) ||
(mouseMsg->position().y < y+th+4*guiscale())) ||
(it == m_list.begin() && mouseMsg->position().y < y) ||
(it == m_list.end()-1 && mouseMsg->position().y >= y+th+4*jguiscale())) {
(it == m_list.end()-1 && mouseMsg->position().y >= y+th+4*guiscale())) {
m_selected = fi;
makeSelectedFileitemVisible();
break;
@ -206,7 +206,7 @@ bool FileList::onProcessMessage(Message* msg)
gfx::Rect vp = view->getViewportBounds();
if (select < 0)
select = 0;
select += sgn * vp.h / (getTextHeight()+4*jguiscale());
select += sgn * vp.h / (getTextHeight()+4*guiscale());
break;
}
@ -285,7 +285,7 @@ bool FileList::onProcessMessage(Message* msg)
View* view = View::getView(this);
if (view) {
gfx::Point scroll = view->getViewScroll();
scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * 3*(getTextHeight()+4*jguiscale());
scroll += static_cast<MouseMessage*>(msg)->wheelDelta() * 3*(getTextHeight()+4*guiscale());
view->setViewScroll(scroll);
}
break;
@ -346,7 +346,7 @@ void FileList::onPaint(ui::PaintEvent& ev)
theme->getColor(ThemeColor::FileListOddRowText);
}
x = bounds.x+2*jguiscale();
x = bounds.x+2*guiscale();
// Item background
g->fillRect(bgcolor, gfx::Rect(bounds.x, y, bounds.w, itemSize.h));
@ -354,14 +354,14 @@ void FileList::onPaint(ui::PaintEvent& ev)
if (fi->isFolder()) {
int icon_w = getFont()->textLength("[+]");
g->drawUIString("[+]", fgcolor, bgcolor, gfx::Point(x, y+2*jguiscale()));
x += icon_w+2*jguiscale();
g->drawUIString("[+]", fgcolor, bgcolor, gfx::Point(x, y+2*guiscale()));
x += icon_w+2*guiscale();
}
// item name
g->drawString(
fi->getDisplayName().c_str(),
fgcolor, bgcolor, gfx::Point(x, y+2*jguiscale()));
fgcolor, bgcolor, gfx::Point(x, y+2*guiscale()));
// draw progress bars
double progress;
@ -369,13 +369,13 @@ void FileList::onPaint(ui::PaintEvent& ev)
ThumbnailGenerator::instance()->getWorkerStatus(fi, progress);
if (workerStatus == ThumbnailGenerator::WorkingOnThumbnail) {
int barw = 64*jguiscale();
int barw = 64*guiscale();
theme->paintProgressBar(g,
gfx::Rect(
bounds.x2()-2*jguiscale()-barw,
y+itemSize.h/2-3*jguiscale(),
barw, 6*jguiscale()),
bounds.x2()-2*guiscale()-barw,
y+itemSize.h/2-3*guiscale(),
barw, 6*guiscale()),
progress);
}
@ -392,9 +392,9 @@ void FileList::onPaint(ui::PaintEvent& ev)
// Draw the thumbnail
if (thumbnail) {
x = vp.x+vp.w - 2*jguiscale() - thumbnail->width();
x = vp.x+vp.w - 2*guiscale() - thumbnail->width();
y = thumbnail_y - thumbnail->height()/2 + getBounds().y;
y = MID(vp.y+2*jguiscale(), y, vp.y+vp.h-3*jguiscale()-thumbnail->height());
y = MID(vp.y+2*guiscale(), y, vp.y+vp.h-3*guiscale()-thumbnail->height());
x -= getBounds().x;
y -= getBounds().y;
@ -461,11 +461,11 @@ gfx::Size FileList::getFileItemSize(IFileItem* fi) const
int len = 0;
if (fi->isFolder())
len += getFont()->textLength("[+]") + 2*jguiscale();
len += getFont()->textLength("[+]") + 2*guiscale();
len += getFont()->textLength(fi->getDisplayName().c_str());
return gfx::Size(len+4*jguiscale(), getTextHeight()+4*jguiscale());
return gfx::Size(len+4*guiscale(), getTextHeight()+4*guiscale());
}
void FileList::makeSelectedFileitemVisible()
@ -486,8 +486,8 @@ void FileList::makeSelectedFileitemVisible()
if (fi == m_selected) {
if (y < vp.y)
scroll.y = y - getBounds().y;
else if (y > vp.y + vp.h - (th+4*jguiscale()))
scroll.y = y - getBounds().y - vp.h + (th+4*jguiscale());
else if (y > vp.y + vp.h - (th+4*guiscale()))
scroll.y = y - getBounds().y - vp.h + (th+4*guiscale());
view->setViewScroll(scroll);
break;

View File

@ -50,7 +50,7 @@ HexColorEntry::HexColorEntry()
initTheme();
setBorder(gfx::Border(2*jguiscale(), 0, 0, 0));
setBorder(gfx::Border(2*guiscale(), 0, 0, 0));
child_spacing = 0;
}

View File

@ -91,9 +91,9 @@ protected:
rect.w = playSize.w;
rect.h = playSize.h;
rect.offset(window->getBounds().x2() - 3*jguiscale()
- playSize.w - 1*jguiscale() - closeSize.w,
window->getBounds().y + 3*jguiscale());
rect.offset(window->getBounds().x2() - 3*guiscale()
- playSize.w - 1*guiscale() - closeSize.w,
window->getBounds().y + 3*guiscale());
setBounds(rect);
}
@ -154,7 +154,7 @@ bool MiniEditorWindow::onProcessMessage(ui::Message* msg)
// Default bounds
int width = ui::display_w()/4;
int height = ui::display_h()/4;
int extra = 2*kEditorViewScrollbarWidth*jguiscale();
int extra = 2*kEditorViewScrollbarWidth*guiscale();
setBounds(
gfx::Rect(
ui::display_w() - width - ToolBar::instance()->getBounds().w - extra,

View File

@ -68,7 +68,7 @@ void Notifications::addLink(INotificationDelegate* del)
void Notifications::onPreferredSize(PreferredSizeEvent& ev)
{
ev.setPreferredSize(gfx::Size(16, 10)*jguiscale()); // TODO hard-coded flag size
ev.setPreferredSize(gfx::Size(16, 10)*guiscale()); // TODO hard-coded flag size
}
void Notifications::onPaint(PaintEvent& ev)

View File

@ -46,7 +46,7 @@ PalettePopup::PalettePopup()
, m_popup(new gen::PalettePopup())
{
setAutoRemap(false);
setBorder(gfx::Border(4*jguiscale()));
setBorder(gfx::Border(4*guiscale()));
addChild(m_popup);
@ -68,7 +68,7 @@ void PalettePopup::showPopup(const gfx::Rect& bounds)
moveWindow(bounds);
// Setup the hot-region
setHotRegion(gfx::Region(gfx::Rect(bounds).enlarge(32 * jguiscale())));
setHotRegion(gfx::Region(gfx::Rect(bounds).enlarge(32 * guiscale())));
openWindow();
}

View File

@ -67,11 +67,11 @@ PaletteView::PaletteView(bool editable)
m_editable = editable;
m_columns = 16;
m_boxsize = 6*jguiscale();
m_boxsize = 6*guiscale();
this->border_width.l = this->border_width.r = 1 * jguiscale();
this->border_width.t = this->border_width.b = 1 * jguiscale();
this->child_spacing = 1 * jguiscale();
this->border_width.l = this->border_width.r = 1 * guiscale();
this->border_width.t = this->border_width.b = 1 * guiscale();
this->child_spacing = 1 * guiscale();
m_conn = App::instance()->PaletteChange.connect(&PaletteView::onAppPaletteChange, this);
}

View File

@ -66,8 +66,8 @@ void PalettesListBox::onPaintResource(Graphics* g, const gfx::Rect& bounds, Reso
doc::Palette* palette = static_cast<PaletteResource*>(resource)->palette();
gfx::Rect box(
bounds.x, bounds.y+bounds.h-6*jguiscale(),
4*jguiscale(), 4*jguiscale());
bounds.x, bounds.y+bounds.h-6*guiscale(),
4*guiscale(), 4*guiscale());
for (int i=0; i<palette->size(); ++i) {
doc::color_t c = palette->getEntry(i);
@ -82,13 +82,13 @@ void PalettesListBox::onPaintResource(Graphics* g, const gfx::Rect& bounds, Reso
// g->drawString(getText(), fgcolor, gfx::ColorNone, false,
// gfx::Point(
// bounds.x + jguiscale()*2,
// bounds.x + guiscale()*2,
// bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2));
}
void PalettesListBox::onResourcePreferredSize(Resource* resource, gfx::Size& size)
{
size = gfx::Size(0, (2+16+2)*jguiscale());
size = gfx::Size(0, (2+16+2)*guiscale());
}
} // namespace app

View File

@ -92,7 +92,7 @@ protected:
g->drawString(getText(), fgcolor, gfx::ColorNone,
gfx::Point(
bounds.x + jguiscale()*2,
bounds.x + guiscale()*2,
bounds.y + bounds.h/2 - g->measureUIString(getText()).h/2));
}

View File

@ -434,7 +434,7 @@ gfx::Size SkinTheme::get_part_size(int part_i) const
void SkinTheme::onRegenerate()
{
scrollbar_size = 12 * jguiscale();
scrollbar_size = 12 * guiscale();
m_part.clear();
m_part.resize(PARTS, NULL);
@ -504,7 +504,7 @@ void SkinTheme::onRegenerate()
she::Surface* slice = sliceSheet(NULL, gfx::Rect(x, y, w, h));
m_cursors[c] = new Cursor(slice,
gfx::Point(focusx*jguiscale(), focusy*jguiscale()));
gfx::Point(focusx*guiscale(), focusy*guiscale()));
break;
}
@ -687,7 +687,7 @@ she::Surface* SkinTheme::sliceSheet(she::Surface* sur, const gfx::Rect& bounds)
src->blitTo(dst, bounds.x, bounds.y, 0, 0, bounds.w, bounds.h);
}
sur->applyScale(jguiscale());
sur->applyScale(guiscale());
return sur;
}
@ -716,7 +716,7 @@ void SkinTheme::initWidget(Widget* widget)
widget->border_width.r = (R); \
widget->border_width.b = (B);
int scale = jguiscale();
int scale = guiscale();
switch (widget->type) {
@ -785,8 +785,8 @@ void SkinTheme::initWidget(Widget* widget)
button->border_width.r = 0;
button->border_width.b = 0;
button->child_spacing = 0;
button->min_w = 15 * jguiscale();
button->min_h = 16 * jguiscale();
button->min_w = 15 * guiscale();
button->min_h = 16 * guiscale();
static_cast<ButtonBase*>(button)->setIconInterface
(new ButtonIconImpl(static_cast<SkinTheme*>(button->getTheme()),
@ -925,8 +925,8 @@ void SkinTheme::setDecorativeWidgetBounds(Widget* widget)
rect.w = m_part[PART_WINDOW_CLOSE_BUTTON_NORMAL]->width();
rect.h = m_part[PART_WINDOW_CLOSE_BUTTON_NORMAL]->height();
rect.offset(window->getBounds().x2() - 3*jguiscale() - rect.w,
window->getBounds().y + 3*jguiscale());
rect.offset(window->getBounds().x2() - 3*guiscale() - rect.w,
window->getBounds().y + 3*guiscale());
widget->setBounds(rect);
}
@ -1194,7 +1194,7 @@ void SkinTheme::paintLinkLabel(PaintEvent& ev)
// Underline style
if (widget->hasMouseOver()) {
int w = widget->getTextWidth();
for (int v=0; v<jguiscale(); ++v)
for (int v=0; v<guiscale(); ++v)
g->drawHLine(fg, bounds.x, bounds.y2()-1-v, w);
}
}
@ -1244,7 +1244,7 @@ void SkinTheme::paintMenu(PaintEvent& ev)
void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
{
int scale = jguiscale();
int scale = guiscale();
Graphics* g = ev.getGraphics();
MenuItem* widget = static_cast<MenuItem*>(ev.getSource());
gfx::Rect bounds = widget->getClientBounds();
@ -1474,15 +1474,15 @@ void SkinTheme::paintSlider(PaintEvent& ev)
// Draw borders
rc.shrink(Border(
3 * jguiscale(),
3 * guiscale(),
thumb->height(),
3 * jguiscale(),
1 * jguiscale()));
3 * guiscale(),
1 * guiscale()));
draw_bounds_nw(g, rc, nw, gfx::ColorNone);
// Draw background (using the customized ISliderBgPainter implementation)
rc.shrink(Border(1, 1, 1, 2) * jguiscale());
rc.shrink(Border(1, 1, 1, 2) * guiscale());
if (!rc.isEmpty())
bgPainter->paint(widget, g, rc);
}
@ -1742,7 +1742,7 @@ void SkinTheme::paintWindow(PaintEvent& ev)
if (window->hasText()) {
get_style("window")->paint(g, pos, NULL, Style::State());
get_style("window_title")->paint(g,
gfx::Rect(cpos.x, pos.y+5*jguiscale(), cpos.w, // TODO this hard-coded 5 should be configurable in skin.xml
gfx::Rect(cpos.x, pos.y+5*guiscale(), cpos.w, // TODO this hard-coded 5 should be configurable in skin.xml
window->getTextHeight()),
window->getText().c_str(), Style::State());
}
@ -1914,7 +1914,7 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, gfx::Color fg_color,
// Background
if (!is_transparent(bg_color)) {
if (!widget->isEnabled())
g->fillRect(bg_color, Rect(textrc).inflate(jguiscale(), jguiscale()));
g->fillRect(bg_color, Rect(textrc).inflate(guiscale(), guiscale()));
else
g->fillRect(bg_color, textrc);
}
@ -1923,7 +1923,7 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, gfx::Color fg_color,
Rect textWrap = textrc.createIntersect(
// TODO add ui::Widget::getPadding() property
// Rect(widget->getClientBounds()).shrink(widget->getBorder()));
widget->getClientBounds()).inflate(0, 1*jguiscale());
widget->getClientBounds()).inflate(0, 1*guiscale());
IntersectClip clip(g, textWrap);
if (clip) {
@ -1932,7 +1932,7 @@ void SkinTheme::drawTextString(Graphics* g, const char *t, gfx::Color fg_color,
g->drawUIString(t,
getColor(ThemeColor::Background),
gfx::ColorNone,
textrc.getOrigin() + Point(jguiscale(), jguiscale()));
textrc.getOrigin() + Point(guiscale(), guiscale()));
}
g->drawUIString(t,
@ -1950,7 +1950,7 @@ void SkinTheme::drawEntryCaret(ui::Graphics* g, Entry* widget, int x, int y)
gfx::Color color = getColor(ThemeColor::Text);
int h = widget->getTextHeight();
for (int u=x; u<x+2*jguiscale(); ++u)
for (int u=x; u<x+2*guiscale(); ++u)
g->drawVLine(color, u, y-1, h+2);
}
@ -2193,7 +2193,6 @@ void SkinTheme::paintIcon(Widget* widget, Graphics* g, IButtonIcon* iconInterfac
g->drawRgbaSurface(icon_bmp, x, y);
}
// static
she::Font* SkinTheme::loadFont(const char* userFont, const std::string& path)
{
ResourceFinder rf;
@ -2207,7 +2206,7 @@ she::Font* SkinTheme::loadFont(const char* userFont, const std::string& path)
// Try to load the font
while (rf.next()) {
she::Font* f = she::load_bitmap_font(rf.filename().c_str(), jguiscale());
she::Font* f = she::load_bitmap_font(rf.filename().c_str(), guiscale());
if (f) {
if (f->isScalable())
f->setSize(8);

View File

@ -206,7 +206,7 @@ namespace app {
void paintIcon(ui::Widget* widget, ui::Graphics* g, ui::IButtonIcon* iconInterface, int x, int y);
static she::Font* loadFont(const char* userFont, const std::string& path);
she::Font* loadFont(const char* userFont, const std::string& path);
std::string m_selected_skin;
she::Surface* m_sheet;

View File

@ -144,7 +144,7 @@ Rules::Rules(const css::Query& query) :
m_text->setColor(StyleSheet::convertColor(textColor));
m_text->setPadding(gfx::Border(
paddingLeft.number(), paddingTop.number(),
paddingRight.number(), paddingBottom.number())*ui::jguiscale());
paddingRight.number(), paddingBottom.number())*ui::guiscale());
}
}

View File

@ -38,7 +38,7 @@ StartView::StartView()
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
setBgColor(theme->getColor(ThemeColor::Workspace));
child_spacing = 8 * jguiscale();
child_spacing = 8 * guiscale();
addChild(new Label("Welcome to " PACKAGE " v" VERSION));
}

View File

@ -189,7 +189,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)
setBorder(gfx::Border(1*jguiscale(), 0, 1*jguiscale(), 0));
setBorder(gfx::Border(1*guiscale(), 0, 1*guiscale(), 0));
// Construct the commands box
{
@ -215,7 +215,7 @@ StatusBar::StatusBar()
m_slider->Change.connect(Bind<void>(&slider_change_hook, m_slider));
m_slider->setMinSize(gfx::Size(ui::display_w()/5, 0));
box1->setBorder(gfx::Border(2, 1, 2, 2)*jguiscale());
box1->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());
box2->noBorderNoChildSpacing();
box3->noBorderNoChildSpacing();
box3->setExpansive(true);
@ -242,7 +242,7 @@ StatusBar::StatusBar()
Box* box1 = new Box(JI_HORIZONTAL);
Box* box2 = new Box(JI_VERTICAL);
box1->setBorder(gfx::Border(2, 1, 2, 2)*jguiscale());
box1->setBorder(gfx::Border(2, 1, 2, 2)*guiscale());
box2->noBorderNoChildSpacing();
box2->setExpansive(true);
@ -473,13 +473,13 @@ void StatusBar::onResize(ResizeEvent& ev)
m_notificationsBox->setBounds(rc);
rc = ev.getBounds();
rc.w -= rc.w/4 + 4*jguiscale();
rc.w -= rc.w/4 + 4*guiscale();
m_commandsBox->setBounds(rc);
}
void StatusBar::onPreferredSize(PreferredSizeEvent& ev)
{
int s = 4*jguiscale() + getTextHeight() + 4*jguiscale();
int s = 4*guiscale() + getTextHeight() + 4*guiscale();
ev.setPreferredSize(Size(s, s));
}
@ -492,9 +492,9 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
g->fillRect(getBgColor(), rc);
rc.shrink(Border(2, 1, 2, 2)*jguiscale());
rc.shrink(Border(2, 1, 2, 2)*guiscale());
int x = rc.x + 4*jguiscale();
int x = rc.x + 4*guiscale();
// Color
if (m_state == SHOW_COLOR) {
@ -502,14 +502,14 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
she::Surface* icon = theme->get_toolicon("eyedropper");
if (icon) {
g->drawRgbaSurface(icon, x, rc.y + rc.h/2 - icon->height()/2);
x += icon->width() + 4*jguiscale();
x += icon->width() + 4*guiscale();
}
// Draw color
draw_color_button(g, gfx::Rect(x, rc.y, 32*jguiscale(), rc.h),
draw_color_button(g, gfx::Rect(x, rc.y, 32*guiscale(), rc.h),
m_color, false, false);
x += (32+4)*jguiscale();
x += (32+4)*guiscale();
// Draw color description
std::string str = m_color.toHumanReadableString(app_get_current_pixel_format(),
@ -523,7 +523,7 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
g->drawString(str, textColor, ColorNone,
gfx::Point(x, rc.y + rc.h/2 - getFont()->height()/2));
x += getFont()->textLength(str.c_str()) + 4*jguiscale();
x += getFont()->textLength(str.c_str()) + 4*guiscale();
}
// Show tool
@ -532,7 +532,7 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
she::Surface* icon = theme->get_toolicon(m_tool->getId().c_str());
if (icon) {
g->drawRgbaSurface(icon, x, rc.y + rc.h/2 - icon->height()/2);
x += icon->width() + 4*jguiscale();
x += icon->width() + 4*guiscale();
}
}
@ -541,7 +541,7 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
g->drawString(getText(), textColor, ColorNone,
gfx::Point(x, rc.y + rc.h/2 - getFont()->height()/2));
x += getFont()->textLength(getText().c_str()) + 4*jguiscale();
x += getFont()->textLength(getText().c_str()) + 4*guiscale();
}
// Draw progress bar

View File

@ -48,7 +48,7 @@ bool StyledButton::onProcessMessage(Message* msg) {
void StyledButton::onPreferredSize(PreferredSizeEvent& ev) {
ev.setPreferredSize(
m_style->preferredSize(NULL, skin::Style::State()) + 4*jguiscale());
m_style->preferredSize(NULL, skin::Style::State()) + 4*guiscale());
}
void StyledButton::onPaint(PaintEvent& ev) {

View File

@ -34,7 +34,7 @@
#include <algorithm>
#include <cmath>
#define ARROW_W (12*jguiscale())
#define ARROW_W (12*guiscale())
#define ANI_ADDING_TAB_TICKS 5
#define ANI_REMOVING_TAB_TICKS 10
@ -367,7 +367,7 @@ void Tabs::onPaint(PaintEvent& ev)
Graphics* g = ev.getGraphics();
gfx::Rect rect = getClientBounds();
gfx::Rect box(rect.x-m_scrollX, rect.y,
2*jguiscale(),
2*guiscale(),
m_list_of_tabs.empty() ? 0: theme->get_part(PART_TAB_FILLER)->height());
g->fillRect(theme->getColorById(kWindowFaceColorId), g->getClipBounds());
@ -505,7 +505,7 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& box, Tab* tab, int y_delta, boo
g->drawString(tab->text, text_color, gfx::ColorNone,
gfx::Point(
box.x + 4*jguiscale(),
box.x + 4*guiscale(),
box.y + box.h/2 - getFont()->height()/2+1 + y_delta));
}
@ -524,8 +524,8 @@ void Tabs::drawTab(Graphics* g, const gfx::Rect& box, Tab* tab, int y_delta, boo
#ifdef CLOSE_BUTTON_IN_EACH_TAB
she::Surface* close_icon = theme->get_part(PART_WINDOW_CLOSE_BUTTON_NORMAL);
g->drawRgbaSurface(close_icon,
box.x2() - 4*jguiscale() - close_icon->width(),
box.y + box.h/2 - close_icon->height()/2+1 * jguiscale());
box.x2() - 4*guiscale() - close_icon->width(),
box.y + box.h/2 - close_icon->height()/2+1 * guiscale());
#endif
}
@ -667,7 +667,7 @@ void Tabs::calcTabWidth(Tab* tab)
// Cache current tab text
tab->text = tab->view->getTabText();
int border = 4*jguiscale();
int border = 4*guiscale();
#ifdef CLOSE_BUTTON_IN_EACH_TAB
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
int close_icon_w = theme->get_part(PART_WINDOW_CLOSE_BUTTON_NORMAL)->width();

View File

@ -59,7 +59,7 @@
// Size of the thumbnail in the screen (width x height), the really
// size of the thumbnail bitmap is specified in the
// 'generate_thumbnail' routine.
#define THUMBSIZE (12*jguiscale())
#define THUMBSIZE (12*guiscale())
// Height of the headers.
#define HDRSIZE THUMBSIZE
@ -71,9 +71,9 @@
#define LAYSIZE THUMBSIZE
// Space between icons and other information in the layer.
#define ICONSEP (2*jguiscale())
#define ICONSEP (2*guiscale())
#define OUTLINE_WIDTH (2*jguiscale()) // TODO theme specific
#define OUTLINE_WIDTH (2*guiscale()) // TODO theme specific
// Space between the icon-bitmap and the edge of the surrounding button.
#define ICONBORDER 0
@ -162,7 +162,7 @@ Timeline::Timeline()
, m_document(NULL)
, m_scroll_x(0)
, m_scroll_y(0)
, m_separator_x(100 * jguiscale())
, m_separator_x(100 * guiscale())
, m_separator_w(1)
, m_confPopup(NULL)
, m_clipboard_timer(100, this)
@ -1295,7 +1295,7 @@ void Timeline::drawRangeOutline(ui::Graphics* g)
}
case Range::kFrames: {
int w = 5 * jguiscale(); // TODO get width from the skin info
int w = 5 * guiscale(); // TODO get width from the skin info
if (m_dropTarget.hhit == DropTarget::Before)
dropBounds.x -= w/2;
@ -1311,7 +1311,7 @@ void Timeline::drawRangeOutline(ui::Graphics* g)
}
case Range::kLayers: {
int h = 5 * jguiscale(); // TODO get height from the skin info
int h = 5 * guiscale(); // TODO get height from the skin info
if (m_dropTarget.vhit == DropTarget::Top)
dropBounds.y -= h/2;

View File

@ -81,7 +81,7 @@ static Size getToolIconSize(Widget* widget)
if (icon)
return Size(icon->width(), icon->height());
else
return Size(16, 16) * jguiscale();
return Size(16, 16) * guiscale();
}
//////////////////////////////////////////////////////////////////////
@ -96,9 +96,9 @@ ToolBar::ToolBar()
{
m_instance = this;
this->border_width.l = 1*jguiscale();
this->border_width.l = 1*guiscale();
this->border_width.t = 0;
this->border_width.r = 1*jguiscale();
this->border_width.r = 1*guiscale();
this->border_width.b = 0;
m_hotTool = NULL;
@ -461,7 +461,7 @@ void ToolBar::openPopupWindow(int group_index, ToolGroup* tool_group)
rc.w = w;
// Set hotregion of popup window
Region rgn(gfx::Rect(rc).enlarge(16*jguiscale()));
Region rgn(gfx::Rect(rc).enlarge(16*guiscale()));
rgn.createUnion(rgn, Region(getBounds()));
m_popupWindow->setHotRegion(rgn);
@ -486,19 +486,19 @@ Rect ToolBar::getToolGroupBounds(int group_index)
switch (group_index) {
case ConfigureToolIndex:
rc.y += groups*(iconsize.h-1*jguiscale())+ 8*jguiscale();
rc.h = iconsize.h+2*jguiscale();
rc.y += groups*(iconsize.h-1*guiscale())+ 8*guiscale();
rc.h = iconsize.h+2*guiscale();
break;
case MiniEditorVisibilityIndex:
rc.y += rc.h - iconsize.h - 2*jguiscale();
rc.h = iconsize.h+2*jguiscale();
rc.y += rc.h - iconsize.h - 2*guiscale();
rc.h = iconsize.h+2*guiscale();
break;
default:
rc.y += group_index*(iconsize.h-1*jguiscale());
rc.h = group_index < groups-1 ? iconsize.h+1*jguiscale():
iconsize.h+2*jguiscale();
rc.y += group_index*(iconsize.h-1*guiscale());
rc.h = group_index < groups-1 ? iconsize.h+1*guiscale():
iconsize.h+2*guiscale();
break;
}

View File

@ -321,7 +321,7 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
vertical ? JI_VERTICAL: 0);
if (position) {
splitter->setPosition(strtod(position, NULL)
* (type == Splitter::ByPixel ? jguiscale(): 1));
* (type == Splitter::ByPixel ? guiscale(): 1));
}
widget = splitter;
}
@ -515,14 +515,14 @@ void WidgetLoader::fillWidgetWithXmlElementAttributes(const TiXmlElement* elem,
gfx::Size reqSize = widget->getPreferredSize();
if (minwidth || minheight) {
int w = (minwidth ? jguiscale()*strtol(minwidth, NULL, 10): reqSize.w);
int h = (minheight ? jguiscale()*strtol(minheight, NULL, 10): reqSize.h);
int w = (minwidth ? guiscale()*strtol(minwidth, NULL, 10): reqSize.w);
int h = (minheight ? guiscale()*strtol(minheight, NULL, 10): reqSize.h);
widget->setMinSize(gfx::Size(w, h));
}
if (maxwidth || maxheight) {
int w = (maxwidth ? jguiscale()*strtol(maxwidth, NULL, 10): INT_MAX);
int h = (maxheight ? jguiscale()*strtol(maxheight, NULL, 10): INT_MAX);
int w = (maxwidth ? guiscale()*strtol(maxwidth, NULL, 10): INT_MAX);
int h = (maxheight ? guiscale()*strtol(maxheight, NULL, 10): INT_MAX);
widget->setMaxSize(gfx::Size(w, h));
}

View File

@ -150,7 +150,7 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
else if (button) {
char buttonId[256];
Button* button_widget = new Button(beg);
button_widget->setMinSize(gfx::Size(60*jguiscale(), 0));
button_widget->setMinSize(gfx::Size(60*guiscale(), 0));
buttons.push_back(button_widget);
sprintf(buttonId, "button-%lu", buttons.size());

View File

@ -362,9 +362,9 @@ void ComboBox::onPreferredSize(PreferredSizeEvent& ev)
ListItems::iterator it, end = m_items.end();
for (it = m_items.begin(); it != end; ++it) {
int item_w =
2*jguiscale()+
2*guiscale()+
getFont()->textLength((*it)->getText().c_str())+
10*jguiscale();
10*guiscale();
reqSize.w = MAX(reqSize.w, item_w);
}
@ -507,7 +507,7 @@ void ComboBox::openListBox()
(gfx::Size(
m_button->getBounds().x2() - m_entry->getBounds().x - view->border_width.l - view->border_width.r,
+viewport->border_width.t
+(2*jguiscale()+m_listbox->getTextHeight())*MID(1, size, 16)+
+(2*guiscale()+m_listbox->getTextHeight())*MID(1, size, 16)+
+viewport->border_width.b));
m_window->addChild(view);

View File

@ -415,7 +415,7 @@ void Entry::onPreferredSize(PreferredSizeEvent& ev)
int w =
+ border_width.l
+ getFont()->charWidth('w') * MIN(m_maxsize, 6)
+ 2*jguiscale()
+ 2*guiscale()
+ border_width.r;
w = MIN(w, ui::display_w()/2);

View File

@ -197,7 +197,7 @@ void Graphics::drawUIString(const std::string& str, gfx::Color fg, gfx::Color bg
if (underscored_w > 0) {
y += m_font->height();
dst->fillRect(fg,
gfx::Rect(underscored_x, y, underscored_w, jguiscale()));
gfx::Rect(underscored_x, y, underscored_w, guiscale()));
}
}

View File

@ -134,8 +134,8 @@ void IntEntry::openPopup()
{
Rect rc = getBounds();
rc.y += rc.h;
rc.h += 2*jguiscale();
rc.w = 128*jguiscale();
rc.h += 2*guiscale();
rc.w = 128*guiscale();
if (rc.x+rc.w > ui::display_w())
rc.x = rc.x - rc.w + getBounds().w;

View File

@ -181,10 +181,10 @@ void PopupWindow::onInitTheme(InitThemeEvent& ev)
{
Widget::onInitTheme(ev);
this->border_width.l = 3 * jguiscale();
this->border_width.t = 3 * jguiscale();
this->border_width.r = 3 * jguiscale();
this->border_width.b = 3 * jguiscale();
this->border_width.l = 3 * guiscale();
this->border_width.t = 3 * guiscale();
this->border_width.r = 3 * guiscale();
this->border_width.b = 3 * guiscale();
}
void PopupWindow::startFilteringMessages()

View File

@ -292,7 +292,7 @@ void Splitter::onLoadLayout(LoadLayoutEvent& ev)
ev.stream() >> m_pos;
if (m_pos < 0) m_pos = 0;
if (m_type == ByPixel)
m_pos *= jguiscale();
m_pos *= guiscale();
// Do for all children
UI_FOREACH_WIDGET(getChildren(), it)
@ -301,7 +301,7 @@ void Splitter::onLoadLayout(LoadLayoutEvent& ev)
void Splitter::onSaveLayout(SaveLayoutEvent& ev)
{
double pos = (m_type == ByPixel ? m_pos / jguiscale(): m_pos);
double pos = (m_type == ByPixel ? m_pos / guiscale(): m_pos);
ev.stream() << pos;
// Do for all children

View File

@ -24,11 +24,11 @@ namespace ui {
static Theme* current_theme = NULL;
Theme::Theme()
: m_guiscale(1)
{
this->name = "Theme";
this->default_font = she::instance()->defaultFont();
this->scrollbar_size = 0;
this->guiscale = 1;
}
Theme::~Theme()

View File

@ -25,19 +25,20 @@ namespace ui {
class PaintEvent;
class Widget;
class Theme
{
class Theme {
public:
const char* name;
she::Font* default_font;
int scrollbar_size;
int guiscale;
Theme();
virtual ~Theme();
void regenerate();
int guiscale() const { return m_guiscale; }
void setScale(int value) { m_guiscale = value; }
virtual Cursor* getCursor(CursorType type) = 0;
virtual void initWidget(Widget* widget) = 0;
virtual void getWindowMask(Widget* widget, gfx::Region& region) = 0;
@ -71,6 +72,9 @@ namespace ui {
protected:
virtual void onRegenerate() = 0;
private:
int m_guiscale;
};
namespace CurrentTheme
@ -81,9 +85,9 @@ namespace ui {
// This value is a factor to multiply every screen size/coordinate.
// Every icon/graphics/font should be scaled to this factor.
inline int jguiscale()
inline int guiscale()
{
return CurrentTheme::get() ? CurrentTheme::get()->guiscale: 1;
return CurrentTheme::get() ? CurrentTheme::get()->guiscale(): 1;
}
} // namespace ui

View File

@ -91,8 +91,8 @@ void TooltipManager::onTick()
if (!m_tipWindow) {
m_tipWindow.reset(new TipWindow(m_target.tipInfo.text.c_str()));
gfx::Rect bounds = m_target.widget->getBounds();
int x = get_mouse_position().x+12*jguiscale();
int y = get_mouse_position().y+12*jguiscale();
int x = get_mouse_position().x+12*guiscale();
int y = get_mouse_position().y+12*guiscale();
int w, h;
m_tipWindow->setArrowAlign(m_target.tipInfo.arrowAlign);
@ -220,10 +220,10 @@ void TipWindow::onInitTheme(InitThemeEvent& ev)
{
Window::onInitTheme(ev);
this->border_width.l = 6 * jguiscale();
this->border_width.t = 6 * jguiscale();
this->border_width.r = 6 * jguiscale();
this->border_width.b = 7 * jguiscale();
this->border_width.l = 6 * guiscale();
this->border_width.t = 6 * guiscale();
this->border_width.r = 6 * guiscale();
this->border_width.b = 7 * guiscale();
// Setup the background color.
setBgColor(gfx::rgba(255, 255, 200));