Skip to content

Commit 6bf0396

Browse files
committed
Add FLTK, gtkmm and imgui examples
1 parent f2eb974 commit 6bf0396

19 files changed

+26774
-0
lines changed

fltk/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Example FLTK code from http://www.fltk.org/doc-1.3/basics.html

fltk/test_fltk.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <FL/Fl.H>
2+
#include <FL/Fl_Window.H>
3+
#include <FL/Fl_Box.H>
4+
#include <iostream>
5+
6+
int main(int argc, char **argv) {
7+
std::cout << "utf8 locale " << fl_utf8locale() << '\n';
8+
Fl_Window *window = new Fl_Window(340,180);
9+
Fl_Box *box = new Fl_Box(20,40,300,100, "Hello World" );
10+
box->box(FL_UP_BOX);
11+
box->labelfont(FL_BOLD+FL_ITALIC);
12+
box->labelsize(32);
13+
box->labeltype(FL_SHADOW_LABEL);
14+
window->end();
15+
window->show(argc, argv);
16+
return Fl::run();
17+
}
18+
19+
20+

gtkmm/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Example Hello World from https://developer.gnome.org/gtkmm-tutorial/stable/sec-helloworld.html.en

gtkmm/hello_world.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "hello_world.hpp"
2+
#include <iostream>
3+
4+
HelloWorld::HelloWorld()
5+
: m_button("Hello World") // creates a new button with label "Hello World".
6+
{
7+
// Sets the border width of the window.
8+
set_border_width(10);
9+
10+
// When the button receives the "clicked" signal, it will call the
11+
// on_button_clicked() method defined below.
12+
m_button.signal_clicked().connect(sigc::mem_fun(*this,
13+
&HelloWorld::on_button_clicked));
14+
15+
// This packs the button into the Window (a container).
16+
add(m_button);
17+
18+
// The final step is to display this newly created widget...
19+
m_button.show();
20+
}
21+
22+
23+
void HelloWorld::on_button_clicked()
24+
{
25+
std::cout << "Hello World\n";
26+
}
27+

gtkmm/hello_world.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef GTKMM_EXAMPLE_HELLO_WORLD_HPP
2+
#define GTKMM_EXAMPLE_HELLO_WORLD_HPP
3+
4+
#include <gtkmm/button.h>
5+
#include <gtkmm/window.h>
6+
7+
class HelloWorld : public Gtk::Window
8+
{
9+
10+
public:
11+
HelloWorld();
12+
13+
protected:
14+
//Signal handlers:
15+
void on_button_clicked();
16+
17+
//Member widgets:
18+
Gtk::Button m_button;
19+
};
20+
21+
#endif // GTKMM_EXAMPLE_HELLO_WORLD_HPP
22+

gtkmm/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "hello_world.hpp"
2+
#include <gtkmm/application.h>
3+
4+
int main (int argc, char *argv[])
5+
{
6+
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
7+
8+
HelloWorld helloworld;
9+
10+
//Shows the window and returns when it is closed.
11+
return app->run(helloworld);
12+
}
13+

imgui/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Example of using imgui with SFML from https://github.com/eliasdaler/imgui-sfml

imgui/imconfig.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <SFML/System/Vector2.hpp>
2+
#include <SFML/Graphics/Color.hpp>
3+
4+
#define IM_VEC2_CLASS_EXTRA \
5+
template <typename T> \
6+
ImVec2(const sf::Vector2<T>& v) { \
7+
x = static_cast<float>(v.x); \
8+
y = static_cast<float>(v.y); \
9+
} \
10+
\
11+
template <typename T> \
12+
operator sf::Vector2<T>() const { \
13+
return sf::Vector2<T>(x, y); \
14+
}
15+
16+
#define IM_VEC4_CLASS_EXTRA \
17+
ImVec4(const sf::Color & c) \
18+
: ImVec4(c.r / 255.f, c.g / 255.f, c.b / 255.f, c.a / 255.f) { \
19+
} \
20+
operator sf::Color() const { \
21+
return sf::Color(static_cast<sf::Uint8>(x * 255.f), \
22+
static_cast<sf::Uint8>(y * 255.f), \
23+
static_cast<sf::Uint8>(z * 255.f), \
24+
static_cast<sf::Uint8>(w * 255.f)); \
25+
}

0 commit comments

Comments
 (0)