From 1a6cc0db3ad358cf0ef1335003e1f3945ff5bb65 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 19 Oct 2012 21:17:25 -0400 Subject: [PATCH] Rename wrapper/core variables to document. Rename AXRCore to AXRDocument and rename its files from AXRInitializer.* to AXRDocument.* Update some related documentation. This work is part of #169. --- src/TEST/AXRTestProducer.cpp | 20 +-- src/TEST/AXRTestProducer.h | 4 +- src/TEST/AXRTestRunner.cpp | 6 +- src/TEST/AXRTestRunner.h | 15 +-- src/TEST/AXRTestThread.cpp | 16 +-- src/TEST/AXRTestThread.h | 4 +- src/cocoa/AXRView.h | 6 +- src/cocoa/AXRView.mm | 2 +- src/core/AXRGlobal.h | 100 ++++++++++++++ src/core/axr/AXRController.cpp | 12 +- src/core/axr/AXRController.h | 8 +- .../{AXRInitializer.cpp => AXRDocument.cpp} | 126 +++++++++--------- .../axr/{AXRInitializer.h => AXRDocument.h} | 125 ++--------------- src/core/debug/AXRError.h | 3 +- src/core/hss/HSSTypeEnums.h | 2 +- src/core/hss/objects/HSSContainer.cpp | 72 +++++----- src/core/hss/objects/HSSDisplayObject.cpp | 10 +- src/core/hss/objects/HSSObject.cpp | 2 +- src/core/hss/objects/HSSTextBlock.cpp | 2 +- src/core/hss/objects/actions/HSSRequest.cpp | 28 ++-- src/core/hss/objects/actions/HSSRequest.h | 2 +- src/core/hss/parsing/HSSParser.cpp | 2 +- src/core/hss/parsing/HSSParser.h | 3 +- src/core/hss/parsing/filters/HSSFlag.cpp | 4 +- .../hss/parsing/functions/HSSFunction.cpp | 6 +- .../parsing/selectors/HSSParentSelector.cpp | 2 +- .../hss/parsing/selectors/HSSRootSelector.cpp | 10 +- src/core/rendering/AXRRender.cpp | 16 +-- src/core/rendering/AXRRender.h | 2 +- src/core/xml/XMLParser.cpp | 2 +- .../rendering/cocoa/CocoaAppDelegate.h | 4 +- .../rendering/cocoa/CocoaAppDelegate.mm | 6 +- src/examples/rendering/sdl/main.cpp | 32 ++--- src/prototype/AXRWidget.cpp | 12 +- src/prototype/AXRWidget.h | 8 +- src/prototype/PrototypeWindow.cpp | 30 ++--- 36 files changed, 341 insertions(+), 363 deletions(-) rename src/core/axr/{AXRInitializer.cpp => AXRDocument.cpp} (73%) rename src/core/axr/{AXRInitializer.h => AXRDocument.h} (58%) diff --git a/src/TEST/AXRTestProducer.cpp b/src/TEST/AXRTestProducer.cpp index 5838141d..041e0995 100644 --- a/src/TEST/AXRTestProducer.cpp +++ b/src/TEST/AXRTestProducer.cpp @@ -42,16 +42,16 @@ ********************************************************************/ #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRTestProducer.h" #include "AXRTestRunner.h" using namespace AXR; // Constructor with name and the queue to use -AXRTestProducer::AXRTestProducer(AXRTestRunner * wrapper, std::vector test, unsigned * totalTests, unsigned * totalPassed, HSSContainer::p status) +AXRTestProducer::AXRTestProducer(AXRTestRunner *runner, std::vector test, unsigned * totalTests, unsigned * totalPassed, HSSContainer::p status) { - this->wrapper = wrapper; + this->runner = runner; this->test = test; this->totalPassed = totalPassed; this->totalTests = totalTests; @@ -76,16 +76,16 @@ void AXRTestProducer::operator () () AXRString expectedRep; //load the XML - AXRCore *core = AXRCore::getInstance(); + AXRDocument *document = AXRDocument::getInstance(); - testLoaded = core->loadXMLFile(this->test[0]); + testLoaded = document->loadXMLFile(this->test[0]); if (testLoaded) { - AXRController::p controller = core->getController(); + AXRController::p controller = document->getController(); HSSContainer::p root = controller->getRoot(); - core->getRender()->windowWidth = 400.; - core->getRender()->windowHeight = 400.; + document->getRender()->windowWidth = 400.; + document->getRender()->windowHeight = 400.; root->recursiveReadDefinitionObjects(); root->recursiveLayout(); testRep = root->toString(); @@ -99,7 +99,7 @@ void AXRTestProducer::operator () () //load the "expected" file if (testLoaded) { - AXRBuffer::p expectedFile = core->getFile(test[1]); + AXRBuffer::p expectedFile = document->getFile(test[1]); if (!expectedFile->isValid()) { std_log("could not load file with expected results"); @@ -125,7 +125,7 @@ void AXRTestProducer::operator () () this->statusMutex.lock(); this->status->setContentText(AXRString("Passed %1 out of %2").arg(*this->totalPassed).arg(*this->totalTests)); this->statusMutex.unlock(); - core->setNeedsDisplay(true); + document->setNeedsDisplay(true); } else { diff --git a/src/TEST/AXRTestProducer.h b/src/TEST/AXRTestProducer.h index f82f891e..e030f5ae 100644 --- a/src/TEST/AXRTestProducer.h +++ b/src/TEST/AXRTestProducer.h @@ -56,7 +56,7 @@ namespace AXR class AXR_API AXRTestProducer : public QRunnable { private: - AXRTestRunner * wrapper; + AXRTestRunner *runner; std::vector test; // the filename of the test unsigned * totalTests; unsigned * totalPassed; @@ -66,7 +66,7 @@ namespace AXR static QMutex statusMutex; public: - AXRTestProducer(AXRTestRunner *testRunner, std::vector test, unsigned * totalTests, unsigned * totalPassed, HSSContainer::p status); + AXRTestProducer(AXRTestRunner *runner, std::vector test, unsigned * totalTests, unsigned * totalPassed, HSSContainer::p status); void operator () (); void run(); }; diff --git a/src/TEST/AXRTestRunner.cpp b/src/TEST/AXRTestRunner.cpp index d212a125..562722e1 100644 --- a/src/TEST/AXRTestRunner.cpp +++ b/src/TEST/AXRTestRunner.cpp @@ -46,7 +46,7 @@ #include #include #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRTestThread.h" #include "AXRTestRunner.h" #include "AXRWarning.h" @@ -77,8 +77,8 @@ AXRString AXRTestRunner::getPathToTestsFile() void AXRTestRunner::executeLayoutTests(HSSObservableProperty passnull, void*data) { HSSContainer::p status; - AXRCore* core = AXRCore::getInstance(); - HSSContainer::p root = core->getController()->getRoot(); + AXRDocument* document = AXRDocument::getInstance(); + HSSContainer::p root = document->getController()->getRoot(); std::deque arguments = *(std::deque*)data; for (std::deque::iterator it = arguments.begin(); it != arguments.end(); ++it) diff --git a/src/TEST/AXRTestRunner.h b/src/TEST/AXRTestRunner.h index ca14c9b4..e932a609 100644 --- a/src/TEST/AXRTestRunner.h +++ b/src/TEST/AXRTestRunner.h @@ -41,8 +41,8 @@ * ********************************************************************/ -#ifndef AXRWRAPPER_H -#define AXRWRAPPER_H +#ifndef AXRTESTRUNNER_H +#define AXRTESTRUNNER_H #include #include @@ -56,22 +56,11 @@ namespace AXR { - /** - * @brief This is the abstract superclass from with all OS-specific wrappers - * should inherit from. - */ class AXR_API AXRTestRunner { public: - /** - * Creates a new instance of the wrapper. It will obtain the singleton instance of - * the AXRCore and initialize it. - */ AXRTestRunner(); - /** - * Destructs the wrapper - */ virtual ~AXRTestRunner(); virtual AXRString getPathToTestsFile(); diff --git a/src/TEST/AXRTestThread.cpp b/src/TEST/AXRTestThread.cpp index d38e2d8b..5717d715 100644 --- a/src/TEST/AXRTestThread.cpp +++ b/src/TEST/AXRTestThread.cpp @@ -42,7 +42,7 @@ ********************************************************************/ #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRTestProducer.h" #include "AXRTestRunner.h" #include "AXRTestThread.h" @@ -50,9 +50,9 @@ using namespace AXR; -AXRTestThread::AXRTestThread(AXRTestRunner * wrapper, QUrl url, HSSContainer::p status) +AXRTestThread::AXRTestThread(AXRTestRunner *runner, QUrl url, HSSContainer::p status) { - this->wrapper = wrapper; + this->runner = runner; this->url = url; this->totalPassed = 0; this->totalTests = 0; @@ -69,16 +69,16 @@ void AXRTestThread::operator () () try { //load the XML file - AXRCore* core = AXRCore::getInstance(); - XMLParser::p parser = core->getParserXML(); + AXRDocument* document = AXRDocument::getInstance(); + XMLParser::p parser = document->getParserXML(); HSSContainer::p status = this->status; - AXRBuffer::p testsFile = core->getFile(this->url); + AXRBuffer::p testsFile = document->getFile(this->url); bool loadingSuccess = parser->loadFile(testsFile); if (loadingSuccess) { //find all the tests that need to be executed std::vector > tests; - AXRController::p controller = core->getController(); + AXRController::p controller = document->getController(); HSSContainer::p root = controller->getRoot(); const std::vector & children = root->getChildren(true); @@ -102,7 +102,7 @@ void AXRTestThread::operator () () for (std::vector >::iterator it2 = tests.begin(); it2 != tests.end(); ++it2) { - AXRTestProducer prdcr(this->wrapper, *it2, &this->totalTests, &this->totalPassed, status); + AXRTestProducer prdcr(this->runner, *it2, &this->totalTests, &this->totalPassed, status); producers.start(&prdcr); QThread::yieldCurrentThread(); } diff --git a/src/TEST/AXRTestThread.h b/src/TEST/AXRTestThread.h index 81813883..11bbaa69 100644 --- a/src/TEST/AXRTestThread.h +++ b/src/TEST/AXRTestThread.h @@ -55,14 +55,14 @@ namespace AXR class AXR_API AXRTestThread : public QThread { private: - AXRTestRunner *wrapper; + AXRTestRunner *runner; QUrl url; unsigned totalTests; unsigned totalPassed; HSSContainer::p status; public: - AXRTestThread(AXRTestRunner *testRunner, QUrl url, HSSContainer::p status); + AXRTestThread(AXRTestRunner *runner, QUrl url, HSSContainer::p status); void operator () (); void run(); }; diff --git a/src/cocoa/AXRView.h b/src/cocoa/AXRView.h index 4a32aa7e..8df174e4 100644 --- a/src/cocoa/AXRView.h +++ b/src/cocoa/AXRView.h @@ -45,7 +45,7 @@ namespace AXR { - class AXRCore; + class AXRDocument; } /** @@ -55,13 +55,13 @@ namespace AXR @interface AXRView : NSView { @private - AXR::AXRCore *document; + AXR::AXRDocument *document; } /** * The AXR document being rendered by the view. */ -@property(assign) AXR::AXRCore* document; +@property(assign) AXR::AXRDocument* document; /** * @return YES. This is for optimizing the drawing. diff --git a/src/cocoa/AXRView.mm b/src/cocoa/AXRView.mm index 6bb0a4af..8057e94d 100644 --- a/src/cocoa/AXRView.mm +++ b/src/cocoa/AXRView.mm @@ -45,7 +45,7 @@ #import #import "AXRController.h" #import "AXRDebugging.h" -#import "AXRInitializer.h" +#import "AXRDocument.h" #import "AXRView.h" #import "HSSContainer.h" #import "HSSEvent.h" diff --git a/src/core/AXRGlobal.h b/src/core/AXRGlobal.h index 56f4579f..3c464327 100644 --- a/src/core/AXRGlobal.h +++ b/src/core/AXRGlobal.h @@ -41,6 +41,106 @@ * ********************************************************************/ +/** + * @mainpage AXR Prototype Documentation Overview + * + * Welcome to the documentation of the AXR prototype! It was automatically generated from the + * JavaDoc-style comment blocks that are in the header (.h) files, with a tool called Doxygen. + * + * The goal of this document is to provide an overview of how the code is structured, how the + * different classes relate to each other and, in general terms, how text files containing + * source code is transformed into pixels on screen at the end. + * + * Most of the code is C++, which was chosen because of wide interoperability and existence of + * libraries and resources, as well as the native speed and fine grained control when flipping + * bits a rendering engine needs. + * + * We manage the code via GitHub, as well as the issues for bugs and stuff like that. If you'd + * like to contribute, you should create a GitHub account if you don't have one already and + * then click the "Fork" button on https://github.com/AXR/Prototype. You then need to download, + * or "clone" the repository to your computer (install git if you don't have it already). + * Execute the following commands in the command line: + * + * cd path/to/directory + * git clone https://github.com/yourusername/Prototype.git + * + * @section folders Diving into the folder structure + * + * Let's have a look at what's inside the repository folder: + * + * - src/core: this is the core library of the rendering engine + * - src/app: prototype application used to test AXE's functionality + * - tests: this is a bunch of XML and HSS files that were used when developing the library + * + * In Xcode you can use Interface Builder and make a custom view to be of the AXRView class + * and interact with it directly. + * + * Now let's focus on the core. In it we find the AXR.h file that contains the AXRDocument class, + * which encapsulates the library, and the following folders: + * + * - axr: Here we find the guts of the library which is not related to one specific language + * but manage stuff across the rendering engine. + * - hss: In here we find the HSS parser, the parser nodes and all the object types. + * - xml: In here we find the XML parser + * + * @section parsing Parsing the content and getting up and runnig + * + * So you will probably be wondering, where do we start? This of course depends on how you + * are embedding it, but in a general sense, you will create an \a AXRDocument instance + * and then tell it to load a file by pathname. When the path is to a XML file, it gets the + * file and sets it on the core, then calls the run() method on it. If it is to an HSS file, + * it will create a dummy XML file on the fly, which contains only one element called "root". + * + * So now let's jump to AXRDocument.cpp, and have a look at the run() method. It gives the XML + * file to the XML parser. We currently use Qt, and the file XMLParser.cpp parses the + * elements and adds them on axr/AXRController.cpp using enterElement(), addAttribute(), + * appendContentText() and exitElement(). + * + * When it finds an XML instruction it will parse it and if it is a link to a HSS stylesheet + * it calls loadSheetsAdd() on the controller to take note. Which brings us back to + * AXRDocument::run(), where we now pass all the stylesheets that were found to the HSS parser. + * + * Similarly to how the XMl parser does, the hss/parsing/HSSParser.cpp calls rulesAdd(), + * parserTreeAdd(), and objectTreeAdd() on the controller, and then we loop over the found + * rules and recursively match them to the content tree. On each of the matched elements, + * setNeedsRereadRules(true) is called, so that before the next (and first) time we draw, the + * properties from the rules are passed into each "definition object setter" (those which look + * like setD()), where they will be stored according to the value type that + * is passed. + * + * @section drawing Drawing on screen + * + * Currently for drawing we are using Qt. + * + * When the OS asks for drawing, it is the duty of the client app to tell the core to draw in a given + * rectangle (the current implementation still always redraws the whole screen, though), which will then + * get get to the AXRRender class. This one will check if the window size has changed, and if so change + * the width and height of the root object. It will then tell the root element to recursively read the + * "definition objects", which are the HSSParserNodes that hold the values (inside property definitions, + * which in turn are inside the rules that are associated with the elements) into the instance + * variables that hold the actual calculated values that will determine how and where the stuff is rendered. + * + * Next, it tells it to recursively layout, which is a process in which display objects arrange the things + * that are inside, such as text in the case of HSSTextBlock elements or other display objects in the case of + * HSSContainer. + * + * Then it will regenerate all the surfaces as needed and finally it will tell it to draw, also as a + * recursive operation, and finally composites all the individual surfaces of the objects into the final + * surface which is retrieved by the client and blitted onto the screen in an OS and toolkit-dependent manner. + * + * In the process of drawing, each object type which draws (display objects) implements and handles + * all the properties inside to calculate the visual rendering, each generating bitmap surfaces for the + * background, borders, etc, and finally compositing it all together. + * + * This is all done in a pretty straightforward an naïve way, and should receive quite a lot of facelifting + * and perfomance improvements in the near future. + * + * @section diagram Diagram of the structure of the library + * + * In the following diagram you can see a graphical representation of how the AXR core library is structured: + * @image html library-structure.jpg + */ + #ifndef AXRGLOBAL_H #define AXRGLOBAL_H diff --git a/src/core/axr/AXRController.cpp b/src/core/axr/AXRController.cpp index 581f0cb4..112b75a6 100644 --- a/src/core/axr/AXRController.cpp +++ b/src/core/axr/AXRController.cpp @@ -43,7 +43,7 @@ #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" #include "HSSDisplayObject.h" #include "HSSFlag.h" @@ -53,8 +53,8 @@ using namespace AXR; -AXRController::AXRController(AXRCore *core) -: core(core) +AXRController::AXRController(AXRDocument *document) +: document_(document) { axr_log(AXR_DEBUG_CH_GENERAL | AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRController: creating controller"); this->currentContext = std::stack (); @@ -70,9 +70,9 @@ AXRController::~AXRController() this->parserTree.clear(); } -AXRCore* AXRController::document() const +AXRDocument* AXRController::document() const { - return core; + return document_; } void AXRController::matchRulesToContentTree() @@ -691,7 +691,7 @@ HSSContainer::p & AXRController::getRoot() void AXRController::setRoot(HSSContainer::p newRoot) { this->root = newRoot; - HSSParser::p hssparser = this->core->getParserHSS(); + HSSParser::p hssparser = this->document()->getParserHSS(); if (hssparser->currentObjectContextSize() == 0) { hssparser->currentObjectContextAdd(newRoot); diff --git a/src/core/axr/AXRController.h b/src/core/axr/AXRController.h index 2e536007..fc1565c7 100644 --- a/src/core/axr/AXRController.h +++ b/src/core/axr/AXRController.h @@ -53,7 +53,7 @@ namespace AXR { class AXRRender; - class AXRCore; + class AXRDocument; /** * @brief This class holds trees of objects, sheets, rules and the parser tree. Also, @@ -71,14 +71,14 @@ namespace AXR * Creates a new instance of a controller. * */ - AXRController(AXRCore *core); + AXRController(AXRDocument *document); /** * Destructs the controller and clears all the trees. */ virtual ~AXRController(); - AXRCore* document() const; + AXRDocument* document() const; void matchRulesToContentTree(); @@ -421,7 +421,7 @@ namespace AXR bool isAtEndOfSelector(); private: - AXRCore *core; + AXRDocument *document_; void _recursiveGetDescendants(std::vector &ret, const std::vector & scope); }; } diff --git a/src/core/axr/AXRInitializer.cpp b/src/core/axr/AXRDocument.cpp similarity index 73% rename from src/core/axr/AXRInitializer.cpp rename to src/core/axr/AXRDocument.cpp index f2a13b44..c11424d4 100644 --- a/src/core/axr/AXRInitializer.cpp +++ b/src/core/axr/AXRDocument.cpp @@ -44,23 +44,23 @@ #include #include #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" using namespace AXR; -AXRCore* AXRCore::getInstance() +AXRDocument* AXRDocument::getInstance() { - static QThreadStorage theInstance; + static QThreadStorage theInstance; if (!theInstance.localData()) { - theInstance.setLocalData(new AXRCore()); + theInstance.setLocalData(new AXRDocument()); } return theInstance.localData(); } -AXRCore::AXRCore() +AXRDocument::AXRDocument() { this->_isHSSOnly = false; this->_hasLoadedFile = false; @@ -70,7 +70,7 @@ AXRCore::AXRCore() this->_currentLayoutChild = 0; this->_needsDisplay = true; - axr_log(AXR_DEBUG_CH_GENERAL | AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRCore: initializing core for thread"); + axr_log(AXR_DEBUG_CH_GENERAL | AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRDocument: initializing core for thread"); AXRController::p ctrlr = AXRController::p(new AXRController(this)); this->setController(ctrlr); @@ -80,12 +80,12 @@ AXRCore::AXRCore() this->_hasLoadedFile = false; } -AXRCore::~AXRCore() +AXRDocument::~AXRDocument() { - axr_log(AXR_DEBUG_CH_GENERAL | AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRCore: destructing core"); + axr_log(AXR_DEBUG_CH_GENERAL | AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRDocument: destructing core"); } -void AXRCore::drawInRectWithBounds(HSSRect rect, HSSRect bounds) +void AXRDocument::drawInRectWithBounds(HSSRect rect, HSSRect bounds) { if (this->render) { @@ -93,7 +93,7 @@ void AXRCore::drawInRectWithBounds(HSSRect rect, HSSRect bounds) } } -AXRString AXRCore::getPathToResources() const +AXRString AXRDocument::getPathToResources() const { // TODO: it's best to do this in a different way entirely... the library // shouldn't be using the client process's directory to determine where @@ -110,18 +110,18 @@ AXRString AXRCore::getPathToResources() const return dir.canonicalPath(); } -void AXRCore::run() +void AXRDocument::run() { - axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRCore: running"); + axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRDocument: running"); bool loadingSuccess = this->parserXML->loadFile(this->file); - axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRCore: finished parsing " + this->file->sourceUrl().toString()); + axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRDocument: finished parsing " + this->file->sourceUrl().toString()); axr_log(AXR_DEBUG_CH_FULL_FILENAMES, this->file->sourceUrl().toString()); if (!loadingSuccess) { - AXRError("AXRCore", "Could not load the XML file").raise(); + AXRError("AXRDocument", "Could not load the XML file").raise(); } else { @@ -146,13 +146,13 @@ void AXRCore::run() if (!this->parserHSS->loadFile(hssfile)) { - AXRError("AXRCore", "Could not load the HSS file").raise(); + AXRError("AXRDocument", "Could not load the HSS file").raise(); } } - axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRCore: finished loading stylesheets for " + this->file->sourceUrl().toString()); + axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRDocument: finished loading stylesheets for " + this->file->sourceUrl().toString()); axr_log(AXR_DEBUG_CH_FULL_FILENAMES, this->file->sourceUrl().toString()); - axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRCore: matching rules to the content tree"); + axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRDocument: matching rules to the content tree"); //assign the rules to the objects this->controller->matchRulesToContentTree(); root->setNeedsRereadRules(true); @@ -164,10 +164,10 @@ void AXRCore::run() } } - axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRCore: run complete, entering event loop\n\n\n"); + axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRDocument: run complete, entering event loop\n\n\n"); } -void AXRCore::reset() +void AXRDocument::reset() { this->controller->reset(); this->parserHSS->reset(); @@ -178,73 +178,73 @@ void AXRCore::reset() this->file.clear(); } -bool AXRCore::hasLoadedFile() +bool AXRDocument::hasLoadedFile() { return _hasLoadedFile; } -AXRController::p AXRCore::getController() +AXRController::p AXRDocument::getController() { return this->controller; } -void AXRCore::setController(AXRController::p controller) +void AXRDocument::setController(AXRController::p controller) { this->controller = controller; } -AXRRender::p AXRCore::getRender() +AXRRender::p AXRDocument::getRender() { return this->render; } -void AXRCore::setRender(AXRRender::p render) +void AXRDocument::setRender(AXRRender::p render) { this->render = render; } -AXRBuffer::p AXRCore::getFile() +AXRBuffer::p AXRDocument::getFile() { return this->file; } -void AXRCore::setFile(AXRBuffer::p file) +void AXRDocument::setFile(AXRBuffer::p file) { this->file = file; } -XMLParser::p AXRCore::getParserXML() +XMLParser::p AXRDocument::getParserXML() { return this->parserXML; } -void AXRCore::setParserXML(XMLParser::p parser) +void AXRDocument::setParserXML(XMLParser::p parser) { this->parserXML = parser; } -HSSParser::p AXRCore::getParserHSS() +HSSParser::p AXRDocument::getParserHSS() { return this->parserHSS; } -void AXRCore::setParserHSS(HSSParser::p parser) +void AXRDocument::setParserHSS(HSSParser::p parser) { this->parserHSS = parser; } -bool AXRCore::isCustomFunction(AXRString name) +bool AXRDocument::isCustomFunction(AXRString name) { bool ret = this->_customFunctions.find(name) != this->_customFunctions.end(); return ret; } -void AXRCore::registerCustomFunction(AXRString name, HSSCallback* fn) +void AXRDocument::registerCustomFunction(AXRString name, HSSCallback* fn) { this->_customFunctions[name] = fn; } -void AXRCore::evaluateCustomFunction(AXRString name, void* data) +void AXRDocument::evaluateCustomFunction(AXRString name, void* data) { if (this->isCustomFunction(name)) { @@ -252,7 +252,7 @@ void AXRCore::evaluateCustomFunction(AXRString name, void* data) } } -AXRBuffer::p AXRCore::getFile(QUrl u) +AXRBuffer::p AXRDocument::getFile(QUrl u) { if (u.isValid()) { @@ -262,11 +262,11 @@ AXRBuffer::p AXRCore::getFile(QUrl u) AXRBuffer::p ret = AXRBuffer::p(new AXRBuffer(fi)); if (!fi.exists()) { - throw AXRError("AXRWrapper", "the file " + u.toLocalFile() + " doesn't exist"); + throw AXRError("AXRDocument", "the file " + u.toLocalFile() + " doesn't exist"); } else if (!ret->isValid()) { - throw AXRError("AXRWrapper", "the file " + u.toLocalFile() + " couldn't be read"); + throw AXRError("AXRDocument", "the file " + u.toLocalFile() + " couldn't be read"); } return ret; @@ -280,19 +280,19 @@ AXRBuffer::p AXRCore::getFile(QUrl u) return AXRBuffer::p(new AXRBuffer()); } -bool AXRCore::needsDisplay() const +bool AXRDocument::needsDisplay() const { return this->_needsDisplay; } -void AXRCore::setNeedsDisplay(bool newValue) +void AXRDocument::setNeedsDisplay(bool newValue) { this->_needsDisplay = newValue; } -AXRBuffer::p AXRCore::createDummyXML(QUrl hssUrl) +AXRBuffer::p AXRDocument::createDummyXML(QUrl hssUrl) { - axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRWrapper: creating dummy XML file for HSS file " + hssUrl.toString()); + axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRDocument: creating dummy XML file for HSS file " + hssUrl.toString()); if (hssUrl.isValid()) { @@ -301,12 +301,12 @@ AXRBuffer::p AXRCore::createDummyXML(QUrl hssUrl) } else { - AXRError("AXRWrapper", "Could not create dummy XML for invalid HSS file URL").raise(); + AXRError("AXRDocument", "Could not create dummy XML for invalid HSS file URL").raise(); return AXRBuffer::p(new AXRBuffer()); } } -bool AXRCore::loadFileByPath(QUrl url) +bool AXRDocument::loadFileByPath(QUrl url) { if (url.isRelative()) { @@ -316,12 +316,12 @@ bool AXRCore::loadFileByPath(QUrl url) } else { - AXRError("AXRWrapper", "Could not load relative URL as main file", url).raise(); + AXRError("AXRDocument", "Could not load relative URL as main file", url).raise(); return false; } } - axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRWrapper: loading file " + url.toString()); + axr_log(AXR_DEBUG_CH_OVERVIEW, "AXRDocument: loading file " + url.toString()); axr_log(AXR_DEBUG_CH_FULL_FILENAMES, url.toString()); QFileInfo pathInfo(url.path()); @@ -341,9 +341,9 @@ bool AXRCore::loadFileByPath(QUrl url) } } -bool AXRCore::loadXMLFile(QUrl url) +bool AXRDocument::loadXMLFile(QUrl url) { - axr_log(AXR_DEBUG_CH_OVERVIEW, AXRString("AXRWrapper: opening XML document: %1").arg(url.toString())); + axr_log(AXR_DEBUG_CH_OVERVIEW, AXRString("AXRDocument: opening XML document: %1").arg(url.toString())); this->_isHSSOnly = false; this->_showLayoutSteps = false; @@ -381,9 +381,9 @@ bool AXRCore::loadXMLFile(QUrl url) return true; } -bool AXRCore::loadXMLFile(AXRBuffer::p buffer) +bool AXRDocument::loadXMLFile(AXRBuffer::p buffer) { - axr_log(AXR_DEBUG_CH_OVERVIEW, AXRString("AXRWrapper: opening XML document from buffer")); + axr_log(AXR_DEBUG_CH_OVERVIEW, AXRString("AXRDocument: opening XML document from buffer")); this->_isHSSOnly = false; this->_showLayoutSteps = false; @@ -420,7 +420,7 @@ bool AXRCore::loadXMLFile(AXRBuffer::p buffer) return true; } -bool AXRCore::reload() +bool AXRDocument::reload() { this->_showLayoutSteps = false; this->_currentLayoutStep = 0; @@ -435,7 +435,7 @@ bool AXRCore::reload() } else { - AXRWarning("AXRWrapper", "no file loaded").raise(); + AXRWarning("AXRDocument", "no file loaded").raise(); return false; } } @@ -445,9 +445,9 @@ bool AXRCore::reload() } } -bool AXRCore::loadHSSFile(QUrl url) +bool AXRDocument::loadHSSFile(QUrl url) { - axr_log(AXR_DEBUG_CH_OVERVIEW, AXRString("AXRWrapper: opening HSS document: %1").arg(url.toString())); + axr_log(AXR_DEBUG_CH_OVERVIEW, AXRString("AXRDocument: opening HSS document: %1").arg(url.toString())); this->_isHSSOnly = true; this->_showLayoutSteps = false; @@ -467,17 +467,17 @@ bool AXRCore::loadHSSFile(QUrl url) return true; } -void AXRCore::setShowLayoutSteps(bool value) +void AXRDocument::setShowLayoutSteps(bool value) { this->_showLayoutSteps = value; } -bool AXRCore::showLayoutSteps() +bool AXRDocument::showLayoutSteps() { return this->_showLayoutSteps; } -void AXRCore::previousLayoutStep() +void AXRDocument::previousLayoutStep() { if (this->_currentLayoutStep > 0) { @@ -489,7 +489,7 @@ void AXRCore::previousLayoutStep() this->setNeedsDisplay(true); } -void AXRCore::nextLayoutStep() +void AXRDocument::nextLayoutStep() { this->_currentLayoutStep += 1; this->_currentLayoutTick = 0; @@ -497,39 +497,39 @@ void AXRCore::nextLayoutStep() this->setNeedsDisplay(true); } -void AXRCore::nextLayoutTick() +void AXRDocument::nextLayoutTick() { this->_currentLayoutTick += 1; } -void AXRCore::resetLayoutTicks() +void AXRDocument::resetLayoutTicks() { this->_currentLayoutTick = 0; } -bool AXRCore::layoutStepDone() +bool AXRDocument::layoutStepDone() { return this->_currentLayoutTick >= this->_currentLayoutStep; } -void AXRCore::breakIfNeeded() +void AXRDocument::breakIfNeeded() { bool breakvar = _currentLayoutTick >= (_currentLayoutStep - 1); axr_log(AXR_DEBUG_CH_GENERAL_SPECIFIC, AXRString("currentLayoutTick = %1, currentLayoutStep = %2, %3").arg(_currentLayoutTick).arg(_currentLayoutStep).arg(breakvar)); } -void AXRCore::nextLayoutChild() +void AXRDocument::nextLayoutChild() { this->_currentLayoutChild += 1; } -void AXRCore::resetLayoutChild() +void AXRDocument::resetLayoutChild() { this->_currentLayoutChild = 0; } -bool AXRCore::layoutChildDone() +bool AXRDocument::layoutChildDone() { return this->_currentLayoutTick >= this->_currentLayoutChild + 1; } diff --git a/src/core/axr/AXRInitializer.h b/src/core/axr/AXRDocument.h similarity index 58% rename from src/core/axr/AXRInitializer.h rename to src/core/axr/AXRDocument.h index 847a2a3c..eb2b3942 100644 --- a/src/core/axr/AXRInitializer.h +++ b/src/core/axr/AXRDocument.h @@ -41,117 +41,8 @@ * ********************************************************************/ -//This line is dedicated to the memory of Steven P. Jobs, may he rest in peace. -//Farewell, Steve! - - - -/** - * @mainpage AXR Prototype Documentation Overview - * - * Welcome to the documentation of the AXR prototype! It was automatically generated from the - * JavaDoc-style comment blocks that are in the header (.h) files, with a tool called Doxygen. - * - * The goal of this document is to provide an overview of how the code is structured, how the - * different classes relate to each other and, in general terms, how text files containing - * source code is transformed into pixels on screen at the end. - * - * Most of the code is C++, which was chosen because of wide interoperability and existence of - * libraries and resources, as well as the native speed and fine grained control when flipping - * bits a rendering engine needs. - * - * We manage the code via GitHub, as well as the issues for bugs and stuff like that. If you'd - * like to contribute, you should create a GitHub account if you don't have one already and - * then click the "Fork" button on https://github.com/AXR/Prototype. You then need to download, - * or "clone" the repository to your computer (install git if you don't have it already). - * Execute the following commands in the command line: - * - * cd path/to/directory - * git clone https://github.com/yourusername/Prototype.git - * - * @section folders Diving into the folder structure - * - * Let's have a look at what's inside the repository folder: - * - * - src/core: this is the core library of the rendering engine - * - src/app: prototype application used to test AXE's functionality - * - tests: this is a bunch of XML and HSS files that were used when developing the library - * - * The library follows a core/wrapper pattern that allows to embed it wherever needed, it's - * just a matter of creating a platform specific wrapper. On OS X you can use Interface Builder - * and make a custom view to be of the AXRView class and interact with it directly. - * - * Now let's focus on the core. In it we find the AXR.h file that contains the AXRCore class, - * which encapsulates the library, and the following folders: - * - * - axr: Here we find the guts of the library which is not related to one specific language - * but manage stuff across the rendering engine. - * - hss: In here we find the HSS parser, the parser nodes and all the object types. - * - xml: In here we find the XML parser - * - * @section parsing Parsing the content and getting up and runnig - * - * So you will probably be wondering, where do we start? This of course depends on how you - * are embedding it, but in a general sense, you (or in case of OS X, the provided NSView - * subclass) will create a platform specific wrapper and then tell it to load a file either - * via a file open dialog or by pathname. The implementation of this method is in the - * abstract superclass in axr/AXRWrapper.cpp. When the path is to a XML file, it gets the - * file (implemented by the platform specific wrapper) and sets it on the core, then calls - * the run() method on it. If it is to an HSS file, it will create a dummy XML file on the - * fly, which contains only one element called "root". - * - * So now let's jump to ../AXR.cpp, and have a look at the run() method. It gives the XML - * file to the XML parser. We currently use Qt, and the file XMLParser.cpp parses the - * elements and adds them on axr/AXRController.cpp using enterElement(), addAttribute(), - * appendContentText() and exitElement(). - * - * When it finds an XML instruction it will parse it and if it is a link to a HSS stylesheet - * it calls loadSheetsAdd() on the controller to take note. Which brings us back to - * AXRCore::run(), where we now pass all the stylesheets that were found to the HSS parser. - * - * Similarly to how the XMl parser does, the hss/parsing/HSSParser.cpp calls rulesAdd(), - * parserTreeAdd(), and objectTreeAdd() on the controller, and then we loop over the found - * rules and recursively match them to the content tree. On each of the matched elements, - * setNeedsRereadRules(true) is called, so that before the next (and first) time we draw, the - * properties from the rules are passed into each "definition object setter" (those which look - * like setD()), where they will be stored according to the value type that - * is passed. - * - * @section drawing Drawing on screen - * - * Currently for drawing we are using Qt. - * - * When the OS asks for drawing, it is the duty of the wrapper to tell the core to draw in a given - * rectangle (the current implementation still always redraws the whole screen, though), which will then - * get get to the AXRRender class. This one will check if the window size has changed, and if so change - * the width and height of the root object. It will then tell the root element to recursively read the - * "definition objects", which are the HSSParserNodes that hold the values (inside property definitions, - * which in turn are inside the rules that are associated with the elements) into the instance - * variables that hold the actual calculated values that will determine how and where the stuff is rendered. - * - * Next, it tells it to recursively layout, which is a process in which display objects arrange the things - * that are inside, such as text in the case of HSSTextBlock elements or other display objects in the case of - * HSSContainer. - * - * Then it will regenerate all the surfaces as needed and finally it will tell it to draw, also as a - * recursive operation, and finally composites all the individual surfaces of the objects into the final - * surface which is retrieved by the client and blitted onto the screen in an OS and toolkit-dependent manner. - * - * In the process of drawing, each object type which draws (display objects) implements and handles - * all the properties inside to calculate the visual rendering, each generating bitmap surfaces for the - * background, borders, etc, and finally compositing it all together. - * - * This is all done in a pretty straightforward an naïve way, and should receive quite a lot of facelifting - * and perfomance improvements in the near future. - * - * @section diagram Diagram of the structure of the library - * - * In the following diagram you can see a graphical representation of how the AXR core library is structured: - * @image html library-structure.jpg - */ - -#ifndef AXR_H -#define AXR_H +#ifndef AXRDOCUMENT_H +#define AXRDOCUMENT_H #include #include @@ -169,20 +60,20 @@ namespace AXR * This class cannot be instantiated directly. Instead, call the getInstance() method * to retrieve a thread-specific shared pointer to a singleton instance. */ - class AXR_API AXRCore + class AXR_API AXRDocument { public: /** * Whenever you need to access the core object use this method, - * as AXRCore is a per-thread-singleton, where 1 instance is created for each thread that uses AXRCore. + * as AXRDocument is a per-thread-singleton, where 1 instance is created for each thread that uses AXRDocument. * @return A thread specific pointer to core for this thread */ - static AXRCore* getInstance(); + static AXRDocument* getInstance(); /** * Destroys the object */ - virtual ~AXRCore(); + virtual ~AXRDocument(); /** * Main drawing function. @@ -368,9 +259,9 @@ namespace AXR private: /** - * Creates a new AXRCore object. + * Creates a new AXRDocument object. */ - AXRCore(); + AXRDocument(); }; } diff --git a/src/core/debug/AXRError.h b/src/core/debug/AXRError.h index c844176f..511f6574 100644 --- a/src/core/debug/AXRError.h +++ b/src/core/debug/AXRError.h @@ -72,8 +72,7 @@ namespace AXR virtual ~AXRError(); /** - * Call this if you want the message to be displayed. The actual implementation is - * handled by the OS-specific wrapper. + * Call this if you want the message to be displayed. */ void raise() const; diff --git a/src/core/hss/HSSTypeEnums.h b/src/core/hss/HSSTypeEnums.h index c1993aee..3105d12f 100644 --- a/src/core/hss/HSSTypeEnums.h +++ b/src/core/hss/HSSTypeEnums.h @@ -395,7 +395,7 @@ namespace AXR HSSActionTypeJavascript, /**< HSS object representation of a piece of JS code. */ HSSActionTypeJsFunction, /**< This will probably not be used, it's based on an old idea. */ HSSActionTypeAlert, /**< Shows an alert box (not implemented yet). */ - HSSActionTypeLog, /**< Logs a value (where it appears is specific to the wrapper. */ + HSSActionTypeLog, /**< Logs a value (where it appears is specific to the client application. */ HSSActionTypeFlag, /**< All flagging functions have their corresponding HSS object representation. */ HSSActionTypeFunction /**< Custom functions registered on the core use this type.. */ }; diff --git a/src/core/hss/objects/HSSContainer.cpp b/src/core/hss/objects/HSSContainer.cpp index 412f7563..be33465f 100644 --- a/src/core/hss/objects/HSSContainer.cpp +++ b/src/core/hss/objects/HSSContainer.cpp @@ -44,7 +44,7 @@ #include #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" #include "HSSContainer.h" #include "HSSExpression.h" @@ -506,7 +506,7 @@ void HSSContainer::layout() unsigned i, size, j, k; //HSSUnit acc2 = 0; security_brake_init(); - AXRCore * wrapper = axrController->document(); + AXRDocument * document = axrController->document(); //bool secondaryIsHorizontal = (this->directionSecondary == HSSDirectionLeftToRight || this->directionSecondary == HSSDirectionRightToLeft); @@ -546,12 +546,12 @@ void HSSContainer::layout() if (child->y < child->topMargin + this->topPadding) child->y = child->topMargin + this->topPadding; } - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->nextLayoutChild(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->nextLayoutChild(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { done = true; break; @@ -624,11 +624,11 @@ void HSSContainer::layout() } } - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { done = true; break; @@ -681,11 +681,11 @@ void HSSContainer::layout() } } - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { done = true; break; @@ -732,11 +732,11 @@ void HSSContainer::layout() if (pgGrp->lines.empty()) { this->_distribute(pgGrp, this->directionPrimary); - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { done = true; break; @@ -748,11 +748,11 @@ void HSSContainer::layout() for (std::vector::iterator pgLineIt = pgGrp->lines.begin(); pgLineIt != pgGrp->lines.end(); ++pgLineIt) { this->_distribute(*pgLineIt, this->directionPrimary); - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { done = true; break; @@ -1609,7 +1609,7 @@ bool HSSContainer::_arrangeLines(displayGroup::p &group, HSSDirectionValue direc return true; } - AXRCore * wrapper = axrController->document(); + AXRDocument * document = axrController->document(); switch (direction) { @@ -1761,11 +1761,11 @@ bool HSSContainer::_arrangeLines(displayGroup::p &group, HSSDirectionValue direc accHeight += otherChild2->outerHeight; - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { return false; } @@ -1824,11 +1824,11 @@ bool HSSContainer::_arrangeLines(displayGroup::p &group, HSSDirectionValue direc { currentChild->y = constraintBottom - currentChild->bottomMargin - currentChild->height; currentChild->_layoutFlagLockBottom = true; - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { return false; } @@ -1862,11 +1862,11 @@ bool HSSContainer::_arrangeLines(displayGroup::p &group, HSSDirectionValue direc { currentChild->y = constraintTop + currentChild->topMargin; currentChild->_layoutFlagLockTop = true; - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - wrapper->breakIfNeeded(); - if (wrapper->layoutStepDone()) + document->nextLayoutTick(); + document->breakIfNeeded(); + if (document->layoutStepDone()) { return false; } diff --git a/src/core/hss/objects/HSSDisplayObject.cpp b/src/core/hss/objects/HSSDisplayObject.cpp index a70c4dc3..3d22e2d3 100644 --- a/src/core/hss/objects/HSSDisplayObject.cpp +++ b/src/core/hss/objects/HSSDisplayObject.cpp @@ -47,7 +47,7 @@ #include #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" #include "HSSContainer.h" #include "HSSDisplayObject.h" @@ -771,11 +771,11 @@ bool HSSDisplayObject::isDirty() void HSSDisplayObject::draw(QPainter &painter) { - AXRCore *wrapper = axrController->document(); - if (wrapper->showLayoutSteps()) + AXRDocument *document = axrController->document(); + if (document->showLayoutSteps()) { - wrapper->nextLayoutTick(); - if (wrapper->layoutChildDone()) return; + document->nextLayoutTick(); + if (document->layoutChildDone()) return; } axr_log(AXR_DEBUG_CH_GENERAL_SPECIFIC, "HSSDisplayObject: drawing " + this->elementName); diff --git a/src/core/hss/objects/HSSObject.cpp b/src/core/hss/objects/HSSObject.cpp index bb6359bb..d924c740 100644 --- a/src/core/hss/objects/HSSObject.cpp +++ b/src/core/hss/objects/HSSObject.cpp @@ -44,7 +44,7 @@ #include #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" #include "HSSCircle.h" #include "HSSColorStop.h" diff --git a/src/core/hss/objects/HSSTextBlock.cpp b/src/core/hss/objects/HSSTextBlock.cpp index b80af28d..1d63e6cc 100644 --- a/src/core/hss/objects/HSSTextBlock.cpp +++ b/src/core/hss/objects/HSSTextBlock.cpp @@ -44,7 +44,7 @@ #include #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" #include "HSSFunction.h" #include "HSSObjectDefinition.h" diff --git a/src/core/hss/objects/actions/HSSRequest.cpp b/src/core/hss/objects/actions/HSSRequest.cpp index 62ac71c0..c36b594d 100644 --- a/src/core/hss/objects/actions/HSSRequest.cpp +++ b/src/core/hss/objects/actions/HSSRequest.cpp @@ -43,7 +43,7 @@ #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" #include "HSSRequest.h" #include "HSSSelFunction.h" @@ -131,12 +131,12 @@ void HSSRequest::setProperty(HSSObservableProperty name, HSSParserNode::p value) void HSSRequest::fire() { - AXRCore* core = axrController->document(); + AXRDocument* document = axrController->document(); //if there is no target if (this->target.empty()) { - core->loadXMLFile(this->src); + document->loadXMLFile(this->src); } else { @@ -144,14 +144,14 @@ void HSSRequest::fire() { default: { - AXRController::p controller = AXRController::p(new AXRController(core)); + AXRController::p controller = AXRController::p(new AXRController(document)); XMLParser::p xmlParser(new XMLParser(controller.data())); HSSParser::p hssParser(new HSSParser(controller.data())); - AXRBuffer::p baseFile = core->getFile(); + AXRBuffer::p baseFile = document->getFile(); AXRBuffer::p newFile; try { - newFile = core->getFile(this->src); + newFile = document->getFile(this->src); } catch (const AXRError &e) { @@ -163,7 +163,7 @@ void HSSRequest::fire() bool loadingSuccess = xmlParser->loadFile(newFile); if (!loadingSuccess) { - AXRError("AXRCore", "Could not load the XML file").raise(); + AXRError("AXRDocument", "Could not load the XML file").raise(); } else { @@ -177,7 +177,7 @@ void HSSRequest::fire() AXRBuffer::p hssfile; try { - hssfile = core->getFile(*sheetsIt); + hssfile = document->getFile(*sheetsIt); } catch (const AXRError &e) { @@ -187,7 +187,7 @@ void HSSRequest::fire() if (!hssParser->loadFile(hssfile)) { - AXRError("AXRCore", "Could not load the HSS file").raise(); + AXRError("AXRDocument", "Could not load the HSS file").raise(); } } @@ -212,16 +212,16 @@ void HSSRequest::fire() root->setNeedsRereadRules(true); root->recursiveReadDefinitionObjects(); root->handleEvent(HSSEventTypeLoad, NULL); - core->setNeedsDisplay(true); + document->setNeedsDisplay(true); } } } - // AXRCore::tp core = AXRCore::getInstance(); - // AXRWrapper * wrapper = core->getWrapper(); - // AXRBuffer::p baseFile = core->getFile(); + // AXRDocument::tp document = AXRDocument::getInstance(); + // AXRWrapper * document = document->getWrapper(); + // AXRBuffer::p baseFile = document->getFile(); // - // bool loadingSuccess = wrapper->loadFile(baseFile->basePath+this->src, this->src); + // bool loadingSuccess = document->loadFile(baseFile->basePath+this->src, this->src); // if(loadingSuccess){ // unsigned i, size; // for (i=0, size=this->target.size(); i #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWarning.h" #include "HSSAttrFunction.h" #include "HSSComment.h" diff --git a/src/core/hss/parsing/HSSParser.h b/src/core/hss/parsing/HSSParser.h index 769f3ed7..dad826fb 100644 --- a/src/core/hss/parsing/HSSParser.h +++ b/src/core/hss/parsing/HSSParser.h @@ -75,7 +75,6 @@ namespace AXR /** @} */ class AXRController; - class AXRWrapper; /** * @brief This class reads an HSS file and, with the help of HSSTokenizer, converts @@ -101,7 +100,7 @@ namespace AXR typedef QSharedPointer p; /** - * Creates a new instance of a parser object, linking it to the given controller and wrapper. + * Creates a new instance of a parser object, linking it to the given controller. * It will create a new instance of a HSSTokenizer automatically, and set the current context to root. * * @param theController A regular pointer to the controller associated to this parser. diff --git a/src/core/hss/parsing/filters/HSSFlag.cpp b/src/core/hss/parsing/filters/HSSFlag.cpp index 155f12aa..10c553bd 100644 --- a/src/core/hss/parsing/filters/HSSFlag.cpp +++ b/src/core/hss/parsing/filters/HSSFlag.cpp @@ -42,7 +42,7 @@ ********************************************************************/ #include "AXRController.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "HSSDisplayObject.h" #include "HSSFlag.h" @@ -90,7 +90,7 @@ void HSSFlag::flagChanged(HSSRuleState newStatus) { HSSRule::p theRule = qSharedPointerCast (ruleStatement); std::vector scope = theRule->getOriginalScope(); - AXRController::p controller = AXRCore::getInstance()->getController(); + AXRController::p controller = AXRDocument::getInstance()->getController(); this->setPurging(newStatus); std::vector > selection = controller->select(theRule->getSelectorChains(), scope, this->getThisObj(), false); this->setPurging(HSSRuleStateOff); diff --git a/src/core/hss/parsing/functions/HSSFunction.cpp b/src/core/hss/parsing/functions/HSSFunction.cpp index ba8a4895..58dd7fad 100644 --- a/src/core/hss/parsing/functions/HSSFunction.cpp +++ b/src/core/hss/parsing/functions/HSSFunction.cpp @@ -42,7 +42,7 @@ ********************************************************************/ #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "HSSExpression.h" #include "HSSFunction.h" @@ -133,8 +133,8 @@ QVariant HSSFunction::_evaluate() QVariant HSSFunction::_evaluate(std::deque arguments) { - AXRCore* core = AXRCore::getInstance(); - core->evaluateCustomFunction(this->getName(), (void*) &arguments); + AXRDocument* document = AXRDocument::getInstance(); + document->evaluateCustomFunction(this->getName(), (void*) &arguments); return QVariant(); } diff --git a/src/core/hss/parsing/selectors/HSSParentSelector.cpp b/src/core/hss/parsing/selectors/HSSParentSelector.cpp index 63415173..375ec811 100644 --- a/src/core/hss/parsing/selectors/HSSParentSelector.cpp +++ b/src/core/hss/parsing/selectors/HSSParentSelector.cpp @@ -42,7 +42,7 @@ ********************************************************************/ #include -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "HSSParentSelector.h" using namespace AXR; diff --git a/src/core/hss/parsing/selectors/HSSRootSelector.cpp b/src/core/hss/parsing/selectors/HSSRootSelector.cpp index d9137174..7d9ca295 100644 --- a/src/core/hss/parsing/selectors/HSSRootSelector.cpp +++ b/src/core/hss/parsing/selectors/HSSRootSelector.cpp @@ -41,7 +41,7 @@ * ********************************************************************/ -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "HSSRootSelector.h" using namespace AXR; @@ -69,14 +69,14 @@ HSSClonable::p HSSRootSelector::cloneImpl() const AXRString HSSRootSelector::getElementName() { - AXRCore* core = AXRCore::getInstance(); - return core->getController()->getRoot()->getElementName(); + AXRDocument* document = AXRDocument::getInstance(); + return document->getController()->getRoot()->getElementName(); } std::vector HSSRootSelector::filterSelection(const std::vector & scope, HSSDisplayObject::p thisObj, bool processing) { std::vector ret; - AXRCore* core = AXRCore::getInstance(); - ret.push_back(core->getController()->getRoot()); + AXRDocument* document = AXRDocument::getInstance(); + ret.push_back(document->getController()->getRoot()); return ret; } diff --git a/src/core/rendering/AXRRender.cpp b/src/core/rendering/AXRRender.cpp index ae1583a0..53dd93d0 100644 --- a/src/core/rendering/AXRRender.cpp +++ b/src/core/rendering/AXRRender.cpp @@ -45,7 +45,7 @@ #include "AXRController.h" #include "AXRDebugging.h" #include "AXRError.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRRender.h" #include "AXRString.h" #include "HSSDisplayObject.h" @@ -65,7 +65,7 @@ void AXRRender::drawInRectWithBounds(HSSRect rect, HSSRect bounds) { //prepare values HSSContainer::p root = this->controller->getRoot(); - AXRCore * wrapper = this->controller->document(); + AXRDocument * document = this->controller->document(); if (root) { @@ -88,15 +88,15 @@ void AXRRender::drawInRectWithBounds(HSSRect rect, HSSRect bounds) root->recursiveReadDefinitionObjects(); axr_log(AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRRender: laying out elements on page"); root->recursiveLayout(); - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->resetLayoutTicks(); + document->resetLayoutTicks(); } axr_log(AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRRender: regenerating surfaces"); regenerateRootSurface(); axr_log(AXR_DEBUG_CH_GENERAL | AXR_DEBUG_CH_GENERAL_SPECIFIC, "AXRRender: drawing tree"); - wrapper->nextLayoutChild(); + document->nextLayoutChild(); QPainter painter(this->rootSurface); if (_globalAntialiasingEnabled) @@ -107,10 +107,10 @@ void AXRRender::drawInRectWithBounds(HSSRect rect, HSSRect bounds) //this->rootSurfaceFinal = this->rootSurface->convertToFormat(QImage::Format_ARGB32); this->rootSurfaceFinal = *this->rootSurface; - if (wrapper->showLayoutSteps()) + if (document->showLayoutSteps()) { - wrapper->resetLayoutTicks(); - wrapper->resetLayoutChild(); + document->resetLayoutTicks(); + document->resetLayoutChild(); } } else diff --git a/src/core/rendering/AXRRender.h b/src/core/rendering/AXRRender.h index 63f47635..ff9f7bb0 100644 --- a/src/core/rendering/AXRRender.h +++ b/src/core/rendering/AXRRender.h @@ -52,7 +52,7 @@ namespace AXR { class AXRController; - class AXRCore; + class AXRDocument; /** * @brief This is the main control hub for rendering. Calls for drawing and handling diff --git a/src/core/xml/XMLParser.cpp b/src/core/xml/XMLParser.cpp index 23f57c57..beed22ce 100644 --- a/src/core/xml/XMLParser.cpp +++ b/src/core/xml/XMLParser.cpp @@ -46,7 +46,7 @@ #include "AXRController.h" #include "AXRDebugging.h" #include "AXRError.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "XMLParser.h" using namespace AXR; diff --git a/src/examples/rendering/cocoa/CocoaAppDelegate.h b/src/examples/rendering/cocoa/CocoaAppDelegate.h index 93c8fb42..8e53a112 100644 --- a/src/examples/rendering/cocoa/CocoaAppDelegate.h +++ b/src/examples/rendering/cocoa/CocoaAppDelegate.h @@ -42,7 +42,7 @@ ********************************************************************/ #import -#import "AXRInitializer.h" +#import "AXRDocument.h" #import "AXRView.h" #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 @@ -54,7 +54,7 @@ NSWindow *window; NSWindow *axrWindow; AXRView *axrView; - AXR::AXRCore *document; + AXR::AXRDocument *document; } @property(assign) IBOutlet NSWindow *axrWindow; diff --git a/src/examples/rendering/cocoa/CocoaAppDelegate.mm b/src/examples/rendering/cocoa/CocoaAppDelegate.mm index a54f47d8..f9483451 100644 --- a/src/examples/rendering/cocoa/CocoaAppDelegate.mm +++ b/src/examples/rendering/cocoa/CocoaAppDelegate.mm @@ -42,7 +42,7 @@ ********************************************************************/ #import "AXRDebugging.h" -#import "AXRInitializer.h" +#import "AXRDocument.h" #import "HSSDisplayObject.h" #import "CocoaAppDelegate.h" @@ -56,7 +56,7 @@ -(id) init self = [super init]; if (self) { - document = AXR::AXRCore::getInstance(); + document = AXR::AXRDocument::getInstance(); } return self; @@ -65,7 +65,7 @@ -(id) init -(void) dealloc { // TODO: don't delete until thread pointer is eliminated - //delete wrapper; + //delete document; [super dealloc]; } diff --git a/src/examples/rendering/sdl/main.cpp b/src/examples/rendering/sdl/main.cpp index d609bb92..3e1bbaa9 100644 --- a/src/examples/rendering/sdl/main.cpp +++ b/src/examples/rendering/sdl/main.cpp @@ -46,7 +46,7 @@ #include #include #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #if defined(_WIN32) #include @@ -59,7 +59,7 @@ const int WINDOW_WIDTH = 640; const int WINDOW_HEIGHT = 480; const char* WINDOW_TITLE = "AXR SDL Demo"; -AXRCore *core; +AXRDocument *document; SDL_Surface* screen = NULL; #ifdef _WIN32 @@ -97,25 +97,25 @@ SDL_Surface* QImage_toSDLSurface(const QImage &sourceImage) void render() { - if (core->needsDisplay()) + if (document->needsDisplay()) { HSSRect bounds(0, 0, screen->w, screen->h); - core->drawInRectWithBounds(bounds, bounds); + document->drawInRectWithBounds(bounds, bounds); SDL_FillRect(screen, NULL, SDL_MapRGBA(screen->format, 255, 255, 255, 255)); - SDL_Surface *surf = QImage_toSDLSurface(core->getRender()->surface()); + SDL_Surface *surf = QImage_toSDLSurface(document->getRender()->surface()); SDL_BlitSurface(surf, NULL, screen, NULL); SDL_FreeSurface(surf); SDL_Flip(screen); - core->setNeedsDisplay(false); + document->setNeedsDisplay(false); } } void loadFile() { QString filepath = QFileDialog::getOpenFileName(NULL, QObject::tr("Open File"), QString(), QObject::tr("AXR Files (*.xml *.hss)")); - core->loadFileByPath(QUrl::fromLocalFile(filepath)); + document->loadFileByPath(QUrl::fromLocalFile(filepath)); } int main(int argc, char **argv) @@ -143,14 +143,14 @@ int main(int argc, char **argv) SDL_EnableKeyRepeat(300, 50); SDL_EnableUNICODE(1); - core = AXRCore::getInstance(); + document = AXRDocument::getInstance(); if (!args.empty()) { QFileInfo fi(args.last()); if (fi.exists()) { - core->loadFileByPath(QUrl::fromLocalFile(AXR::fromQString(args.first()))); + document->loadFileByPath(QUrl::fromLocalFile(AXR::fromQString(args.first()))); } else { @@ -176,7 +176,7 @@ int main(int argc, char **argv) } else if (event.type == SDL_MOUSEBUTTONDOWN) { - HSSContainer::p root = core->getController()->getRoot(); + HSSContainer::p root = document->getController()->getRoot(); if (root) { @@ -188,7 +188,7 @@ int main(int argc, char **argv) } else if (event.type == SDL_MOUSEBUTTONUP) { - HSSContainer::p root = core->getController()->getRoot(); + HSSContainer::p root = document->getController()->getRoot(); if (root) { @@ -201,7 +201,7 @@ int main(int argc, char **argv) } else if (event.type == SDL_MOUSEMOTION) { - HSSContainer::p root = core->getController()->getRoot(); + HSSContainer::p root = document->getController()->getRoot(); if (root) { @@ -219,7 +219,7 @@ int main(int argc, char **argv) if (event.key.keysym.sym == SDLK_F5) { std_log("Reloading file"); - core->reload(); + document->reload(); } else if (event.key.keysym.sym == SDLK_o && (event.key.keysym.mod & KMOD_CTRL)) { @@ -229,11 +229,11 @@ int main(int argc, char **argv) else if (event.type == SDL_VIDEORESIZE) { screen = SDL_SetVideoMode(event.resize.w, event.resize.h, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE); - core->setNeedsDisplay(true); + document->setNeedsDisplay(true); } else if (event.active.state & SDL_APPMOUSEFOCUS && event.active.gain == 0) { - HSSContainer::p root = core->getController()->getRoot(); + HSSContainer::p root = document->getController()->getRoot(); if (root) { @@ -254,7 +254,7 @@ int main(int argc, char **argv) #endif // TODO: don't delete until thread pointer is eliminated - //delete core; + //delete document; return 0; } diff --git a/src/prototype/AXRWidget.cpp b/src/prototype/AXRWidget.cpp index 930491fb..9a821173 100644 --- a/src/prototype/AXRWidget.cpp +++ b/src/prototype/AXRWidget.cpp @@ -42,7 +42,7 @@ ********************************************************************/ #include -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRWidget.h" using namespace AXR; @@ -50,13 +50,13 @@ using namespace AXR; class AXRWidget::Private { public: - Private(AXRCore *doc = NULL) : document(doc), backgroundFillColor(QColor(Qt::white)) { } + Private(AXRDocument *doc = NULL) : document(doc), backgroundFillColor(QColor(Qt::white)) { } - AXRCore *document; + AXRDocument *document; QColor backgroundFillColor; }; -AXRWidget::AXRWidget(AXRCore *document, QWidget *parent) +AXRWidget::AXRWidget(AXRDocument *document, QWidget *parent) : QWidget(parent), d(new Private(document)) { this->setMouseTracking(true); @@ -73,12 +73,12 @@ AXRWidget::~AXRWidget() delete d; } -AXRCore* AXRWidget::document() const +AXRDocument* AXRWidget::document() const { return d->document; } -void AXRWidget::setDocument(AXRCore *document) +void AXRWidget::setDocument(AXRDocument *document) { d->document = document; } diff --git a/src/prototype/AXRWidget.h b/src/prototype/AXRWidget.h index c12b26b5..6eb33b7e 100644 --- a/src/prototype/AXRWidget.h +++ b/src/prototype/AXRWidget.h @@ -48,19 +48,19 @@ namespace AXR { - class AXRCore; + class AXRDocument; class AXRWidget : public QWidget { Q_OBJECT public: - AXRWidget(AXRCore *document, QWidget *parent = NULL); + AXRWidget(AXRDocument *document, QWidget *parent = NULL); AXRWidget(QWidget *parent = NULL); virtual ~AXRWidget(); - AXRCore* document() const; - void setDocument(AXRCore *document); + AXRDocument* document() const; + void setDocument(AXRDocument *document); QColor backgroundFillColor() const; void setBackgroundFillColor(const QColor &color); diff --git a/src/prototype/PrototypeWindow.cpp b/src/prototype/PrototypeWindow.cpp index 63a1c769..9894e610 100644 --- a/src/prototype/PrototypeWindow.cpp +++ b/src/prototype/PrototypeWindow.cpp @@ -49,7 +49,7 @@ #include "AXRController.h" #include "AXRDebugging.h" -#include "AXRInitializer.h" +#include "AXRDocument.h" #include "AXRTestRunner.h" #include "XMLParser.h" @@ -68,7 +68,7 @@ class PrototypeWindow::Private public: Private() { - wrapper = AXRCore::getInstance(); + document = AXRDocument::getInstance(); testRunner = new AXRTestRunner(); axr_debug_device = qApp->loggingDevice(); } @@ -78,11 +78,11 @@ class PrototypeWindow::Private axr_debug_device = NULL; // TODO: don't delete until thread pointer is eliminated - //delete wrapper; + //delete document; delete testRunner; } - AXRCore *wrapper; + AXRDocument *document; AXRTestRunner *testRunner; }; @@ -91,10 +91,10 @@ PrototypeWindow::PrototypeWindow(QWidget *parent) { ui->setupUi(this); - ui->enableAntialiasingAction->setChecked(d->wrapper->getRender()->globalAntialiasingEnabled()); + ui->enableAntialiasingAction->setChecked(d->document->getRender()->globalAntialiasingEnabled()); // Tell the widget to render this window's document - ui->renderingView->setDocument(d->wrapper); + ui->renderingView->setDocument(d->document); // The subview needs to accept drops as well even though the main window handles it ui->renderingView->setAcceptDrops(true); @@ -185,7 +185,7 @@ void PrototypeWindow::openFile(const QString &filePath) setWindowTitle(QString()); setWindowFilePath(filePath); - d->wrapper->loadFileByPath(QUrl::fromLocalFile(filePath)); + d->document->loadFileByPath(QUrl::fromLocalFile(filePath)); qApp->settings()->setLastFileOpened(filePath); update(); } @@ -214,15 +214,15 @@ void PrototypeWindow::closeFile() void PrototypeWindow::previousLayoutStep() { - d->wrapper->setShowLayoutSteps(true); - d->wrapper->previousLayoutStep(); + d->document->setShowLayoutSteps(true); + d->document->previousLayoutStep(); update(); } void PrototypeWindow::nextLayoutStep() { - d->wrapper->setShowLayoutSteps(true); - d->wrapper->nextLayoutStep(); + d->document->setShowLayoutSteps(true); + d->document->nextLayoutStep(); update(); } @@ -237,7 +237,7 @@ void PrototypeWindow::listXmlElements() AXRBuffer::p f(new AXRBuffer(fi)); - AXRController *controller = new AXRController(d->wrapper); + AXRController *controller = new AXRController(d->document); XMLParser parser(controller); if (!parser.loadFile(f)) @@ -263,7 +263,7 @@ void PrototypeWindow::listHssStatements() AXRBuffer::p f(new AXRBuffer(fi)); - AXRController controller(d->wrapper); + AXRController controller(d->document); HSSParser hssparser(&controller); if (hssparser.loadFile(f)) @@ -320,7 +320,7 @@ void PrototypeWindow::listHssTokens() void PrototypeWindow::runLayoutTests() { - d->wrapper->registerCustomFunction("AXRLayoutTestsExecute", new HSSValueChangedCallback(d->testRunner, &AXRTestRunner::executeLayoutTests)); + d->document->registerCustomFunction("AXRLayoutTestsExecute", new HSSValueChangedCallback(d->testRunner, &AXRTestRunner::executeLayoutTests)); this->openFile(d->testRunner->getPathToTestsFile()); } @@ -340,6 +340,6 @@ void PrototypeWindow::showAbout() void PrototypeWindow::toggleAntialiasing(bool on) { - d->wrapper->getRender()->setGlobalAntialiasingEnabled(on); + d->document->getRender()->setGlobalAntialiasingEnabled(on); update(); }