Minsky
pubTab.h
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2023
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef PUBTAB_H
21 #define PUBTAB_H
22 
23 #include "item.h"
24 #include "pannableTab.h"
25 #include "publication.h"
26 #include "renderNativeWindow.h"
27 
28 namespace minsky
29 {
31  {
32  public:
33  PubItem()=default;
35  if (item) editorMode=item->editorMode();
36  }
38  schema3::PublicationItem(state), itemRef(item) {}
41  Point itemCoords(float x, float y) const;
42  };
43 
45  {
46  float offsx=0, offsy=0;
47  float m_zoomFactor=1;
48  bool panning=false;
49  };
50 
51  class PubTab: public PannableTab<PubTabBase>
52  {
53  bool redraw(int x0, int y0, int width, int height) override;
55  PubItem* item=nullptr; // weak reference for moving items
56  PubItem* m_getItemAt(float x, float y);
57  void zoomTranslate(float& x, float& y);
58  bool rotating=false;
60  float dx,dy;
61  Exclude<Point> rotateOrigin;
63  public:
64  PubTab()=default;
65  PubTab(const char* name): name(name) {}
66  PubTab(const std::string& name): name(name) {}
67  std::string name;
68  std::vector<PubItem> items;
69  void addNote(const std::string& note, float x, float y);
72  void removeSelf();
73  void removeItemAt(float x, float y);
74  void rotateItemAt(float x, float y);
75  void toggleEditorModeAt(float x, float y) {
76  zoomTranslate(x,y);
77  if (auto i=m_getItemAt(x,y))
78  i->editorMode=!i->editorMode;
79  }
80  bool getItemAt(float x, float y) override {
81  zoomTranslate(x,y);
82  return m_getItemAt(x,y);
83  }
84  void mouseDown(float x, float y) override;
85  void controlMouseDown(float x, float y) override {panning=true; PannableTab<PubTabBase>::mouseDown(x,y);}
86  void mouseUp(float x, float y) override;
87  void mouseMove(float x, float y) override;
88  bool keyPress(const EventInterface::KeyPressArgs&) override;
89  bool hasScrollBars() const override {return true;}
90  };
91 }
92 
93 #include "pubTab.cd"
94 #endif
void addNote(const std::string &note, float x, float y)
Definition: pubTab.cc:99
float dy
relative offset between mouse and item origin when moving
Definition: pubTab.h:60
float dx
Definition: pubTab.h:60
ItemPtr itemRef
Definition: pubTab.h:39
PubItem()=default
bool hasScrollBars() const override
return whether this window has scrollbars (needed for MacOSX).
Definition: pubTab.h:89
void mouseMove(float x, float y) override
Definition: pubTab.cc:264
void mouseDown(float x, float y) override
Definition: pannableTab.h:44
std::vector< PubItem > items
list of wrapped items and annotations
Definition: pubTab.h:68
ClickType::Type clickType
Definition: pubTab.h:59
represents rectangular region of a lasso operation
Definition: lasso.h:28
void mouseDown(float x, float y) override
Definition: pubTab.cc:193
PubTab(const std::string &name)
Definition: pubTab.h:66
PubTab()=default
std::shared_ptr< Item > ItemPtr
Definition: item.h:57
void mouseUp(float x, float y) override
Definition: pubTab.cc:226
PubItem * m_getItemAt(float x, float y)
Definition: pubTab.cc:175
bool getItemAt(float x, float y) override
item or wire obtained by get*At() calls
Definition: pubTab.h:80
void removeItemAt(float x, float y)
Definition: pubTab.cc:121
Point itemCoords(float x, float y) const
given (x,y) in PubTab, returns coordinates within item. Nb: must be wrapped by EnsureEditorMode ...
Definition: pubTab.cc:93
bool keyPress(const EventInterface::KeyPressArgs &) override
handle key press over current itemFocus,
Definition: pubTab.cc:316
float m_zoomFactor
Definition: pubTab.h:47
bool rotating
Definition: pubTab.h:58
void removeSelf()
remove this from the global minsky object calling this method will invalidate any references to this...
Definition: pubTab.cc:110
void toggleEditorModeAt(float x, float y)
Definition: pubTab.h:75
PubItem(const ItemPtr &item)
Definition: pubTab.h:34
void zoomTranslate(float &x, float &y)
Definition: pubTab.cc:186
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22
void rotateItemAt(float x, float y)
Definition: pubTab.cc:135
Mixin implementing common panning functionality in tabs.
Definition: pannableTab.h:36
boost::geometry::model::d2::point_xy< float > Point
Definition: geometry.h:34
PubTab(const char *name)
Definition: pubTab.h:65
PubItem * item
Definition: pubTab.h:55
void controlMouseDown(float x, float y) override
Definition: pubTab.h:85
std::string name
name of this publication tab
Definition: pubTab.h:67
CLASSDESC_ACCESS(PubTab)
Exclude< Point > rotateOrigin
reference position for rotating
Definition: pubTab.h:61
PubItem(const ItemPtr &item, const schema3::PublicationItem &state)
Definition: pubTab.h:37
bool redraw(int x0, int y0, int width, int height) override
Definition: pubTab.cc:145
LassoBox lasso
Definition: pubTab.h:62