Giter Club home page Giter Club logo

nana-extra's People

Contributors

5cript avatar besh81 avatar errorflynn avatar jamesbremner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nana-extra's Issues

BUG in PropertyGrid: The property value is ONLY updated when the user presses the ENTER key

i want to write the property values, after the user has set them, to a database. But I do not get the new values set by the user.

This code ( based on demo with save button added )

#include <nana/gui.hpp>
#include <nana/gui/place.hpp>
#include <nana/gui/widgets/textbox.hpp>

#include "propertygrid.h"
#include "pgitems.h"

int main()
{
    nana::form fm(0, nana::size{ 600, 500 });
    nana::place pl{ fm };
    pl.div("margin=50 gap=5 field");

    nana::propertygrid propgrid{ fm };
    pl["field"] << propgrid;

    nana::textbox txt{ fm };
    pl["field"] << txt;
    txt.editable(false);


    // append category
    auto cat = propgrid.append("Standard properties");
    // append string property
    cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string("string", "ABC")));
    // append int property
    cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string_int("int", "-100")));
    // append unsigned int property
    cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string_uint("unsigned int", "100")));
    // append string with button property
    cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_string_button("string + button", "Ciao")));
    // append choice property
    auto ip = cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_choice("choice")));
    auto pgchoiche = static_cast<nana::pg_choice*>(ip._m_pgitem());
    pgchoiche->push_back("One");
    pgchoiche->push_back("Two");
    pgchoiche->push_back("3");
    // append check property
    cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_check("check", true)));
    // append color property
    cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_color("color", "255,0,0")));
    // append color+inherited property
    ip = cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_color("color + inherited", "128,128,128", true)));
    ip.value("0,255,0");

    // connect the events
    propgrid.events().property_changed([&txt](const nana::arg_propertygrid& arg)
    {
        auto ip = arg.item;
        txt.append("[cat: " + std::to_string(ip.pos().cat) + ", pos: " + std::to_string(ip.pos().item) + "] ", true);
        txt.append("   label: " + ip.label() + "\n", true);
    });

    // Save button will read the current value of the int properrty
    nana::button save(fm,nana::rectangle{5,5,40,25},true);
    save.caption("SAVE");
    save.events().click([&propgrid]()
    {
        std::string t = propgrid.find("Standard properties","int").value();
        nana::msgbox msg("Current Value of int property");
        msg << t;
        msg.show();
    });


    pl.collocate();
    fm.show();
    nana::exec();
}

Shows this result after user changes int property to 34

image

Question: Collapsing a category

I want to start up my application with the categories collapsed.

( There are over 100 properties, so it is overwhelming to see all of them at once )

I tried:

    cat = propgrid.append("Output Ports");
    cat.expand( false );

but expand is not a method of the cat_proxy class returned by append.

It is an attribute of the structure category_t

cat_proxy does have a private attribute that is a pointer to a category_t structure, so maybe that is what I need?

PropertyGrid feature request: nested categories.

I am requesting that categories should not only contain property items, but also child categories.

Something like this:

	// append category to top level
	auto parent_cat = propgrid.append("Parent");

       // append category under parent
       auto child_cat = propgrid.appendIn( parent_cat, "Child" );

Motivation

I was hoping to port my wxWidgets property grid application to nana. This has over 100 properties, so having just one level of category makes finding a particular property difficult for the user. Here is a screenshot of the wxWidgets app:

On startup, all categories are collapsed, hiding their children and so helping the user find what needs to be looked at in detail:

image

With categories expanded:

image

pgitem memory leak

pgitem should have a virtual destructor, otherwise the derived class will not destruct and there will be memory leaks.

Compile failure

C:\Users\James\code\nana-extra\propertygrid\pgitems.cpp:12:10: fatal error: lock_guard.h: No such file or directory

Feature Request PropertyGrid: Vertical gap between properties

There is a generous vertical gap between properties. Would it be possible to have an option to adjust the size of this gap, or even eliminate it entirely.

My application has over 100 properties, so there is a lot of scrolling when many categories are expanded.

Here is a screenshot of the app built with wxWidgets, which has no vertical gap between properties.

image

PropertyGrid Question: Use of item_proxy::_m_pgitem()

pgitem* _m_pgitem() const; ///< Internal use

The comment on the declaration of this method suggests it is for internal use only.

Yet I seem to need to use it very often in my application code.

Creating a choice property ( this is from your demo code )

auto ip = cat.append(nana::propertygrid::pgitem_ptr(new nana::pg_choice("choice")));
auto pgchoiche = static_cast<nana::pg_choice*>(ip._m_pgitem());
pgchoiche->push_back("One");
pgchoiche->push_back("Two");
pgchoiche->push_back("3");

and also when I need to select a choice

int selected;
... set selected...
(static_cast<nana::pg_choice*>(pg.find("Output Ports","A Format")._m_pgitem()))->option( selected ));

So, my questions:

  • Should I be using this, or something else?
  • If it should be used, can you fix the comment to describe what it does?
  • If it should be used, maybe you could change the name to make application code easier to read?

BUG PropertyGrid choice property set value fails

void pg_choice::value(const std::string& value_)
{
try
{
option(std::stoul(pgitem::value()));
}
catch(...)
{
}
}

The intention here ( I assume - there is no documentation ) is to select a new option. It fails. Instead the current value is set again.

At a minimum, line 418 should be changed to

option(std::stoul( value_ ));

I would also change the name of the parameter - it looks like a class member.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.