mirror of
https://github.com/XorTroll/hb-appstore.git
synced 2025-03-01 06:46:01 +00:00
add scroll to app details, fix progress bar centering
This commit is contained in:
parent
9907a9510c
commit
76a831f640
@ -43,20 +43,24 @@ AppDetails::AppDetails(Package* package, AppList* appList)
|
||||
this->elements.push_back(cancel);
|
||||
|
||||
|
||||
// the scrollable portion of the app details page
|
||||
AppDetailsContent* content = new AppDetailsContent();
|
||||
this->elements.push_back(content);
|
||||
|
||||
TextElement* title = new TextElement(package->title.c_str(), 35, &black);
|
||||
title->position(20, 20);
|
||||
this->elements.push_back(title);
|
||||
content->elements.push_back(title);
|
||||
|
||||
int MARGIN = 525;
|
||||
|
||||
TextElement* title2 = new TextElement(package->author.c_str(), 27, &gray);
|
||||
title2->position(20, 80);
|
||||
this->elements.push_back(title2);
|
||||
content->elements.push_back(title2);
|
||||
|
||||
// the main description (wrapped text)
|
||||
TextElement* details = new TextElement(package->long_desc.c_str(), 20, &black, false, 700);
|
||||
details->position(150, 230);
|
||||
this->elements.push_back(details);
|
||||
content->elements.push_back(details);
|
||||
|
||||
|
||||
// lots of details that we know about the package
|
||||
@ -124,12 +128,13 @@ bool AppDetails::process(InputEvents* event)
|
||||
// event->key.keysym.sym = SDLK_z;
|
||||
event->update();
|
||||
this->highlighted = -1;
|
||||
|
||||
|
||||
// add a progress bar to the screen to be drawn
|
||||
this->pbar = new ProgressBar();
|
||||
pbar->position(580, 495);
|
||||
pbar->width = 740;
|
||||
pbar->position(1280/2 - this->pbar->width/2, 720/2 - 5);
|
||||
pbar->color = 0xff0000ff;
|
||||
pbar->width = 500;
|
||||
pbar->dimBg = true;
|
||||
this->elements.push_back(pbar);
|
||||
|
||||
// hide the two specific elements for the download/install/remove and close buttons
|
||||
@ -173,7 +178,7 @@ bool AppDetails::process(InputEvents* event)
|
||||
if (event->isTouchDown())
|
||||
this->dragging = true;
|
||||
|
||||
return false;
|
||||
return super::process(event);
|
||||
}
|
||||
|
||||
void AppDetails::render(Element* parent)
|
||||
@ -237,3 +242,18 @@ int AppDetails::updateCurrentlyDisplayedPopup(void *clientp, double dltotal, dou
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AppDetailsContent::render(Element* parent)
|
||||
{
|
||||
if (this->parent == NULL)
|
||||
this->parent = parent;
|
||||
|
||||
this->renderer = parent->renderer;
|
||||
|
||||
super::render(this);
|
||||
}
|
||||
|
||||
bool AppDetailsContent::process(InputEvents* event)
|
||||
{
|
||||
return ListElement::process(event);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "TextElement.hpp"
|
||||
#include "ImageElement.hpp"
|
||||
#include "ProgressBar.hpp"
|
||||
#include "ListElement.hpp"
|
||||
#include "../libs/get/src/Package.hpp"
|
||||
#include "../libs/get/src/Get.hpp"
|
||||
|
||||
@ -27,4 +28,10 @@ public:
|
||||
static int updateCurrentlyDisplayedPopup(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
};
|
||||
|
||||
class AppDetailsContent : public ListElement
|
||||
{
|
||||
bool process(InputEvents* event);
|
||||
void render(Element* parent);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -94,11 +94,8 @@ bool AppList::process(InputEvents* event)
|
||||
this->highlighted = -1;
|
||||
this->touchMode = true;
|
||||
}
|
||||
|
||||
// perform inertia scrolling for this element
|
||||
ret |= this->handleInertiaScroll(event);
|
||||
|
||||
ret |= super::process(event);
|
||||
ret |= ListElement::process(event);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,6 +1,18 @@
|
||||
#include "ListElement.hpp"
|
||||
#include <SDL2/SDL2_gfxPrimitives.h>
|
||||
|
||||
bool ListElement::process(InputEvents* event)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
// perform inertia scrolling for this element
|
||||
ret |= this->handleInertiaScroll(event);
|
||||
|
||||
ret |= super::process(event);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ListElement::handleInertiaScroll(InputEvents* event)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -7,5 +7,6 @@ class ListElement : public Element
|
||||
public:
|
||||
int highlighted = -1;
|
||||
int initialTouchDown = -1;
|
||||
bool process(InputEvents* event);
|
||||
bool handleInertiaScroll(InputEvents* event);
|
||||
};
|
||||
|
@ -165,6 +165,7 @@ bool MainDisplay::process(InputEvents* event)
|
||||
// add in the sidebar, footer, and main app listing
|
||||
Sidebar* sidebar = new Sidebar();
|
||||
this->elements.push_back(sidebar);
|
||||
|
||||
AppList* applist = new AppList(this->get, sidebar);
|
||||
this->elements.push_back(applist);
|
||||
sidebar->appList = applist;
|
||||
|
@ -13,12 +13,24 @@ void ProgressBar::render(Element* parent)
|
||||
if (this->percent < 0)
|
||||
return;
|
||||
|
||||
if (dimBg)
|
||||
{
|
||||
// draw a big dim layer around the entire window before drawing this progress bar
|
||||
SDL_Rect dim = { 0, 0, 1280, 720 };
|
||||
|
||||
SDL_SetRenderDrawBlendMode(parent->renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(parent->renderer, 0x00, 0x00, 0x00, 0xbb);
|
||||
SDL_RenderFillRect(parent->renderer, &dim);
|
||||
}
|
||||
|
||||
SDL_Rect location;
|
||||
int x = this->x + parent->x;
|
||||
int y = this->y + parent->y;
|
||||
|
||||
int blue = this->color;
|
||||
// int gray = 0x989898ff;
|
||||
|
||||
|
||||
|
||||
// draw full grayed out bar first
|
||||
SDL_Rect gray_rect;
|
||||
|
@ -8,6 +8,7 @@ public:
|
||||
float percent = 0;
|
||||
|
||||
int color;
|
||||
|
||||
bool dimBg = false;
|
||||
|
||||
int width = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user