<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Ashampoo Systems - Medium]]></title>
        <description><![CDATA[Ashampoo Systems Blog - Medium]]></description>
        <link>https://medium.com/ashampoo-systems?source=rss----1d37f5469b0b---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Ashampoo Systems - Medium</title>
            <link>https://medium.com/ashampoo-systems?source=rss----1d37f5469b0b---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:39:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/ashampoo-systems" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting started with C++17 mobile cross-platform development using Boden]]></title>
            <link>https://medium.com/ashampoo-systems/getting-started-with-c-17-mobile-cross-platform-development-using-boden-b47cb0f9a9a1?source=rss----1d37f5469b0b---4</link>
            <guid isPermaLink="false">https://medium.com/p/b47cb0f9a9a1</guid>
            <category><![CDATA[user-interface]]></category>
            <category><![CDATA[gui]]></category>
            <category><![CDATA[bodenframework]]></category>
            <category><![CDATA[cplusplus]]></category>
            <category><![CDATA[mobile-apps]]></category>
            <dc:creator><![CDATA[Ashampoo Systems]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 11:53:32 GMT</pubDate>
            <atom:updated>2019-09-17T13:44:40.864Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4RD09WG_B-6ET0pWQ2A8A.png" /></figure><h3>TL;DR</h3><ul><li>Love C++ and mobile apps? Learn how to write a <strong>simple cross-platform todo mobile app in idiomatic C++17</strong> using the <a href="https://www.boden.io/"><strong>Boden Cross-Platform GUI Framework</strong></a><strong> </strong>in this tutorial.</li><li>The resulting app will use <strong>native machine code and native widgets</strong> to manage your todos in a simple single view application.</li><li>Jump right to the <a href="https://github.com/AshampooSystems/boden-todomvc"><strong>boden-todomvc example repository on GitHub</strong></a> to have a look at the final code!</li></ul><h3>What will I learn?</h3><p>In this tutorial you will learn how to write an app once in C++17 and then run it on an Android Phone and an iPhone from the same codebase.</p><p>Your app will:</p><ul><li><strong>Allow users to manage a list of todos in a simple way</strong>. Users can add new todos, mark existing todos as completed, and delete todos using a swipe gesture. The app won’t lose the todo list when closed.</li><li>It will <strong>look and behave natively</strong> since it’s going to use the native UI widgets of the platform.</li><li>It will<strong> </strong>be<strong> based on the MVC architecture</strong>, similar to what you would write in Objective-C/Swift on iOS or Java/Kotlin on Android.</li></ul><h3>Setting up the project</h3><p>The first step is to set up a new app project with the Boden Framework. Don’t worry, this will be quick and easy.</p><p>First, clone the boden git repository from GitHub:</p><pre>git clone --recursive https://github.com/AshampooSystems/boden.git</pre><p>Make sure your system meets Boden’s requirements by following the <a href="https://www.boden.io/getting-started/">Getting Started Guide</a> on <a href="https://www.boden.io/">boden.io</a>.</p><p>Finally, use the boden command line tool to generate a new project:</p><pre>cd boden<br>python boden.py new -n todomvc</pre><p>That’s it!</p><p>The tool will create a folder titled todomvc and generate the source and project files for a barebones Boden application, which we’ll modify and extend in the next part of this tutorial.</p><h3>Setting up your development environment</h3><p>Boden comes with support for Xcode on macOS and Android Studio on Linux, Windows, and macOS.</p><p>Change to the todomvc directory and use the boden command line tool to conveniently open the project in your IDE:</p><pre>cd todomvc<br>python ../boden.py open</pre><p>This will open Android Studio on Linux/Windows or Xcode on macOS.</p><p>In this tutorial, you will add several new source files to the project. You can simply add those files using the IDE. In this case, make sure the files are added to the source directory.</p><p>An alternative way to add files is to create them in the source directory using a text editor and then re-running python.py ../boden.py open. This will automatically regenerate the project files with the new source files added.</p><h3>Planning the todo app</h3><p>When the todo app is finished, users should be able to:</p><ul><li>Write a new todo and add it to a list of items that need to be completed.</li><li>Mark an existing todo in the list as completed.</li><li>Delete a todo from the list.</li></ul><p>The app should also persist the todo list to device storage so that todos won’t be lost when the app is closed and re-opened.</p><p>To keep things simple the app will be based on a single screen with a text field at the top and a scrollable list of todo items taking up the rest of the available screen space below. This is what it’s going to look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UxByqyJ8IL2zCwmnCXrfUA.png" /></figure><h3>Planning the architecture</h3><p>As mentioned above, this tutorial will stick to the well-known MVC pattern to structure the app’s architecture. Hence, the following components are needed to implement the full app:</p><ol><li><strong>A data model of a todo</strong>. This is a simple data structure designed to store the information associated with a todo item in the list.</li><li><strong>A store component </strong>managing a list of<strong> </strong>todos and persisting that list to device storage.</li><li><strong>A list item view</strong> that presents a todo in the a view to the user.</li><li><strong>A data source </strong>accessing the store component to populate the list view.</li><li><strong>A view controller</strong> setting up the view, including a text field and a list view with the corresponding layout.</li></ol><h3>Creating the todo data model</h3><p>The todo data model is a simple data structure consisting of a string containing the todo’s text and a bool indicating whether the todo is completed.</p><p>Create a new header file named Todo.h and add the following code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*xYZsETGmwD3ECCe-bCNyUQ.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/Todo.h">Todo.h</a></figcaption></figure><h3>Creating the store</h3><p>The store is responsible for maintaining a list of todos in memory and on device storage. It can add and remove todos from the list, and it can load and save the list to disk as a JSON file.</p><p>Create a new header file named TodoStore.h and add the following code to declare the TodoStore class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*kBrT8jc7jA0VsvzooVCDDw.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoStore.h">TodoStore.h</a></figcaption></figure><p>Create the corresponding source file named TodoStore.cpp .</p><p>In the first step, we’re going to include the necessary headers and implement the add() and remove() methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*vnDlS2LerbN8t6utk8eEVg.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoStore.cpp">TodoStore.cpp</a></figcaption></figure><p>The add() method appends an uncompleted todo containing the given todo text at the end of the todos vector. The remove() method removes the todo at the given index from the vector. Both methods call save() to persist changes to the todo list immediately.</p><p>In the next step, we’re going to implement load() and save() to allow for storing and loading a list of todos from a JSON file.</p><h3>Persisting the todo list</h3><p>First, we’ll add a couple of new headers and using statements for JSON, path retrieval, and filesystem functions at the top of TodoStore.cpp .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QRDMmCBXEB2zUa2eep953g.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoStore.cpp">TodoStore.cpp</a></figcaption></figure><ul><li>We use <a href="https://github.com/nlohmann/json">nlohmann::json</a> which is bundled with Boden to parse and serialize JSON data.</li><li><a href="https://www.boden.io/reference/foundation/path/">bdn::path</a> is a Boden module providing functions for retrieving common platform-specific directory paths, which we’ll use to retrieve a path to the documents directory.</li><li>Finally, we use std::filesystem for creating directories and safely concatenating path components.</li></ul><p>In the next step, we’re going to implement the load() and save() methods.</p><p>Add the following code at the end of TodoStore.cpp :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5iZdtDi5GiRZTE39XcgvBQ.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoStore.cpp">TodoStore.cpp</a></figcaption></figure><p>Here’s a short summary of what the functions do:</p><ul><li>load() uses std::ifstream to load the todo.json file from disk. It then parses the contents of the file using nlohmann::json and pushes it to the todos JSON array.</li><li>save() uses std::ofstream and nlohmann::json to serialize the JSON data to the todo.json file.</li><li>todoFilePath() uses bdn::path::documentDirectoryPath() and std::filesystem to safely create the document directory path for the application. It then returns the full path of the todo.json file on device storage.</li></ul><p>As a final step, we are going to add to_json() and from_json() to the Todo data structure defined above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHHvJm2cbg2y3bVDAN1ndQ.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/Todo.h">Todo.h</a></figcaption></figure><p>And create theTodo.cpp source file containing the corresponding implementation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDhrlzlh5tOaUGdgzactkw.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/Todo.cpp">Todo.cpp</a></figcaption></figure><h3>Implementing the todo item view</h3><p>TodoItemView defines how the list item is going to be displayed on screen. It will be used by the list view data source to provide item views to the list view.</p><p>It inherits from <a href="https://www.boden.io/reference/ui/core_less/">bdn::ui::CoreLess</a> to indicate that it is a composite view without a native “view core”. This means that it does not wrap a native platform widget, but rather aggregates existing platform-independent views into one.</p><p><a href="https://www.boden.io/reference/ui/container_view/">bdn::ui::ContainerView</a> is going to be the actual base class of TodoItemView. This allows the class to manage child views in the view hierarchy.</p><p>Here’s what the TodoItemView.h header file looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPRURTo1Ht9SlqIM0nsEAg.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoItemView.h">TodoItemView.h</a></figcaption></figure><ul><li><a href="https://www.boden.io/reference/foundation/property/">bdn::Property</a> is used to make the Todo data structure’s members available as data bindings.</li><li>using CoreLess&lt;ContainerView&gt;::CoreLess declares that the TodoItemView class should reuseCoreLess‘s constructor.</li><li>void init() override is required to implement the view’s custom initialization, where we’re going to set up its child views and layout.</li></ul><p>In the next step, we’ll create a file named TodoItemView.cpp and add the corresponding implementation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-TxQdpWb8qohBMVTiU7pg.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoItemView.cpp">TodoItemView.cpp</a></figcaption></figure><ul><li>We override void init() to initialize the item view’s child views and layout.</li><li>The layout is defined by setting the stylesheet property to a suitable layout definition for the item view.</li><li>The rest of the implementation adds a checkbox for marking a todo as completed and a label for displaying a todo’s text accompanied with the corresponding property bindings and child layouts.</li></ul><h3>Implementing the list view data source</h3><p>In the next step, we are going to implement TodoListDataSource, which will be used by the todo app’s list view to retrieve instances of TodoItemView.</p><p>The data source can be seen as a view model, fetching data from TodoStore, populating a TodoItemView with it, and then delivering it to a <a href="https://www.boden.io/reference/ui/list_view/">ListView</a>.</p><p>Create a new file named TodoListDataSource.h and add the following declaration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZ3WtDdolu25_QF4STrYXQ.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoListDataSource.h">TodoListDataSource.h</a></figcaption></figure><p>Now, create the corresponding source file named TodoListDataSource.cpp :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T_lNJguefXCz4LU0_aUE9w.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/TodoListDataSource.cpp">TodoListDataSource.cpp</a></figcaption></figure><p>TodoListDataSource inherits from <a href="https://www.boden.io/reference/ui/list_view_data_source/">bdn::ui::ListViewDataSource</a>, which declares a couple of pure virtual functions that need to be overridden:</p><ul><li>numberOfRows() returns the number of rows to display in the list view.</li><li>viewForRowIndex() returns a reusable item view to be displayed at the given row index.</li><li>heightForRowIndex() returns the height of the view at the given row index.</li></ul><p>Let’s a have a closer look at the implementation of viewForRowIndex().</p><p>viewForRowIndex() is called by the framework with the listView, rowIndex, and reusableView arguments. If a reusable view is not provided by the framework (reusableView == nullptr), the implementation is responsible for instantiating a new item view:</p><pre><strong>if</strong> (!reusableView) {<br>    // Create a new TodoItemView instance if none is<br>    // provided by the framework<br>    reusableView = std::make_shared&lt;TodoItemView&gt;();<br>}</pre><p>The rest of the code populates the item view with data from the store and installs a listener on the completed property to update the store when the user clicks the item’s checkbox:</p><pre>auto item = std::dynamic_pointer_cast&lt;TodoItemView&gt;(reusableView);<br>    <br>item-&gt;text = _store-&gt;todos.at(rowIndex).at(&quot;text&quot;);<br>item-&gt;completed = _store-&gt;todos.at(rowIndex).at(&quot;completed&quot;);<br>    <br>std::weak_ptr&lt;View&gt; weakItem(item);<br>    <br>item-&gt;completed.onChange().unsubscribeAll();<br>item-&gt;completed.onChange() += [list=listView.get(), weakItem, this](const auto &amp;property) {<br>    if (auto rowIndex = list-&gt;rowIndexForView(weakItem.lock())) {<br>        _store-&gt;todos.at(*rowIndex).at(&quot;completed&quot;) = property.get();<br>        _store-&gt;save();<br>    }<br>};</pre><pre>return reusableView;</pre><h3>Setting up the app’s main view</h3><p>Finally, we’re going to implement the app’s MainViewController class.</p><p>The main view controller is instantiated by the framework upon app launch. It’s responsible for setting up the application’s window and principal view hierarchy.</p><p>MainViewController.h and MainViewController.cpp have already been generated by the boden project generator tool. We’re now going to change and extend these files in order to set up the todo app’s main view.</p><p>This is the final MainViewController declaration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRpY6fCx2pqIhqyX1O64Sw.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/MainViewController.h">MainViewController.h</a></figcaption></figure><p>MainViewController manages the following components:</p><ul><li>The application’s window.</li><li>The text field users will use to enter the text for a new todo item.</li><li>The list view for presenting todo items.</li><li>A container view that contains the text field and the list view and acts as the content view of the window.</li><li>An instance of TodoListDataSource which we created above to provide the list view with item views populated with data from the TodoStore.</li><li>An instance of TodoStore itself responsible for managing the data model.</li></ul><p>That’s it for the header.</p><p>Now, let’s have a look at the implementation in MainViewController.cpp. The application’s main components are set up in the constructor of MainViewController. First, we create the app’s window and set its title and layout:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WtBGbLgxtfeASdnZSHAuDg.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/MainViewController.cpp">MainViewController.cpp</a></figcaption></figure><p>In the next step, we set up the main container, text field, and list view:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fwmJvL4fl65vqt6a7zh1aA.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/MainViewController.cpp">MainViewController.cpp</a></figcaption></figure><p>Finally, we create an instance of TodoStore, call load() to load existing todos from disk, and create and wire an instance of TodoListDataSource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1zV2Z0I6GgVFPW9zrcceA.png" /><figcaption><a href="https://github.com/AshampooSystems/boden-todomvc/blob/master/source/MainViewController.cpp">MainViewController.cpp</a></figcaption></figure><h3>Wrapping up</h3><p>In this tutorial, you’ve learned how to write a cross-platform todo list mobile app in C++17 using the Boden Cross-Platform GUI Framework.</p><p>If you want to play around with the project without writing the app yourself, take a look at the final code at the <a href="https://github.com/AshampooSystems/boden-todomvc"><strong>boden-todomvc example repository on GitHub</strong></a><strong>.</strong></p><p>If you want to learn more about Boden, check out our documentation at <a href="https://www.boden.io/">boden.io</a>.</p><p>In the next tutorial, we’ll complete the app by setting it up for deployment to the Google Play Store and Apple iOS App Store.</p><h3>What do you think?</h3><p>What do you think about the tutorial and about the <a href="https://www.boden.io/">Boden</a> framework? Feel free to offer your perspective and ideas in the comments section below.</p><blockquote>If you enjoyed this article, feel free to hit that clap button 👏 to help others find it.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b47cb0f9a9a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ashampoo-systems/getting-started-with-c-17-mobile-cross-platform-development-using-boden-b47cb0f9a9a1">Getting started with C++17 mobile cross-platform development using Boden</a> was originally published in <a href="https://medium.com/ashampoo-systems">Ashampoo Systems</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>