mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-25 19:30:53 +00:00
UIContext now keeps track of dimensions, allowing us to reduce use of display.h
This commit is contained in:
parent
cbd28980da
commit
f73890f0b2
@ -147,6 +147,18 @@ void DrawBuffer::Rect(float x, float y, float w, float h, uint32 color, int alig
|
||||
RectVGradient(x, y, w, h, color, color);
|
||||
}
|
||||
|
||||
void DrawBuffer::hLine(float x1, float y, float x2, uint32 color) {
|
||||
Rect(x1, y, x2 - x1, pixel_in_dps, color);
|
||||
}
|
||||
|
||||
void DrawBuffer::vLine(float x, float y1, float y2, uint32 color) {
|
||||
Rect(x, y1, pixel_in_dps, y2 - y1, color);
|
||||
}
|
||||
|
||||
void DrawBuffer::vLineAlpha50(float x, float y1, float y2, uint32 color) {
|
||||
Rect(x, y1, pixel_in_dps, y2 - y1, (color | 0xFF000000) & 0x7F000000);
|
||||
}
|
||||
|
||||
void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32 colorTop, uint32 colorBottom) {
|
||||
V(x, y, 0, colorTop, 0, 0);
|
||||
V(x + w, y, 0, colorTop, 1, 0);
|
||||
@ -156,6 +168,14 @@ void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32 colorT
|
||||
V(x, y + h, 0, colorBottom, 0, 1);
|
||||
}
|
||||
|
||||
void DrawBuffer::RectOutline(float x, float y, float w, float h, uint32 color, int align) {
|
||||
hLine(x, y, x + w + pixel_in_dps, color);
|
||||
hLine(x, y + h, x + w + pixel_in_dps, color);
|
||||
|
||||
vLine(x, y, y + h + pixel_in_dps, color);
|
||||
vLine(x + w, y, y + h + pixel_in_dps, color);
|
||||
}
|
||||
|
||||
void DrawBuffer::MultiVGradient(float x, float y, float w, float h, GradientStop *stops, int numStops) {
|
||||
for (int i = 0; i < numStops - 1; i++) {
|
||||
float t0 = stops[i].t, t1 = stops[i+1].t;
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/color.h"
|
||||
#include "base/display.h"
|
||||
#include "gfx/gl_lost_manager.h"
|
||||
#include "gfx/texture_atlas.h"
|
||||
#include "math/geom2d.h"
|
||||
@ -73,17 +72,11 @@ public:
|
||||
void Flush(bool set_blend_state=true);
|
||||
|
||||
void Rect(float x, float y, float w, float h, uint32 color, int align = ALIGN_TOPLEFT);
|
||||
void hLine(float x1, float y, float x2, uint32 color) { Rect(x1, y, x2 - x1, pixel_in_dps, color); }
|
||||
void vLine(float x, float y1, float y2, uint32 color) { Rect(x, y1, pixel_in_dps, y2 - y1, color); }
|
||||
void vLineAlpha50(float x, float y1, float y2, uint32 color) { Rect(x, y1, pixel_in_dps, y2 - y1, (color | 0xFF000000) & 0x7F000000); }
|
||||
void hLine(float x1, float y, float x2, uint32 color);
|
||||
void vLine(float x, float y1, float y2, uint32 color);
|
||||
void vLineAlpha50(float x, float y1, float y2, uint32 color);
|
||||
|
||||
void RectOutline(float x, float y, float w, float h, uint32 color, int align = ALIGN_TOPLEFT) {
|
||||
hLine(x, y, x + w + pixel_in_dps, color);
|
||||
hLine(x, y + h, x + w + pixel_in_dps, color);
|
||||
|
||||
vLine(x, y, y + h + pixel_in_dps, color);
|
||||
vLine(x + w, y, y + h + pixel_in_dps, color);
|
||||
}
|
||||
void RectOutline(float x, float y, float w, float h, uint32 color, int align = ALIGN_TOPLEFT);
|
||||
|
||||
void RectVGradient(float x, float y, float w, float h, uint32 colorTop, uint32 colorBottom);
|
||||
void RectVDarkFaded(float x, float y, float w, float h, uint32 colorTop) {
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/display.h"
|
||||
#include "base/NativeApp.h"
|
||||
|
||||
namespace UI {
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "base/display.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/view.h"
|
||||
#include "ui/ui_context.h"
|
||||
@ -12,6 +13,7 @@ UIContext::UIContext()
|
||||
fontScaleX_ = 1.0f;
|
||||
fontScaleY_ = 1.0f;
|
||||
fontStyle_ = new UI::FontStyle();
|
||||
bounds_ = Bounds(0, 0, dp_xres, dp_yres);
|
||||
}
|
||||
|
||||
UIContext::~UIContext() {
|
||||
@ -107,7 +109,7 @@ Bounds UIContext::GetScissorBounds() {
|
||||
if (!scissorStack_.empty())
|
||||
return scissorStack_.back();
|
||||
else
|
||||
return Bounds(0, 0, dp_xres, dp_yres);
|
||||
return bounds_;
|
||||
}
|
||||
|
||||
void UIContext::ActivateTopScissor() {
|
||||
@ -119,7 +121,7 @@ void UIContext::ActivateTopScissor() {
|
||||
int w = scale * bounds.w;
|
||||
int h = scale * bounds.h;
|
||||
|
||||
glstate.scissorRect.set(x,y,w,h);
|
||||
glstate.scissorRect.set(x, y, w, h);
|
||||
glstate.scissorTest.enable();
|
||||
} else {
|
||||
glstate.scissorTest.disable();
|
||||
|
@ -59,7 +59,13 @@ public:
|
||||
void DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align = 0);
|
||||
void FillRect(const UI::Drawable &drawable, const Bounds &bounds);
|
||||
|
||||
// in dps, like dp_xres and dp_yres
|
||||
void SetBounds(const Bounds &b) { bounds_ = b; }
|
||||
const Bounds &GetBounds() const { return bounds_; }
|
||||
|
||||
private:
|
||||
Bounds bounds_;
|
||||
|
||||
float fontScaleX_;
|
||||
float fontScaleY_;
|
||||
UI::FontStyle *fontStyle_;
|
||||
|
@ -143,10 +143,14 @@ void PopupScreen::touch(const TouchInput &touch) {
|
||||
void PopupScreen::CreateViews() {
|
||||
using namespace UI;
|
||||
|
||||
UIContext &dc = *screenManager()->getUIContext();
|
||||
|
||||
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
|
||||
float yres = screenManager()->getUIContext()->GetBounds().h;
|
||||
|
||||
box_ = new LinearLayout(ORIENT_VERTICAL,
|
||||
new AnchorLayoutParams(550, FillVertical() ? dp_yres - 30 : WRAP_CONTENT, dp_xres / 2, dp_yres / 2, NONE, NONE, true));
|
||||
new AnchorLayoutParams(550, FillVertical() ? yres - 30 : WRAP_CONTENT, dc.GetBounds().centerX(), dc.GetBounds().centerY(), NONE, NONE, true));
|
||||
|
||||
root_->Add(box_);
|
||||
box_->SetBG(UI::Drawable(0xFF303030));
|
||||
@ -198,7 +202,7 @@ void ListPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
using namespace UI;
|
||||
|
||||
listView_ = parent->Add(new ListView(&adaptor_)); //, new LinearLayoutParams(1.0)));
|
||||
listView_->SetMaxHeight(dp_yres - 140);
|
||||
listView_->SetMaxHeight(screenManager()->getUIContext()->GetBounds().h - 140);
|
||||
listView_->OnChoice.Handle(this, &ListPopupScreen::OnListChoice);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <queue>
|
||||
#include <algorithm>
|
||||
#include "base/display.h"
|
||||
|
||||
#include "base/mutex.h"
|
||||
#include "input/input_state.h"
|
||||
#include "input/keycodes.h"
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <set>
|
||||
|
||||
#include "base/display.h"
|
||||
#include "base/functional.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/mutex.h"
|
||||
@ -105,7 +104,7 @@ void ViewGroup::Axis(const AxisInput &input) {
|
||||
void ViewGroup::Draw(UIContext &dc) {
|
||||
if (hasDropShadow_) {
|
||||
// Darken things behind.
|
||||
dc.FillRect(UI::Drawable(0x60000000), Bounds(0,0,dp_xres, dp_yres));
|
||||
dc.FillRect(UI::Drawable(0x60000000), dc.GetBounds());
|
||||
float dropsize = 30;
|
||||
dc.Draw()->DrawImage4Grid(dc.theme->dropShadow4Grid,
|
||||
bounds_.x - dropsize, bounds_.y,
|
||||
@ -1072,11 +1071,7 @@ void LayoutViewHierarchy(const UIContext &dc, ViewGroup *root) {
|
||||
ELOG("Tried to layout a view hierarchy from a zero pointer root");
|
||||
return;
|
||||
}
|
||||
Bounds rootBounds;
|
||||
rootBounds.x = 0;
|
||||
rootBounds.y = 0;
|
||||
rootBounds.w = dp_xres;
|
||||
rootBounds.h = dp_yres;
|
||||
const Bounds &rootBounds = dc.GetBounds();
|
||||
|
||||
MeasureSpec horiz(EXACTLY, rootBounds.w);
|
||||
MeasureSpec vert(EXACTLY, rootBounds.h);
|
||||
|
Loading…
x
Reference in New Issue
Block a user