Nana 1.5 brings several updates – including enhanced stability and usability, and numerous other bug fixes and improvements.
You can find a release note using this link.
Please visit homepage to see who’ve contributed to this release.
New Features in Nana 1.5
Nana 1.5 has a variety of new features for extending the existing components. Let’s have a look at these new features.
Listbox
Box Selection
Listbox is enhanced for the user experience. When the multi-selection is enabled, user can select items that intersect with a user selected rectangle region within the listbox.
Place
Fit-Content Layoutment
There are new keywords has been added to place for layouting a content measurable widget depending on its content. The content measurable widgets are button, combox, label and picture.
fit
The keyword fit layouts a widget to fit its content.
int main() { using namespace nana; form fm; button btna{ fm }, btnb{ fm }; btna.caption("This is very long long long title"); btnb.caption("Short title"); fm.div("<><fit x gap=5><>"); //fit here in x field fm["x"] << btna << btnb; //these 2 buttons fit their text. fm.collocate(); fm.show(); exec(); }
vfit
The keyword vfit layouts a widget to fit its content, and the height of the content is measured with specified a fixed width. Now only label supports the vfit.
int main() { using namespace nana; form fm; label lab{ fm }; std::string content = "Nana C++ Library takes aim at easy-to-use and portable library, it provides a GUI framework and threads for easy programming with modern C++ methods."; lab.caption(content); fm.div("<><vfit=200 x gap=5><>"); fm["x"] << lab; fm.collocate(); fm.show(); exec(); }
Customize the Splitter
A new function for class place to specify a splitter renderer.
void splitter_renderer(std::function<void(window, paint::graphics&, mouse_action)> fn);
The function object will be copied to every splitter instance.
place.splitter_renderer([](window wd, paint::graphics& graph, mouse_action mact){ //wd the handle to the splitter //graph the graphics object of the splitter switch(mact) { case mouse_action::normal: //normal state break; case mouse_action::normal_captured: //mouse down case mouse_action::pressed: break; case mouse_action::hovered: //mouse move break; } });
Initialize the Weight of a Min/Max-Specified Field
Before the 1.5, the weight attribute is ignored when the min/max attributes are specified. Now the weight can be specified to initialize the field weight when min/max attributes are specified.
Get the Div-Text of Current Status
Place added a return type for div() method to return the div-text of current running status. For example, If program hides a certain field, the place will add the invisible attribute to the corresponding field for the div-text. This is a useful feature to let developer serialize the current layoutment.
Textbox
A new text_align() method to set the text alignment.
The line color is used to allow textbox to display different background color and foreground color for specified lines.
Using a TTF File
Now Nana supports to load font from a TTF file.
int main() { using namespace nana; //Loads ttf file with default font size paint::font ft(0/*default font size*/, "stocky.ttf"); ft.set_default(); //set the default font for the program form fm; fm.typeface({ 20, "stocky.ttf" }); drawing{ fm }.draw([](paint::graphics& graph) { graph.string({10, 30}, "Set stocky.ttf as default font"); }); button btn{ fm }; btn.caption("Button"); //... }
Very nice new features!
Thanks for your hard work! 🙂
Very nice work! Looking forward to try out the new changes!
These are some great changes. Keep it up!