Skip to content

Commit

Permalink
[geogram] Update to 1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
simogasp committed Jul 13, 2019
1 parent 9819658 commit dd43bd5
Show file tree
Hide file tree
Showing 11 changed files with 572 additions and 39 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ include(cmake/geogram.cmake)

set(VORPALINE_VERSION_MAJOR 1)
set(VORPALINE_VERSION_MINOR 7)
set(VORPALINE_VERSION_PATCH 0)
set(VORPALINE_VERSION_PATCH 1)
set(VORPALINE_VERSION ${VORPALINE_VERSION_MAJOR}.${VORPALINE_VERSION_MINOR}.${VORPALINE_VERSION_PATCH})

set(VORPALINE_INCLUDE_SUBPATH geogram${VORPALINE_VERSION_MAJOR})
Expand Down
4 changes: 0 additions & 4 deletions src/examples/graphics/demo_Delaunay2d/gui_state.h

This file was deleted.

13 changes: 6 additions & 7 deletions src/examples/graphics/demo_Delaunay2d/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include <geogram_gfx/gui/simple_application.h>
#include <geogram/delaunay/delaunay.h>
#include <geogram/numerics/predicates.h>
#include "gui_state.h"

namespace {
using namespace GEO;
Expand Down Expand Up @@ -745,7 +744,12 @@ namespace {
SimpleApplication::cursor_pos_callback(x,y,source);
return;
}
mouse_point_ = unproject_2d(vec2(x,double(get_height()-y)));
mouse_point_ = unproject_2d(
vec2(
x,
double(get_height()) * hidpi_scaling() - y
)
);
if(animate()) {
if(last_button_ == 0) {
points_.push_back(mouse_point_);
Expand All @@ -766,11 +770,6 @@ namespace {
}
}

void geogram_initialize(int argc, char** argv) override {
SimpleApplication::geogram_initialize(argc, argv);
set_gui_state(gui_state);
}

private:
vector<vec2> points_;
vector<vec2> new_points_;
Expand Down
29 changes: 17 additions & 12 deletions src/lib/geogram_gfx/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ namespace GEO {
* \brief Computes the pixel ratio for hidpi devices.
* \details Uses the current GLFW window.
*/
double pixel_ratio();
double compute_pixel_ratio();

/**
* \brief Computes the scaling factor for hidpi devices.
* \details Uses the current GLFW window.
*/
double hidpi_scaling();
double compute_hidpi_scaling();


/**
Expand Down Expand Up @@ -632,8 +632,8 @@ namespace GEO {
glfwMakeContextCurrent(data_->window_);
glfwSwapInterval(1);

hidpi_scaling_ = hidpi_scaling();
pixel_ratio_ = pixel_ratio();
hidpi_scaling_ = compute_hidpi_scaling();
pixel_ratio_ = compute_pixel_ratio();

Logger::out("Skin")
<< "hidpi_scaling=" << hidpi_scaling_ << std::endl;
Expand Down Expand Up @@ -680,10 +680,10 @@ namespace GEO {
// monitor.
if(
glfwGetCurrentContext() != nullptr &&
hidpi_scaling() != hidpi_scaling_
compute_hidpi_scaling() != hidpi_scaling_
) {
hidpi_scaling_ = hidpi_scaling();
pixel_ratio_ = pixel_ratio();
hidpi_scaling_ = compute_hidpi_scaling();
pixel_ratio_ = compute_pixel_ratio();
set_font_size(font_size_); // This reloads the font.
}
}
Expand Down Expand Up @@ -787,7 +787,8 @@ namespace GEO {
app->impl_data()->ImGui_callback_cursor_pos(w, xf, yf);
}
if(!ImGui::GetIO().WantCaptureMouse) {
app->cursor_pos_callback(xf, yf);
double s = app->hidpi_scaling();
app->cursor_pos_callback(s*xf, s*yf);
}
}

Expand Down Expand Up @@ -1204,16 +1205,20 @@ namespace GEO {

#if defined(GEO_GLFW) && !defined(GEO_OS_EMSCRIPTEN)

double pixel_ratio() {
double compute_pixel_ratio() {
int buf_size[2];
int win_size[2];
GLFWwindow* window = glfwGetCurrentContext();
glfwGetFramebufferSize(window, &buf_size[0], &buf_size[1]);
glfwGetWindowSize(window, &win_size[0], &win_size[1]);
// The window may be iconified.
if(win_size[0] == 0) {
return 1.0;
}
return double(buf_size[0]) / double(win_size[0]);
}

double hidpi_scaling() {
double compute_hidpi_scaling() {
float xscale, yscale;
GLFWwindow* window = glfwGetCurrentContext();
glfwGetWindowContentScale(window, &xscale, &yscale);
Expand All @@ -1222,11 +1227,11 @@ namespace GEO {

#else

double pixel_ratio() {
double compute_pixel_ratio() {
return 1.0;
}

double hidpi_scaling() {
double compute_hidpi_scaling() {
return 1.0;
}

Expand Down
27 changes: 25 additions & 2 deletions src/lib/geogram_gfx/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,29 @@ namespace GEO {
* \return a pointer to the implementation-specific window.
*/
void* impl_window();

/**
* \brief MacOS non-sense
* \return a scaling factor between real pixels and logical
* pixels or something, well I do not understand. Sometimes
* you need to multiply by it, sometimes to divide, and
* sometimes you need to use pixel_ratio() instead.
*/
double hidpi_scaling() const {
return hidpi_scaling_;
}

/**
* \brief More MacOS non-sense
* \return something like hidpi_scaling(), that is a scaling
* factor between real pixels and logical
* pixels or something, well I do not understand.
* Sometimes you need to multiply by it, sometimes to divide,
* and sometimes you need to use hidpi_scaling() instead.
*/
double pixel_ratio() const {
return pixel_ratio_;
}

protected:

Expand Down Expand Up @@ -526,7 +549,7 @@ namespace GEO {
animate_ = false;
}

private:
private:
static Application* instance_; /**< a pointer to the instance */
ApplicationData* data_; /**< implementation dependent */
index_t width_; /**< window width */
Expand All @@ -547,7 +570,7 @@ namespace GEO {
bool currently_drawing_gui_; /**< currently drawing ImGui elements */
std::vector<std::string> filenames_; /**< from the command line */
bool animate_; /**< true if drawing always */
protected:
protected:
bool menubar_visible_;
};

Expand Down
176 changes: 175 additions & 1 deletion src/lib/geogram_gfx/gui/gui_state.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,178 @@
// Serialized ImGui windows docking configuration
// generated using <geogram_program> gui:expert=true
// then Windows->Export gui state to C++
const char gui_state[] = u8"[Window][DockSpace] Pos=0,0 Size=1024,1024 Collapsed=0 [Window][ Viewer] Pos=0,24 Size=158,825 Collapsed=0 DockId=0x00000009,0 [Window][ Object] Pos=858,24 Size=166,825 Collapsed=0 DockId=0x00000004,0 [Window][Console] Pos=0,851 Size=1024,172 Collapsed=0 DockId=0x00000002 [Window][Text Editor] Pos=220,24 Size=580,764 Collapsed=0 DockId=0x00000006,1 [Window][Debug##Default] Pos=60,60 Size=400,400 Collapsed=0 [Window][ImGui Demo] Pos=160,24 Size=640,764 Collapsed=0 DockId=0x00000006,0 [Window][say hello] Pos=0,496 Size=158,292 Collapsed=0 DockId=0x00000008 [Window][Command] Pos=0,493 Size=158,295 Collapsed=0 DockId=0x0000000A [Docking][Data] DockSpace ID=0x09EF459F Pos=0,24 Size=1024,999 Split=Y DockNode ID=0x00000001 Parent=0x09EF459F SizeRef=1024,825 Split=X DockNode ID=0x00000003 Parent=0x00000001 SizeRef=856,764 Split=X DockNode ID=0x00000005 Parent=0x00000003 SizeRef=158,764 Split=Y SelectedTab=0x07957BC8 DockNode ID=0x00000007 Parent=0x00000005 SizeRef=158,470 Split=Y SelectedTab=0x07957BC8 DockNode ID=0x00000009 Parent=0x00000007 SizeRef=158,467 HiddenTabBar=1 SelectedTab=0x07957BC8 DockNode ID=0x0000000A Parent=0x00000007 SizeRef=158,295 HiddenTabBar=1 SelectedTab=0x4177D348 DockNode ID=0x00000008 Parent=0x00000005 SizeRef=158,292 HiddenTabBar=1 SelectedTab=0xBD088ACE DockNode ID=0x00000006 Parent=0x00000003 SizeRef=696,764 CentralNode=1 HiddenTabBar=1 SelectedTab=0x080FC883 DockNode ID=0x00000004 Parent=0x00000001 SizeRef=166,764 HiddenTabBar=1 SelectedTab=0xB7250CB4 DockNode ID=0x00000002 Parent=0x09EF459F SizeRef=1024,172 HiddenTabBar=1 SelectedTab=0xF9BEF62A ";
const char gui_state[] = {
91,87,105,110,100,111,119,93,91,68,
111,99,107,83,112,97,99,101,93,9,
80,111,115,61,48,44,48,9,83,105,
122,101,61,49,48,50,52,44,49,48,
50,52,9,67,111,108,108,97,112,115,
101,100,61,48,9,9,91,87,105,110,
100,111,119,93,91,char(239), char(128), char(176), 32,86,
105,101,119,101,114,93,9,80,111,115,
61,48,44,50,52,9,83,105,122,101,
61,49,53,56,44,56,50,53,9,67,
111,108,108,97,112,115,101,100,61,48,
9,68,111,99,107,73,100,61,48,120,
48,48,48,48,48,48,48,57,44,48,
9,9,91,87,105,110,100,111,119,93,
91,char(239), char(129), char(132), 32,79,98,106,101,99,
116,93,9,80,111,115,61,56,53,56,
44,50,52,9,83,105,122,101,61,49,
54,54,44,56,50,53,9,67,111,108,
108,97,112,115,101,100,61,48,9,68,
111,99,107,73,100,61,48,120,48,48,
48,48,48,48,48,52,44,48,9,9,
91,87,105,110,100,111,119,93,91,67,
111,110,115,111,108,101,93,9,80,111,
115,61,48,44,56,53,49,9,83,105,
122,101,61,49,48,50,52,44,49,55,
50,9,67,111,108,108,97,112,115,101,
100,61,48,9,68,111,99,107,73,100,
61,48,120,48,48,48,48,48,48,48,
50,9,9,91,87,105,110,100,111,119,
93,91,84,101,120,116,32,69,100,105,
116,111,114,93,9,80,111,115,61,50,
50,48,44,50,52,9,83,105,122,101,
61,53,56,48,44,55,54,52,9,67,
111,108,108,97,112,115,101,100,61,48,
9,68,111,99,107,73,100,61,48,120,
48,48,48,48,48,48,48,54,44,49,
9,9,91,87,105,110,100,111,119,93,
91,68,101,98,117,103,35,35,68,101,
102,97,117,108,116,93,9,80,111,115,
61,54,48,44,54,48,9,83,105,122,
101,61,52,48,48,44,52,48,48,9,
67,111,108,108,97,112,115,101,100,61,
48,9,9,91,87,105,110,100,111,119,
93,91,73,109,71,117,105,32,68,101,
109,111,93,9,80,111,115,61,49,54,
48,44,50,52,9,83,105,122,101,61,
54,52,48,44,55,54,52,9,67,111,
108,108,97,112,115,101,100,61,48,9,
68,111,99,107,73,100,61,48,120,48,
48,48,48,48,48,48,54,44,48,9,
9,91,87,105,110,100,111,119,93,91,
115,97,121,32,104,101,108,108,111,93,
9,80,111,115,61,48,44,52,57,54,
9,83,105,122,101,61,49,53,56,44,
50,57,50,9,67,111,108,108,97,112,
115,101,100,61,48,9,68,111,99,107,
73,100,61,48,120,48,48,48,48,48,
48,48,56,9,9,91,87,105,110,100,
111,119,93,91,67,111,109,109,97,110,
100,93,9,80,111,115,61,48,44,52,
57,51,9,83,105,122,101,61,49,53,
56,44,50,57,53,9,67,111,108,108,
97,112,115,101,100,61,48,9,68,111,
99,107,73,100,61,48,120,48,48,48,
48,48,48,48,65,9,9,91,68,111,
99,107,105,110,103,93,91,68,97,116,
97,93,9,68,111,99,107,83,112,97,
99,101,32,32,32,32,32,32,32,32,
32,32,32,73,68,61,48,120,48,57,
69,70,52,53,57,70,32,80,111,115,
61,48,44,50,52,32,83,105,122,101,
61,49,48,50,52,44,57,57,57,32,
83,112,108,105,116,61,89,9,32,32,
68,111,99,107,78,111,100,101,32,32,
32,32,32,32,32,32,32,32,73,68,
61,48,120,48,48,48,48,48,48,48,
49,32,80,97,114,101,110,116,61,48,
120,48,57,69,70,52,53,57,70,32,
83,105,122,101,82,101,102,61,49,48,
50,52,44,56,50,53,32,83,112,108,
105,116,61,88,9,32,32,32,32,68,
111,99,107,78,111,100,101,32,32,32,
32,32,32,32,32,73,68,61,48,120,
48,48,48,48,48,48,48,51,32,80,
97,114,101,110,116,61,48,120,48,48,
48,48,48,48,48,49,32,83,105,122,
101,82,101,102,61,56,53,54,44,55,
54,52,32,83,112,108,105,116,61,88,
9,32,32,32,32,32,32,68,111,99,
107,78,111,100,101,32,32,32,32,32,
32,73,68,61,48,120,48,48,48,48,
48,48,48,53,32,80,97,114,101,110,
116,61,48,120,48,48,48,48,48,48,
48,51,32,83,105,122,101,82,101,102,
61,49,53,56,44,55,54,52,32,83,
112,108,105,116,61,89,32,83,101,108,
101,99,116,101,100,84,97,98,61,48,
120,48,55,57,53,55,66,67,56,9,
32,32,32,32,32,32,32,32,68,111,
99,107,78,111,100,101,32,32,32,32,
73,68,61,48,120,48,48,48,48,48,
48,48,55,32,80,97,114,101,110,116,
61,48,120,48,48,48,48,48,48,48,
53,32,83,105,122,101,82,101,102,61,
49,53,56,44,52,55,48,32,83,112,
108,105,116,61,89,32,83,101,108,101,
99,116,101,100,84,97,98,61,48,120,
48,55,57,53,55,66,67,56,9,32,
32,32,32,32,32,32,32,32,32,68,
111,99,107,78,111,100,101,32,32,73,
68,61,48,120,48,48,48,48,48,48,
48,57,32,80,97,114,101,110,116,61,
48,120,48,48,48,48,48,48,48,55,
32,83,105,122,101,82,101,102,61,49,
53,56,44,52,54,55,32,72,105,100,
100,101,110,84,97,98,66,97,114,61,
49,32,83,101,108,101,99,116,101,100,
84,97,98,61,48,120,69,70,52,70,
68,57,51,69,9,32,32,32,32,32,
32,32,32,32,32,68,111,99,107,78,
111,100,101,32,32,73,68,61,48,120,
48,48,48,48,48,48,48,65,32,80,
97,114,101,110,116,61,48,120,48,48,
48,48,48,48,48,55,32,83,105,122,
101,82,101,102,61,49,53,56,44,50,
57,53,32,72,105,100,100,101,110,84,
97,98,66,97,114,61,49,32,83,101,
108,101,99,116,101,100,84,97,98,61,
48,120,52,49,55,55,68,51,52,56,
9,32,32,32,32,32,32,32,32,68,
111,99,107,78,111,100,101,32,32,32,
32,73,68,61,48,120,48,48,48,48,
48,48,48,56,32,80,97,114,101,110,
116,61,48,120,48,48,48,48,48,48,
48,53,32,83,105,122,101,82,101,102,
61,49,53,56,44,50,57,50,32,72,
105,100,100,101,110,84,97,98,66,97,
114,61,49,32,83,101,108,101,99,116,
101,100,84,97,98,61,48,120,66,68,
48,56,56,65,67,69,9,32,32,32,
32,32,32,68,111,99,107,78,111,100,
101,32,32,32,32,32,32,73,68,61,
48,120,48,48,48,48,48,48,48,54,
32,80,97,114,101,110,116,61,48,120,
48,48,48,48,48,48,48,51,32,83,
105,122,101,82,101,102,61,54,57,54,
44,55,54,52,32,67,101,110,116,114,
97,108,78,111,100,101,61,49,32,72,
105,100,100,101,110,84,97,98,66,97,
114,61,49,32,83,101,108,101,99,116,
101,100,84,97,98,61,48,120,48,56,
48,70,67,56,56,51,9,32,32,32,
32,68,111,99,107,78,111,100,101,32,
32,32,32,32,32,32,32,73,68,61,
48,120,48,48,48,48,48,48,48,52,
32,80,97,114,101,110,116,61,48,120,
48,48,48,48,48,48,48,49,32,83,
105,122,101,82,101,102,61,49,54,54,
44,55,54,52,32,72,105,100,100,101,
110,84,97,98,66,97,114,61,49,32,
83,101,108,101,99,116,101,100,84,97,
98,61,48,120,53,50,52,50,57,55,
52,51,9,32,32,68,111,99,107,78,
111,100,101,32,32,32,32,32,32,32,
32,32,32,73,68,61,48,120,48,48,
48,48,48,48,48,50,32,80,97,114,
101,110,116,61,48,120,48,57,69,70,
52,53,57,70,32,83,105,122,101,82,
101,102,61,49,48,50,52,44,49,55,
50,32,72,105,100,100,101,110,84,97,
98,66,97,114,61,49,32,83,101,108,
101,99,116,101,100,84,97,98,61,48,
120,70,57,66,69,70,54,50,65,9,
9, 0 };
Loading

0 comments on commit dd43bd5

Please sign in to comment.