despair 5 years ago
parent
commit
8dc2e81b54
  1. 18
      browser.ntrml
  2. 4
      src/WebResource.cpp
  3. 65
      src/graphics/components/Component.cpp
  4. 1
      src/graphics/elements/AElement.cpp
  5. 7
      src/graphics/text/TextRasterizer.cpp
  6. 1
      src/main.cpp

18
browser.ntrml

@ -1,19 +1,22 @@ @@ -1,19 +1,22 @@
<body color=000000FF bgcolor=CCCCCCCC>
<layer>
<!-- layers are used to control what's drawn on top of what -->
<layer> <!-- background layer -->
<img name="mascot" src="anime.pnm" width=512 height=512 left=60% bottom=0>
</layer>
<layer>
<box color=888888FF top=0 height=64 left=0 right=0></box>
<layer> <!-- document layer, on top of background -->
<!--
>what beyond the colors of the tabs would you want to change?
- The shape of the outline
- how close they stand together
+ how close they stand together
- Something I've really taken a liking to in firefox is how you can disable/enable sound from tabs with the icon in it's title. So perhaps a way to customize what kind of buttons (along with their functions) a tab can have would be nice too. Of course, that's not exactly something that should be prioritized.
-->
<tabSelector color=000000FF hover=888888FF left=0 width=100% top=64 bottom=0>
</tabSelector>
</layer>
<layer>
<layer> <!-- above document and below control layer -->
<box color=88888888 top=0 height=64 left=0 right=0></box>
</layer>
<layer> <!-- control layer -->
<box color=000000FF hover=880000FF left=32 width=32 top=16 height=32
onClick="back">
</box>
@ -23,8 +26,11 @@ @@ -23,8 +26,11 @@
<box color=000000FF hover=000088FF left=116 width=32 top=16 height=32
onClick="refresh">
</box>
<!-- fontSize doesn't work yet -->
<input color=000000FF bgcolor=FFFFFFFF left=192 right=192 top=16 height=24
onClick="address" fontSize=12>
<font top=16 height=16 right=0 width=192 src="DejaVuSerif.ttf" family="san-serif" size=12 color=000000FF bgcolor=FF0000>NetRunner</font>
<!-- family, onStatusBar and bgcolor don't work yet -->
<font top=16 height=16 right=0 width=192 src="DejaVuSerif.ttf" family="san-serif" size=12 color=000000FF bgcolor=FF0000FF>NetRunner</font>
<font bottom=0 height=16 left=0 width=192 src="DejaVuSerif.ttf" family="san-serif" size=12 color=000000FF bgcolor=FFFFFFFF onStatusBar="update">StatusBar: </font>
</layer>
</body>

4
src/WebResource.cpp

@ -118,6 +118,10 @@ WebResource getOnlineWebResource(URL const& url, std::unique_ptr<std::map<std::s @@ -118,6 +118,10 @@ WebResource getOnlineWebResource(URL const& url, std::unique_ptr<std::map<std::s
}
logDebug() << "Redirect To: " << location << std::endl;
redirectLocation = location;
// download redirect
returnRes = getOnlineWebResource(redirectLocation, nullptr);
} else if (response.statusCode != 200) {
returnRes.resourceType = ResourceType::INVALID;
returnRes.raw = "Unsupported status code";

65
src/graphics/components/Component.cpp

@ -69,7 +69,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -69,7 +69,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
if (properties.find("width") != properties.end()) {
boxSetup.width.requested = true;
if (properties["width"][properties["width"].size() - 1] == '%') {
std::cout << "Component::setUpUI - found width %" << std::endl;
//std::cout << "Component::setUpUI - found width %" << std::endl;
boxSetup.width.pct = std::stoi(properties["width"]);
} else {
boxSetup.width.px = std::stoi(properties["width"]);
@ -78,7 +78,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -78,7 +78,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
if (properties.find("height") != properties.end()) {
boxSetup.height.requested = true;
if (properties["height"][properties["height"].size() - 1] == '%') {
std::cout << "Component::setUpUI - found height %" << std::endl;
//std::cout << "Component::setUpUI - found height %" << std::endl;
boxSetup.height.pct = std::stoi(properties["height"]);
} else {
boxSetup.height.px = std::stoi(properties["height"]);
@ -87,7 +87,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -87,7 +87,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
if (properties.find("top") != properties.end()) {
boxSetup.top.requested = true;
if (properties["top"][properties["top"].size() - 1] == '%') {
std::cout << "Component::setUpUI - found top %" << std::endl;
//std::cout << "Component::setUpUI - found top %" << std::endl;
boxSetup.top.pct = std::stoi(properties["top"]);
} else {
boxSetup.top.px = std::stoi(properties["top"]);
@ -96,7 +96,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -96,7 +96,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
if (properties.find("bottom") != properties.end()) {
boxSetup.bottom.requested = true;
if (properties["bottom"][properties["bottom"].size() - 1] == '%') {
std::cout << "Component::setUpUI - found bottom %" << std::endl;
//std::cout << "Component::setUpUI - found bottom %" << std::endl;
boxSetup.bottom.pct = std::stoi(properties["bottom"]);
} else {
boxSetup.bottom.px = std::stoi(properties["bottom"]);
@ -105,7 +105,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -105,7 +105,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
if (properties.find("left") != properties.end()) {
boxSetup.left.requested = true;
if (properties["left"][properties["left"].size() - 1] == '%') {
std::cout << "Component::setUpUI - found left %" << std::endl;
//std::cout << "Component::setUpUI - found left %" << std::endl;
boxSetup.left.pct = std::stoi(properties["left"]);
} else {
boxSetup.left.px = std::stoi(properties["left"]);
@ -114,7 +114,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -114,7 +114,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
if (properties.find("right") != properties.end()) {
boxSetup.right.requested = true;
if (properties["right"][properties["right"].size() - 1] == '%') {
std::cout << "Component::setUpUI - found right %" << std::endl;
//std::cout << "Component::setUpUI - found right %" << std::endl;
boxSetup.right.pct = std::stoi(properties["right"]);
} else {
boxSetup.right.px = std::stoi(properties["right"]);
@ -123,11 +123,13 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -123,11 +123,13 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
std::unique_ptr<std::pair<UImetricV2, UImetricV2>> xUI = getUIMetric(boxSetup.left, boxSetup.right, boxSetup.width);
std::unique_ptr<std::pair<UImetricV2, UImetricV2>> yUI = getUIMetric(boxSetup.top, boxSetup.bottom, boxSetup.height);
int cX = 0, cY = 0, cW = boxSetup.width.px, cH = boxSetup.height.px;
int xPx = 0, yPx = 0;
double xPct = 0, yPct = 0;
double wPct = 100, hPct = 100;
int wPx = 0, hPx = 0;
int winWidth = pwin->windowWidth;
int winHeight = pwin->windowHeight;
//std::cout << "Component::setUpUI - laying out a " << typeOfComponent(this) << std::endl;
if (xUI) {
//std::cout << "box XUI at " << xUI->first.pct << "% +" << xUI->first.px << std::endl;
//std::cout << "box XUI for " << xUI->second.pct << "% +" << xUI->second.px << std::endl;
@ -138,6 +140,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -138,6 +140,7 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
// well we still need winHeight tho, because of the coords
cX = (xUI->first.pct * 0.01 * winWidth) + xUI->first.px;
xPct = xUI->first.pct;
xPx = xUI->first.px;
cW = (xUI->second.pct * 0.01 * winWidth) + xUI->second.px;
wPct = xUI->second.pct;
wPx = xUI->second.px;
@ -145,18 +148,23 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window * @@ -145,18 +148,23 @@ void Component::setUpUI(std::map<std::string, std::string> &properties, Window *
//std::cout << "Component::setUpUI W at " << wPct << "% for " << wPx << std::endl;
}
if (yUI) {
cY = (yUI->first.pct * 0.01 * winHeight) + yUI->first.px;
yPct = yUI->first.pct;
//std::cout << "Component::setUpUI pct" << yUI->first.pct << "/100 - " << yUI->first.px << std::endl;
cY = (yUI->first.pct * 0.01 * winHeight) - yUI->first.px;
// bottom=0 is 0, 0, so we do 100- here
yPct = 100 - yUI->first.pct;
yPx = yUI->first.px;
cH = (yUI->second.pct * 0.01 * winHeight) + yUI->second.px;
hPct = yUI->second.pct;
hPx = yUI->second.px;
//std::cout << "Component::setUpUI Y at " << cY << " for " << cH << std::endl;
//std::cout << "Component::setUpUI Y would be " << (-cH - cY) << " and new is " << yPx << std::endl;
//std::cout << "Component::setUpUI H at " << hPct << "% for " << hPx << std::endl;
}
// set up proper component information for resizing
this->uiControl.x = { 0, cX }; //
this->uiControl.y = { 100, -cH - cY }; //
this->uiControl.x = { xPct, xPx }; //
this->uiControl.y = { yPct, -cH - yPx }; //
this->uiControl.w = { wPct, wPx }; //
this->uiControl.h = { hPct, hPx }; //
@ -298,7 +306,33 @@ void Component::layout() { @@ -298,7 +306,33 @@ void Component::layout() {
}
} else {
// we're block
y = previous->y - previous->height;
y = previous->y - previous->height; // advance down one height
if (!previous->height) {
// ok if last is a nothing burger (0x0 size)
// then we need the parent height
// or we could spool to get the height for the last inline that's been set
// this isn't right
//y -= this->parent->height;
// this is bad because we assume there's only going to be one
std::shared_ptr<Component> pos = this->previous;
bool found = false;
while(pos->previous) {
pos = pos->previous;
if (!pos->isInline) {
std::cout << "found block element at " << pos->y << std::endl;
break;
}
if (pos->height) {
std::cout << "no size, grabbing height " << static_cast<int>(pos->height) << std::endl;
y -= pos->height;
found = true;
break;
}
}
if (!found) {
std::cout << "couldnt adjust height properly" << std::endl;
}
}
//std::cout << "Component::layout - inLine block" << std::endl;
}
} else {
@ -404,6 +438,7 @@ void Component::updateParentSize() { @@ -404,6 +438,7 @@ void Component::updateParentSize() {
// find max width of all siblings
unsigned int maxWidth = width; // float?
unsigned int heightAccum = 0;
unsigned int widthAccum = 0;
unsigned int totalHeight = 0;
// integrity check
@ -415,10 +450,12 @@ void Component::updateParentSize() { @@ -415,10 +450,12 @@ void Component::updateParentSize() {
// look at siblings
bool wasInline = false;
//std::cout << "Component::updateParentSize - assessing " << parent->children.size() << " children" << std::endl;
for (std::shared_ptr<Component> child : parent->children) {
maxWidth = std::max(maxWidth, static_cast<unsigned int>(child->width));
if (child->isInline) {
heightAccum = std::max(heightAccum, static_cast<unsigned int>(child->height));
widthAccum += child->width;
/*
if (wasInline) {
// in in
@ -434,15 +471,19 @@ void Component::updateParentSize() { @@ -434,15 +471,19 @@ void Component::updateParentSize() {
// flush height of previous line + our height
totalHeight += heightAccum + child->height;
heightAccum = 0; // reset
maxWidth = std::max(maxWidth, widthAccum);
widthAccum = 0;
} else {
// bl bl
totalHeight += child->height;
// than a max of all widths of the two is fine
}
}
wasInline = child->isInline;
}
// flush any remaining heightAccum
// flush any remaining width/heightAccum
totalHeight += heightAccum;
maxWidth = std::max(maxWidth, widthAccum);
//std::cout << "new size " << maxWidth << "x" << totalHeight << std::endl;
// did our size actually change

1
src/graphics/elements/AElement.cpp

@ -22,6 +22,7 @@ std::unique_ptr<Component> AElement::renderer(const ElementRenderRequest &reques @@ -22,6 +22,7 @@ std::unique_ptr<Component> AElement::renderer(const ElementRenderRequest &reques
// new window
// new tab
// same documentComponent (iframe, document, tab)
browser->getActiveDocumentComponent()->focusedComponent = nullptr;
browser->getActiveDocumentComponent()->navTo(hrefPair->second);
};
}

7
src/graphics/text/TextRasterizer.cpp

@ -133,7 +133,7 @@ std::unique_ptr<sizeResponse> TextRasterizer::size(const rasterizationRequest &r @@ -133,7 +133,7 @@ std::unique_ptr<sizeResponse> TextRasterizer::size(const rasterizationRequest &r
if (request.noWrap) {
glyphCount = i;
// we're done
std::cout << "TextRasterizer::size - newline found no wrap is on" << std::endl;
std::cout << "TextRasterizer::size - newline found no wrap is on [" << request.text << "]" << std::endl;
break;
} else {
xmax=std::max(xmax, cx);
@ -209,12 +209,11 @@ std::unique_ptr<sizeResponse> TextRasterizer::size(const rasterizationRequest &r @@ -209,12 +209,11 @@ std::unique_ptr<sizeResponse> TextRasterizer::size(const rasterizationRequest &r
response->height = textureHeight;
//std::cout << "adjusted:" << (int)width << "x" << (int)height << std::endl;
}
// inline position where we leave off
response->endingX = cx - request.sourceStartX;
response->endingY = cy + 2 + request.sourceStartY;
// FIXME: how about endingX,Y?
//return std::make_unique<std::pair<int, int>>(std::pair<int, int>(response->width, response->height));
return response;
}

1
src/main.cpp

@ -131,6 +131,7 @@ std::cout \ @@ -131,6 +131,7 @@ std::cout \
if (tabComponent) {
tabComponent->addTab("Start Tab, Loading...");
tabComponent->selectTab(tabComponent->tabs.front());
// render the loading label, before we block for loading
browser->render();
}
/*

Loading…
Cancel
Save