Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - billarhos

Pages: [1] 2 3 ... 8
1
General Discussion / Re: New signal system
« on: 03 March 2019, 20:13:42 »
Quote
This is very flexible as the string could be read from a text file. The downside is that typos aren't caught at compile time.

Can static assertion caught typos?

https://en.cppreference.com/w/cpp/language/static_assert

2
General Discussion / Re: New signal system
« on: 03 March 2019, 19:11:12 »
http://en.fairygui.com/

Fairygui is a Cross Platform UI Editor & UI framework. I 've downloaded last year but never had the chance to use it. Looking at the signal source code, they tend to use const
integers. I don't know how this can be delivered in handling signal functions from txt files but this is an alternative to constant strings. Is more like enums. However in user source code they use direct naming functions. Like this:

Code: [Select]
_view->getChild("n2")->addClickListener([this, bagBtn](EventContext*){ });

3
Help requests / Re: "ReturnKeyPressed" Signal on textbox widget
« on: 03 March 2019, 13:48:32 »
like this:

Code: [Select]
namespace tgui
{
#define IMPROVED_ENUM_NAME  ChildWindowConnect
#define IMPROVED_ENUM_LIST ENUMITEM(Closed) \
      ENUMITEM(Mimimize) \
      ENUMITEM(Focus)
#include "defineImprovedEnum.h"
}

childWindow->connect(tgui::ChildWindowConnect::Closed, [] {});

//in your code
connect(tgui::ChildWindowConnect::EnumType connectType, ..);


4
Help requests / Re: "ReturnKeyPressed" Signal on textbox widget
« on: 03 March 2019, 13:39:05 »
Had u any time to look at improved enum?
The only disadvantage is that strings in txt file should be case sensitive.


Code: [Select]
STATIC_METHOD inline const ENUMSTRING Enum2String(const EnumType& t)
STATIC_METHOD inline const ENUMSTRING Enum2FullString(const EnumType& t)
STATIC_METHOD inline const EnumType String2Enum(const ENUMSTRING& s)
STATIC_METHOD inline const EnumType FullString2Enum(const ENUMSTRING& s)
STATIC_METHOD inline const EnumType NextEnumItem(const EnumType& t)
STATIC_METHOD inline const EnumType PreviousEnumItem(const EnumType& t)
STATIC_METHOD inline const int NumberOfValidEnumItem()

//EXAMPLE
state = LangPageState::PreviousEnumItem(state);

if (state == LangPageState::NotValidEnumItem)
{

}
else
{

}

//----------------------------------------------------------------------------------
#define IMPROVED_ENUM_NAME  TextureAlign
#define IMPROVED_ENUM_LIST   ENUMITEM(ALIGN_NONE) \
ENUMITEM(ALIGN_EXPAND) \
ENUMITEM(ALIGN_LEFT) \
ENUMITEM(ALIGN_RIGHT)         \
ENUMITEM(ALIGN_TOP) \
ENUMITEM(ALIGN_BOTTOM) \
ENUMITEM(ALIGN_BOTTOM_RIGHT)
#include "defineImprovedEnum.h"


//----------------------------------------------------------------------------------
#define IMPROVED_ENUM_NAME  ccTalkFlags
#define IMPROVED_ENUM_LIST ENUMITEM_VALUE(Log, 1) \
ENUMITEM_VALUE(ErrorLog, 2) \
ENUMITEM_VALUE(BoxMessage, 4) \
ENUMITEM_VALUE(TextMessage, 8) \
ENUMITEM_VALUE(Acknowledge, 16) \
ENUMITEM_VALUE(Reset, 32)
#include "defineImprovedEnum.h"

5
Help requests / Re: "ReturnKeyPressed" Signal on textbox widget
« on: 03 March 2019, 10:32:33 »
Quote
childWindow->onClose.connect([]{});

The above declaration isn't easy to be found if you looking for the signals.

Quote
childWindow->connect.onClose([]{});
Quote
childWindow->connect.onShow([]{});
Quote
childWindow->connect.onMinimize([]{});

These are much more clarified for me but i don't know if it can be implemented in your current code.

I would prefer constants or enums for the general purpose since signals should be loaded from txt file.

6
Help requests / Re: "ReturnKeyPressed" Signal on textbox widget
« on: 02 March 2019, 12:26:42 »
Let me think about it.
In meantime think about enums.
Instead of string and constants you can use enums and along with some inline functions you can easily check validness or you can use "defineImprovedEnum.h".
I use it all the time.


https://www.codeproject.com/Articles/32000/Improving-C-Enums-Adding-Serialization-Inheritance?msg=3818041#xx3818041xx

7
Help requests / Re: "ReturnKeyPressed" Signal on textbox widget
« on: 01 March 2019, 19:45:40 »
Defining constants is a brilliant idea and this can eliminate stupid errors like mine. Adding a web page with all signals on the other hand, will be very helpful but not necessary if you implement constants.



8
Help requests / Re: "ReturnKeyPressed" Signal on textbox widget
« on: 01 March 2019, 19:13:58 »
My silly mistake!!

I had opened "Editbox.hpp" to find the signal strings but i was using textbox instead of editbox!

In the future can you gather all signal strings for all widgets in on hpp file? is my thought correct?

9
Help requests / Re: "ReturnKeyPressed" Signal on textbox widget
« on: 01 March 2019, 18:59:46 »
like this:
Code: [Select]
void CALLBACK pressedFunc(tgui::TextBox::Ptr box)
{

}

Tip: I do not use both connect functions at once in my code. I just used one at a time. But both has given me exception.

10
Help requests / "ReturnKeyPressed" Signal on textbox widget
« on: 01 March 2019, 08:42:03 »
Code: [Select]
pTextBox->connect("ReturnKeyPressed", [&]()
{

});

pTextBox->connect("ReturnKeyPressed", pressedFunc, pTextBox);

both above declarations are giving me an exception.

Quote
Exception thrown at 0x743B18A2 in Tgui.exe: Microsoft C++ exception: tgui::Exception at memory location 0x0113EA68.
Unhandled exception at 0x743B18A2 in Tgui.exe: Microsoft C++ exception: tgui::Exception at memory location 0x0113EA68.

in
Quote
unsigned int SignalWidgetBase::connect(std::string signalName, Func&& handler, const Args&... args)

I am using the day before yesterday's patch. (before "right click" in listview fixed)

Missing something?



11
Feature requests / Re: listview and add item
« on: 28 February 2019, 11:24:29 »
Check this out

Code: [Select]

#if defined NDEBUG
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif

#define USE_TGUI
#include "SFML_libs.hpp"

#include <TGUI/TGUI.hpp>

using namespace std;

bool running = true;

//https://scitechdaily.com/chandra-solves-the-universes-missing-mass-problem/
const std::string dataStr =
{
"New results from NASA’s Chandra X - ray Observatory may have helped solve the Universe’s “missing mass” problem. Astronomers cannot account for about a third of the normal matter — that is, hydrogen, helium, and other elements — that were created in the first billion years or so after the Big Bang."
"Scientists have proposed that the missing mass could be hidden in gigantic strands or filaments of warm(temperature less than 100,000 Kelvin) and hot(temperature greater than 100,000 K) gas in intergalactic space.These filaments are known by astronomers as the “warm - hot intergalactic medium” or WHIM."
"They are invisible to optical light telescopes, but some of the warm gas in filaments has been detected in ultraviolet light.The main part of this graphic is from the Millennium simulation, which uses supercomputers to formulate how the key components of the Universe, including the WHIM, would have evolved over cosmic time."
"If these filaments exist, they could absorb certain types of light such as X - rays that pass through them.The inset in this graphic represents some of the X - ray data collected by Chandra from a distant, rapidly - growing supermassive black hole known as a quasar.The plot is a spectrum — the amount of X - rays over a range"
"of wavelengths — from a new study of the quasar H1821 + 643 that is located about 3.4 billion light years from Earth."
"The latest result uses a new technique that both hones the search for the WHIM carefully and boosts the relatively weak absorption signature by combining different parts of the spectrum to find a valid signal.With this technique, researchers identified 17 possible filaments lying between the quasar and Earth, and obtained their distances."
};

bool matchCase(false);
bool matchWholeWord(false);

std::string::size_type  search_Index = std::string::npos;

std::string lower_string(const std::string& str)
{
string lower;
if (matchCase)
lower = str;
else
transform(str.begin(), str.end(), std::back_inserter(lower), tolower);
return lower;
}

std::string::size_type find_str_ci(const std::string& str, const std::string& substr)
{
if (matchWholeWord)
{
string findStr = " " + substr + " ";
return lower_string(str).find(lower_string(findStr));
}
return lower_string(str).find(lower_string(substr));
}

//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI window");
window.setFramerateLimit(60);

tgui::Gui gui(window);

auto pTextBox = tgui::TextBox::create();
pTextBox->setPosition(50, 100);
pTextBox->setSize(700, 470);
pTextBox->setTextSize(16);
pTextBox->setText(dataStr);
gui.add(pTextBox);

auto pSearchTextBox = tgui::TextBox::create();
pSearchTextBox->setPosition(50, 50);
pSearchTextBox->setSize(200, 30);
pSearchTextBox->setTextSize(16);

pSearchTextBox->connect("TextChanged", [&]()
{
search_Index = find_str_ci(dataStr.c_str(), pSearchTextBox->getText().toAnsiString().c_str());

if (search_Index != std::string::npos)
{
pTextBox->setSelectedText(matchWholeWord ? search_Index + 1: search_Index, matchWholeWord ? search_Index + pSearchTextBox->getText().toAnsiString().size() + 1 : search_Index + pSearchTextBox->getText().toAnsiString().size());
}
else
{
pTextBox->setSelectedText(0, 0);
}
});
gui.add(pSearchTextBox);

auto pCheckBoxCase = tgui::CheckBox::create();
pCheckBoxCase->setPosition(300, 50);
pCheckBoxCase->setText("Match case");
pCheckBoxCase->setSize(25, 25);
pCheckBoxCase->connect("Changed", [&]()
{
matchCase = !matchCase;
pTextBox->setSelectedText(0, 0);
pSearchTextBox->setText("");
});
gui.add(pCheckBoxCase);

auto pCheckBoxWord = tgui::CheckBox::create();
pCheckBoxWord->setPosition(470, 50);
pCheckBoxWord->setText("Match whole word");
pCheckBoxWord->setSize(25, 25);
pCheckBoxWord->connect("Changed", [&]()
{
matchWholeWord = !matchWholeWord;
pTextBox->setSelectedText(0, 0);
pSearchTextBox->setText("");
});

gui.add(pCheckBoxWord);

while (running)
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
{
running = false;
}
break;
case sf::Event::MouseButtonPressed:
{

}
break;
case sf::Event::KeyPressed:
{
if (event.key.code == sf::Keyboard::Escape)
running = false;
break;
}
}

gui.handleEvent(event);
}

window.clear(sf::Color(200, 200, 200, 255));
gui.draw();
window.display();
}

return EXIT_SUCCESS;
}

12
Feature requests / Re: listview and add item
« on: 27 February 2019, 15:01:53 »
Quote
Maybe a highlighted text is identical with selected text. And there is selected text in text box.

My mistake. In this phrase i should added one more sentence. This phrase:

Quote
So you can use selected text instead of highlight text.

So, forget everything about "hightlighted" text.

A function like setSelectedText(size_t indexBegin, size_t sizeLetters) can be used in any case of making (in our code) a search functionality. After all in textbox there is a "getSelectedText" function.

I realize that "setHorizontalAlignment and setVerticalAlignment for textbox" were missing when yesterday i tried to make an example while we were talking about searching functionality in textboxes. I overcome this lack by declearing bigger font size. But at the end i never finished this example due to lack of "setSelectedText" function.




13
Feature requests / Re: listview and add item
« on: 26 February 2019, 21:39:08 »
A "setSelectedText(size_t indexBegin, size_t sizeLetters)" function for textbox widget would be useful in many cases.

Also can not found setHorizontalAlignment and setVerticalAlignment for textbox. Have you miss them for any particular reason?



14
Feature requests / Re: listview and add item
« on: 26 February 2019, 20:39:03 »
Maybe a highlighted text is identical with selected text. And there is selected text in text box.

Normally the search in a listview apply to all columns but also this is not a huge handicap .

And yes everything that i thought about can be implemented in our code. ;D

15
Feature requests / Re: listview and add item
« on: 26 February 2019, 20:03:42 »

Quote
Also this functionality can be added to current "textbox"

So a search box is actually a text box. Just see on top right on visual studio or press "ctrl+F" in notepad. The text found (if found) is highlighted! Easy!

However in a listview the lines-rowes that does not contain the request searched string must be excluded.

Pages: [1] 2 3 ... 8