Skip to content
Permalink
Browse files

Removed references to old node code and switched to libpapaya. Brushi…

…ng, undo, etc. is currently disabled
  • Loading branch information...
Apoorva Joshi
Apoorva Joshi committed Feb 1, 2017
1 parent be463e6 commit e24c8570d83f2cadf3add300044156380f7c6764
@@ -13,7 +13,6 @@ SRCS=linux_ui.cpp \
single_header_libs.cpp \
crop_rotate.cpp \
metrics_window.cpp \
node.cpp \
brush.cpp \
color_panel.cpp \
eye_dropper.cpp \
@@ -89,11 +89,6 @@ struct PapayaNode {
} params;
};

struct PapayaDocument {
PapayaNode* nodes;
int num_nodes;
};

// -----------------------------------------------------------------------------

void papaya_evaluate_node(PapayaNode* node, int w, int h, uint8_t* out);

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,6 +1,7 @@

#include "brush.h"
#include "libs/mathlib.h"
#include "libs/linmath.h"
#include "ui.h"
#include "pagl.h"
#include "gl_lite.h"
@@ -91,31 +92,34 @@ static void clear_brush_frame_buffer(PapayaMemory* mem)

static void draw_brush_stroke(PapayaMemory* mem)
{
// TODO: Implement
#if 0
Brush* b = mem->brush;
mem->misc.draw_overlay = true;

// TODO: Handle shift press for straight brush strokes

// Bind frame buffer
GLCHK( glBindFramebuffer(GL_FRAMEBUFFER, mem->misc.fbo) );
GLCHK( glViewport(0, 0, mem->cur_doc->width, mem->cur_doc->height) );
GLCHK( glViewport(0, 0, mem->doc->canvas_size.x, mem->doc->canvas_size.y) );
GLCHK( glDisable(GL_BLEND) );
GLCHK( glDisable(GL_SCISSOR_TEST) );

{
GLCHK( glUseProgram(b->pgm_stroke->id) );

// TODO: Tidy up the uniform calculation variables
f32 w = (f32)mem->cur_doc->width;
f32 h = (f32)mem->cur_doc->height;
f32 w = (f32)mem->doc->canvas_size.x;
f32 h = (f32)mem->doc->canvas_size.y;
Vec2 c = (b->diameter % 2 == 0 ? Vec2() :
Vec2(0.5f / w, 0.5f / h)); // Pixel correction

Vec2 pos = mem->mouse.uv + c;
Vec2 last_pos = (b->draw_line_segment ?
b->line_segment_start_uv : mem->mouse.last_uv) + c;
pos.y *= mem->cur_doc->inverse_aspect;
last_pos.y *= mem->cur_doc->inverse_aspect;
f32 inv_aspect = mem->doc->canvas_size.y / mem->doc->canvas_size.x;
pos.y *= inv_aspect;
last_pos.y *= inv_aspect;

b->draw_line_segment = false;

@@ -130,21 +134,27 @@ static void draw_brush_stroke(PapayaMemory* mem)
}
}

f32 uv_dia = (f32)b->diameter / ((f32)mem->cur_doc->width * 2.0f);
f32 uv_dia = (f32)b->diameter / (mem->doc->canvas_size.x * 2.0f);
Color* a = &mem->color_panel->current_color;
Color col = Color(a->r, a->g, a->b, b->opacity);

GLCHK( glDisable(GL_BLEND) );

f32 proj_mtx[4][4];
mat4x4_ortho(proj_mtx, 0.f,
mem->doc->canvas_size.x, 0.f,
mem->doc->canvas_size.y,
-1.f, 1.f);

pagl_draw_mesh(b->mesh_RTTBrush, b->pgm_stroke, 8,
Pagl_UniformType_Matrix4, &mem->cur_doc->proj_mtx[0][0],
Pagl_UniformType_Matrix4, &proj_mtx[0][0],
Pagl_UniformType_Tex0, mem->misc.fbo_sample_tex,
Pagl_UniformType_Vec2, pos,
Pagl_UniformType_Vec2, last_pos,
Pagl_UniformType_Float, uv_dia,
Pagl_UniformType_Color, col,
Pagl_UniformType_Float, hardness,
Pagl_UniformType_Float, mem->cur_doc->inverse_aspect);
Pagl_UniformType_Float, inv_aspect);
}

// Swap textures
@@ -175,12 +185,12 @@ static void draw_brush_stroke(PapayaMemory* mem)
1,
Pagl_UniformType_Matrix4, &mem->window.proj_mtx[0][0]);
}

#endif
}

static void draw_brush_cursor(PapayaMemory* mem)
{
f32 ScaledDiameter = mem->brush->diameter * mem->cur_doc->canvas_zoom;
f32 ScaledDiameter = mem->brush->diameter * mem->doc->canvas_zoom;

pagl_transform_quad_mesh(mem->brush->mesh_cursor,
(mem->mouse.is_down[1] ||
@@ -242,7 +252,7 @@ void update_and_render_brush(PapayaMemory* mem)
f32 opacity = b->rt_drag_start_opacity + (delta.x * 0.0025f);
b->opacity = math::clamp(opacity, 0.0f, 1.0f);
} else {
f32 zoom = mem->cur_doc ? mem->cur_doc->canvas_zoom : 1.0f;
f32 zoom = mem->doc ? mem->doc->canvas_zoom : 1.0f;
f32 dia = b->rt_drag_start_diameter + (delta.x / zoom * 2.0f);
b->diameter = math::clamp((i32)dia, 1, b->max_diameter);

@@ -264,8 +274,8 @@ void update_and_render_brush(PapayaMemory* mem)
b->being_dragged = true;
b->draw_line_segment = (ImGui::GetIO().KeyShift &&
b->line_segment_start_uv.x >= 0.0f);
b->paint_area_1 = Vec2i(mem->cur_doc->width + 1,
mem->cur_doc->height + 1);
b->paint_area_1 = Vec2i(mem->doc->canvas_size.x + 1,
mem->doc->canvas_size.y + 1);
b->paint_area_2 = Vec2i(0,0);
clear_brush_frame_buffer(mem);

@@ -25,6 +25,8 @@ void crop_rotate::init(PapayaMemory* mem)

void crop_rotate::toolbar(PapayaMemory* mem)
{
// TODO: Implement
#if 0
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3, 0));
if (ImGui::Button("-90")) { mem->crop_rotate.base_rotation--; }
ImGui::SameLine();
@@ -128,10 +130,13 @@ void crop_rotate::toolbar(PapayaMemory* mem)
}

ImGui::PopStyleVar();
#endif
}

void crop_rotate::crop_outline(PapayaMemory* mem)
{
// TODO: Implement
#if 0
// TODO: Function lacks grace
Vec2 mouse = mem->mouse.pos;
Vec2 p[4];
@@ -302,4 +307,5 @@ void crop_rotate::crop_outline(PapayaMemory* mem)
mem->shaders[PapayaShader_VertexColor],
1,
Pagl_UniformType_Matrix4, &mem->window.proj_mtx[0][0]);
#endif
}
@@ -43,7 +43,7 @@ static PapayaSlot* find_snapped_slot(PapayaMemory* mem, Vec2 offset)
PapayaNode* snapped_node = 0; // Snapped node

// Find the node that is currently being moused over
for (int i = 0; i < mem->doc->num_nodes; i++) {
for (size_t i = 0; i < mem->doc->num_nodes; i++) {
PapayaNode* n = &mem->doc->nodes[i];

Vec2 p = offset + Vec2(n->pos_x, n->pos_y);
@@ -116,9 +116,9 @@ static void draw_nodes(PapayaMemory* mem)
GraphPanel* g = mem->graph_panel;
Vec2 offset = ImGui::GetCursorScreenPos() + g->scroll_pos;
ImDrawList* draw_list = ImGui::GetWindowDrawList();
int hovered_node = -1;
size_t hovered_node = -1;

for (int i = 0; i < mem->doc->num_nodes; i++) {
for (size_t i = 0; i < mem->doc->num_nodes; i++) {
PapayaNode* n = &mem->doc->nodes[i];
Vec2 pos = offset + Vec2(n->pos_x - 1, n->pos_y - 1);

@@ -9,7 +9,7 @@ struct GraphPanel {
Vec2 scroll_pos;
f32 node_properties_panel_height;
f32 width;
int cur_node; // Index of current node
size_t cur_node; // Index of current node
PapayaSlot* dragged_slot;
PapayaSlot* displaced_slot;
};

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit e24c857

Please sign in to comment.
You can’t perform that action at this time.