Skip to content

Commit

Permalink
for #410 - add emeus cassowary C code.
Browse files Browse the repository at this point in the history
* compiles and links linux, osx, mxe (not xwin7 - needs newer glib)
* doesn't run
  • Loading branch information
Cecil committed Oct 30, 2018
1 parent 4ac78e2 commit ae75958
Show file tree
Hide file tree
Showing 26 changed files with 5,355 additions and 42 deletions.
27 changes: 15 additions & 12 deletions Tests/layout/l3.rb
Expand Up @@ -5,7 +5,7 @@
include Cassowary
class CassowaryLayout
attr_accessor :canvas, :widgets, :solver, :attrs, :left_limit,
:right_limit, :top_limit, :height_limit, :right_limit_stay,
:right_limit, :top_limit, :height_limit, :rl_stay, :hl_stay,
:canvas_set, :canvas_w, :canvas_h

def initialize()
Expand Down Expand Up @@ -40,8 +40,11 @@ def setup(canvas, attr)
@right_limit = Variable.new(name: 'width', value: wid)
@top_limit = Variable.new(name: "top", value: 0.0)
@height_limit = Variable.new(name: "height", value: hgt)
@solver.add_stay(@left_limit)
@solver.add_stay(@right_limit, Strength::WeakStrength)

@solver.add_stay(@left_limit, Strength::RequiredStrength)
@rl_stay = @solver.add_stay(@right_limit)
@solver.add_stay(@top_limit, Strength::RequiredStrength)
@hl_stay = @solver.add_stay(@height_limit)
$stderr.puts "callback: setup #{wid} X #{hgt}"
end

Expand Down Expand Up @@ -80,11 +83,17 @@ def size(canvas, pass)
return
else
$stderr.puts "callback: size Change! w: #{canvas.width} h:#{canvas.height}"
# reset stays for new window size
#@solver.remove_constraint(@rl_stay)
@right_limit.value = canvas.width
#@rl_stay = @solver.add_constraint(@right_limit, Strength::RequiredStrength)
#@solver.add_constraint(@rl_stay)
@solver.solve
self.finish
end
end

def widget_defaults
@canvas.show
@widgets.each_pair do |id, ele|
vh = @attrs[id]['height']
vh.value = ele.height
Expand All @@ -95,13 +104,7 @@ def widget_defaults
end

def resize(w, h)
@right_limit.value = w
@height_limit.value = h
#@solver.add_stay(@right_limit, Strength::RequiredStrength)

#right_limit_stay = solver.add_constraint(right_limit, strength=REQUIRED)
#solver.add_constraint(right_limit_stay)
end
end

def clear()
$stderr.puts "callback: clear"
Expand Down Expand Up @@ -184,7 +187,7 @@ def method_missing(meth, *args, &block)
@ml.add_constraint(@ml.var('b2-width').cn_equal 113, Strength::StrongStrength)

# string b3 is at the bottom ?
@ml.add_constraint(@ml.height_limit.cn_equal @ml.var('b3-top'))
@ml.add_constraint(@ml.var('b3-top').cn_equal 100)

@lay.finish
@p.text = @lay.inspect
Expand Down
2 changes: 1 addition & 1 deletion Tests/layout/vfl3.rb
Expand Up @@ -11,7 +11,7 @@
end
@lay.start {
metrics = {
'el1' => 80 # what does this mean or do or should be?
'padding' => 10
}
lines = [
"H:|-[para1(but1)]-[but1]-|",
Expand Down
35 changes: 35 additions & 0 deletions shoes/layout/config.h
@@ -0,0 +1,35 @@
/*
* Autogenerated by the Meson build system.
* Do not edit, your changes will be lost.
*/

#pragma once

#define ENABLE_NLS 1

#define GETTEXT_PACKAGE PACKAGE_NAME

#define HAVE_STDBOOL_H

#define HAVE_STDINT_H

#define HAVE_STDLIB_H

#define LOCALEDIR PACKAGE_LOCALE_DIR

#define PACKAGE_DATADIR "/usr/local/share"

#define PACKAGE_LIBDIR "/usr/local/lib/x86_64-linux-gnu"

#define PACKAGE_LIBEXECDIR "/usr/local/libexec"

#define PACKAGE_LOCALE_DIR "/usr/local/share/locale"

#define PACKAGE_NAME "emeus"

#define PACKAGE_STRING "emeus-0.99.1"

#define PACKAGE_VERSION "0.99.1"

#define _EMEUS_PUBLIC __attribute__((visibility("default")))

60 changes: 60 additions & 0 deletions shoes/layout/emeus-constraint-private.h
@@ -0,0 +1,60 @@
/* emeus-constraint-private.h: The base constraint object
*
* Copyright 2016 Endless
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "emeus-constraint.h"
//#include "emeus-constraint-layout-private.h"
#include "emeus-types-private.h"

G_BEGIN_DECLS

struct _EmeusConstraint
{
GInitiallyUnowned parent_instance;

gpointer target_object;
EmeusConstraintAttribute target_attribute;

EmeusConstraintRelation relation;

gpointer source_object;
EmeusConstraintAttribute source_attribute;

double multiplier;
double constant;

int strength;

gboolean is_active;

char *description;
SimplexSolver *solver;
Constraint *constraint;
EmeusConstraintLayout *layout;
};

gboolean emeus_constraint_attach (EmeusConstraint *constraint,
EmeusConstraintLayout *layout);
void emeus_constraint_detach (EmeusConstraint *constraint);

Constraint * emeus_constraint_get_real_constraint (EmeusConstraint *constraint);

const char * emeus_constraint_to_string (EmeusConstraint *constraint);

G_END_DECLS

0 comments on commit ae75958

Please sign in to comment.